mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-10-28 23:26:01 +08:00
precompress embedded frontend. import mholt/archiver.
This commit is contained in:
22
main.go
22
main.go
@ -1,13 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
_ "embed"
|
||||
"flag"
|
||||
"io"
|
||||
"io/fs"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudreve/Cloudreve/v3/bootstrap"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/conf"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/util"
|
||||
"github.com/cloudreve/Cloudreve/v3/routers"
|
||||
|
||||
"github.com/mholt/archiver/v4"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -16,21 +21,28 @@ var (
|
||||
scriptName string
|
||||
)
|
||||
|
||||
//go:embed assets/build
|
||||
var staticEmbed embed.FS
|
||||
//go:embed assets.zip
|
||||
var staticZip string
|
||||
|
||||
var staticFS fs.FS
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&confPath, "c", util.RelativePath("conf.ini"), "配置文件路径")
|
||||
flag.BoolVar(&isEject, "eject", false, "导出内置静态资源")
|
||||
flag.StringVar(&scriptName, "database-script", "", "运行内置数据库助手脚本")
|
||||
flag.Parse()
|
||||
bootstrap.Init(confPath, staticEmbed)
|
||||
|
||||
staticFS = archiver.ArchiveFS{
|
||||
Stream: io.NewSectionReader(strings.NewReader(staticZip), 0, int64(len(staticZip))),
|
||||
Format: archiver.Zip{},
|
||||
}
|
||||
bootstrap.Init(confPath, staticFS)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if isEject {
|
||||
// 开始导出内置静态资源文件
|
||||
bootstrap.Eject(staticEmbed)
|
||||
bootstrap.Eject(staticFS)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user