代码拉取完成,页面将自动刷新
同步操作将从 haha_Dashen/TCS_Main 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"fmt"
"github.com/valyala/fasthttp"
"io"
"io/ioutil"
"os"
"path"
"strconv"
)
func Resource(w *fasthttp.RequestCtx) {
OpenFile, err := os.Open("template"+string(w.URI().Path()))
if err != nil {
w.SetStatusCode(404)
fmt.Println(string(w.URI().Path()))
return
}
//获取文件类型
FileStat, _ := OpenFile.Stat()
FileExt := path.Ext(string(w.URI().Path()))
var FileContentType string
switch FileExt {
case ".js":
FileContentType = "application/javascript"
case ".css":
FileContentType = "text/css"
case ".woff":
FileContentType = "application/font-woff"
case ".woff2":
FileContentType = "font/woff2"
}
FileSize := strconv.FormatInt(FileStat.Size(), 10)
//写入HTTP头
w.Response.Header.Set("Content-Type", FileContentType)
w.Response.Header.Set("Content-Length", FileSize)
//重置文件指针
_, err = OpenFile.Seek(0, 0)
//发送文件
w.Response.Header.Set("Server", "PackEngine-WEB/Core v1.0")
_, err = io.Copy(w, OpenFile)
return
}
func Index(w *fasthttp.RequestCtx) {
//登录状态判断
if !CheckLoginStatus(w){
w.Redirect("login",302)
return
}
OpenFile, err := os.Open("template/index.html")
File,err := ioutil.ReadAll(OpenFile)
if err != nil {
_ = OpenFile.Close()
w.SetStatusCode(404)
fmt.Println(string(w.URI().Path()))
return
}
FileStat, _ := OpenFile.Stat()
FileSize := strconv.FormatInt(FileStat.Size(), 10)
_ = OpenFile.Close()
//写入HTTP头
w.Response.Header.Set("Content-Type", "text/html")
w.Response.Header.Set("Content-Length", FileSize)
w.Response.Header.Set("Cache-Control", "no-cache")
//发送文件
w.Response.Header.Set("Server", "PackEngine-WEB/Core v1.0")
_,_ = w.Write(File)
return
}
func Dashboard(w *fasthttp.RequestCtx) {
//登录状态判断
if !CheckLoginStatus(w){
//写入HTTP头
w.Response.Header.Set("Content-Type", "text/html")
w.Response.Header.Set("Cache-Control", "no-cache")
//发送文件
w.Response.Header.Set("Server", "PackEngine-WEB/Core v1.0")
_,_ = w.WriteString("<script>window.parent.location.href='login'</script>")
return
}
OpenFile, err := os.Open("template/dashboard.html")
File,err := ioutil.ReadAll(OpenFile)
if err != nil {
_ = OpenFile.Close()
w.SetStatusCode(404)
fmt.Println(string(w.URI().Path()))
return
}
FileStat, _ := OpenFile.Stat()
FileSize := strconv.FormatInt(FileStat.Size(), 10)
_ = OpenFile.Close()
//写入HTTP头
w.Response.Header.Set("Content-Type", "text/html")
w.Response.Header.Set("Content-Length", FileSize)
w.Response.Header.Set("Cache-Control", "no-cache")
//发送文件
w.Response.Header.Set("Server", "PackEngine-WEB/Core v1.0")
_,_ = w.Write(File)
return
}
func Login(w *fasthttp.RequestCtx) {
if CheckLoginStatus(w){
w.Redirect("index",302)
return
}
OpenFile, err := os.Open("template/login.html")
File,err := ioutil.ReadAll(OpenFile)
if err != nil {
_ = OpenFile.Close()
w.SetStatusCode(404)
fmt.Println(string(w.URI().Path()))
return
}
FileStat, _ := OpenFile.Stat()
FileSize := strconv.FormatInt(FileStat.Size(), 10)
_ = OpenFile.Close()
//写入HTTP头
w.Response.Header.Set("Content-Type", "text/html")
w.Response.Header.Set("Content-Length", FileSize)
w.Response.Header.Set("Cache-Control", "no-cache")
//发送文件
w.Response.Header.Set("Server", "PackEngine-WEB/Core v1.0")
_,_ = w.Write(File)
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。