[add] public dir PWA support
This commit is contained in:
parent
fcd1a0f2de
commit
d8d14f1994
2 changed files with 21 additions and 1 deletions
|
|
@ -54,7 +54,13 @@ func (d Dir) Open(name string) (http.File, error) {
|
|||
dir = "."
|
||||
}
|
||||
|
||||
fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name)))
|
||||
name = path.Clean("/" + name)
|
||||
fullName := filepath.Join(dir, filepath.FromSlash(name))
|
||||
if isPWA() {
|
||||
if filepath.Ext(fullName) == "" && fullName != dir {
|
||||
fullName = filepath.Join(dir, "index.html")
|
||||
}
|
||||
}
|
||||
|
||||
// Close dir views Disable directory listing
|
||||
stat, err := os.Stat(fullName)
|
||||
|
|
@ -101,6 +107,14 @@ func mapOpenError(originalErr error, name string, sep rune, stat func(string) (f
|
|||
return originalErr
|
||||
}
|
||||
|
||||
// rewrite path
|
||||
func isPWA() bool {
|
||||
if share.App.Static == nil {
|
||||
return false
|
||||
}
|
||||
return share.App.Static.PWA
|
||||
}
|
||||
|
||||
// SetupAdmin setup admin static root
|
||||
func adminRoot() (string, int) {
|
||||
if AdminRoot != "" {
|
||||
|
|
|
|||
|
|
@ -81,9 +81,15 @@ type AppInfo struct {
|
|||
Option map[string]interface{} `json:"option,omitempty"`
|
||||
XGen string `json:"xgen,omitempty"`
|
||||
AdminRoot string `json:"adminRoot,omitempty"`
|
||||
Static *Static `json:"public,omitempty"`
|
||||
Optional map[string]interface{} `json:"optional,omitempty"`
|
||||
}
|
||||
|
||||
// Static setting
|
||||
type Static struct {
|
||||
PWA bool `json:"pwa,omitempty"`
|
||||
}
|
||||
|
||||
// AppStorage 应用存储
|
||||
type AppStorage struct {
|
||||
Default string `json:"default"`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue