34 lines
792 B
Go
34 lines
792 B
Go
// Package web 提供插件管理页面的静态资源。
|
|
package web
|
|
|
|
import "embed"
|
|
|
|
import "path/filepath"
|
|
|
|
//go:embed ui.html ui-config.js app/*.js app/core/*.js app/features/*.js styles/*.css
|
|
var assets embed.FS
|
|
|
|
// UI 返回只读的管理页面内容。
|
|
func UI() []byte {
|
|
value, _, _ := Asset("ui.html")
|
|
return value
|
|
}
|
|
|
|
// Asset 返回嵌入的管理页面资源。
|
|
func Asset(name string) ([]byte, string, bool) {
|
|
value, err := assets.ReadFile(name)
|
|
if err != nil {
|
|
return nil, "", false
|
|
}
|
|
contentType := "application/octet-stream"
|
|
switch filepath.Ext(name) {
|
|
case ".html":
|
|
contentType = "text/html; charset=utf-8"
|
|
case ".css":
|
|
contentType = "text/css; charset=utf-8"
|
|
case ".js":
|
|
contentType = "text/javascript; charset=utf-8"
|
|
}
|
|
return value, contentType, true
|
|
}
|