Compare commits
7 Commits
v2.0.0-bet
...
v2.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
1c56d27e20 | |||
4da655cc44 | |||
a746324ecf | |||
1a3b931727 | |||
bfec01e837 | |||
a7ecb7beb8 | |||
c466672626 |
19
.github/workflows/build.yml
vendored
19
.github/workflows/build.yml
vendored
@ -10,16 +10,24 @@ jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ubuntu-latest]
|
||||
platform: [macos-latest]
|
||||
go-version: [1.17]
|
||||
name: Build
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Set up Go
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Setup docker
|
||||
uses: docker-practice/actions-setup-docker@master
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
@ -33,16 +41,11 @@ jobs:
|
||||
ref: v2
|
||||
path: alist-web
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Set up xgo
|
||||
run: |
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
sudo apt install upx
|
||||
brew install upx
|
||||
|
||||
- name: Build web
|
||||
run: |
|
||||
|
21
.github/workflows/release.yml
vendored
21
.github/workflows/release.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: build
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -9,16 +9,24 @@ jobs:
|
||||
release:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ubuntu-latest]
|
||||
platform: [macos-latest]
|
||||
go-version: [1.17]
|
||||
name: Release
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Set up Go
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Setup docker
|
||||
uses: docker-practice/actions-setup-docker@master
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
@ -32,16 +40,11 @@ jobs:
|
||||
ref: v2
|
||||
path: alist-web
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Set up xgo
|
||||
run: |
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
sudo apt install upx
|
||||
brew install upx
|
||||
|
||||
- name: Build web
|
||||
run: |
|
||||
|
10
alist.go
10
alist.go
@ -13,14 +13,6 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
builtAt string
|
||||
goVersion string
|
||||
gitAuthor string
|
||||
gitCommit string
|
||||
gitTag string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&conf.ConfigFile, "conf", "config.json", "config file")
|
||||
flag.BoolVar(&conf.Debug, "debug", false, "start with debug mode")
|
||||
@ -38,7 +30,7 @@ func Init() {
|
||||
|
||||
func main() {
|
||||
if conf.Version {
|
||||
fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion:%s\n", builtAt, goVersion, gitAuthor, gitCommit, gitTag)
|
||||
fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion:%s\n", conf.BuiltAt, conf.GoVersion, conf.GitAuthor, conf.GitCommit, conf.GitTag)
|
||||
return
|
||||
}
|
||||
Init()
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
@ -106,85 +105,79 @@ func initAccounts() {
|
||||
|
||||
func initSettings() {
|
||||
log.Infof("init settings...")
|
||||
version, err := model.GetSettingByKey("version")
|
||||
if err != nil {
|
||||
log.Debugf("first run")
|
||||
version = &model.SettingItem{
|
||||
Key: "version",
|
||||
Value: "0.0.0",
|
||||
Type: "string",
|
||||
Description: "version",
|
||||
Group: model.CONST,
|
||||
}
|
||||
version := model.SettingItem{
|
||||
Key: "version",
|
||||
Value: conf.GitTag,
|
||||
Description: "version",
|
||||
Group: model.CONST,
|
||||
}
|
||||
settingsMap := map[string][]model.SettingItem{
|
||||
"2.0.0": {
|
||||
{
|
||||
Key: "title",
|
||||
Value: "Alist",
|
||||
Description: "title",
|
||||
Type: "string",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "password",
|
||||
Value: "alist",
|
||||
Type: "string",
|
||||
Description: "password",
|
||||
Group: model.PRIVATE,
|
||||
},
|
||||
{
|
||||
Key: "version",
|
||||
Value: "2.0.0",
|
||||
Type: "string",
|
||||
Description: "version",
|
||||
Group: model.CONST,
|
||||
},
|
||||
{
|
||||
Key: "logo",
|
||||
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
|
||||
Type: "string",
|
||||
Description: "logo",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "icon color",
|
||||
Value: "teal.300",
|
||||
Type: "string",
|
||||
Description: "icon's color",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "text types",
|
||||
Value: "txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp",
|
||||
Type: "string",
|
||||
Description: "text type extensions",
|
||||
},
|
||||
{
|
||||
Key: "readme file",
|
||||
Value: "hide",
|
||||
Type: "string",
|
||||
Description: "hide readme file? (show/hide)",
|
||||
},
|
||||
{
|
||||
Key: "music cover",
|
||||
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
|
||||
Type: "string",
|
||||
Description: "music cover image",
|
||||
},
|
||||
{
|
||||
Key: "site beian",
|
||||
Type: "string",
|
||||
Description: "chinese beian info",
|
||||
},
|
||||
|
||||
_ = model.SaveSetting(version)
|
||||
|
||||
settings := []model.SettingItem{
|
||||
{
|
||||
Key: "title",
|
||||
Value: "Alist",
|
||||
Description: "title",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "password",
|
||||
Value: "alist",
|
||||
Description: "password",
|
||||
Group: model.PRIVATE,
|
||||
},
|
||||
{
|
||||
Key: "logo",
|
||||
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
|
||||
Description: "logo",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "favicon",
|
||||
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
|
||||
Description: "favicon",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "icon color",
|
||||
Value: "teal.300",
|
||||
Description: "icon's color",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "text types",
|
||||
Value: "txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp",
|
||||
Description: "text type extensions",
|
||||
},
|
||||
{
|
||||
Key: "readme file",
|
||||
Value: "hide",
|
||||
Description: "hide readme file? (show/hide)",
|
||||
},
|
||||
{
|
||||
Key: "music cover",
|
||||
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
|
||||
Description: "music cover image",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "site beian",
|
||||
Description: "chinese beian info",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "home readme url",
|
||||
Description: "when have multiple, the readme file to show",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
}
|
||||
for k, v := range settingsMap {
|
||||
if utils.VersionCompare(k, version.Value) > 0 {
|
||||
log.Infof("writing [v%s] settings", k)
|
||||
err = model.SaveSettings(v)
|
||||
for _, v := range settings {
|
||||
_, err := model.GetSettingByKey(v.Key)
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = model.SaveSetting(v)
|
||||
if err != nil {
|
||||
log.Fatalf("save settings error")
|
||||
log.Fatalf("failed write setting: %s", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
build.sh
18
build.sh
@ -9,21 +9,25 @@ gitCommit=$(git log --pretty=format:"%h" -1)
|
||||
if [ "$1" == "release" ]; then
|
||||
gitTag=$(git describe --abbrev=0 --tags)
|
||||
else
|
||||
gitTag="beta"
|
||||
gitTag=$(git describe --abbrev=0 --tags)-next
|
||||
fi
|
||||
|
||||
ldflags="\
|
||||
-w -s \
|
||||
-X 'main.builtAt=$builtAt' \
|
||||
-X 'main.goVersion=$goVersion' \
|
||||
-X 'main.gitAuthor=$gitAuthor' \
|
||||
-X 'main.gitCommit=$gitCommit' \
|
||||
-X 'main.gitTag=$gitTag' \
|
||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||
-X 'github.com/Xhofe/alist/conf.GoVersion=$goVersion' \
|
||||
-X 'github.com/Xhofe/alist/conf.GitAuthor=$gitAuthor' \
|
||||
-X 'github.com/Xhofe/alist/conf.GitCommit=$gitCommit' \
|
||||
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
||||
"
|
||||
|
||||
cp -R ../alist-web/dist/* public
|
||||
|
||||
xgo -out alist -ldflags="$ldflags" .
|
||||
if [ "$1" == "release" ]; then
|
||||
xgo -out alist -ldflags="$ldflags" .
|
||||
else
|
||||
xgo -targets=linux/amd64,windows/amd64,darwin/amd64 -out alist -ldflags="$ldflags" .
|
||||
fi
|
||||
mkdir "build"
|
||||
mv alist-* build
|
||||
cd build || exit
|
||||
|
@ -7,6 +7,14 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
BuiltAt string
|
||||
GoVersion string
|
||||
GitAuthor string
|
||||
GitCommit string
|
||||
GitTag string
|
||||
)
|
||||
|
||||
var (
|
||||
ConfigFile string // config file
|
||||
Conf *Config
|
||||
|
@ -115,8 +115,8 @@ func (o Onedrive) Items() []Item {
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "site_url",
|
||||
Label: "site url",
|
||||
Name: "site_id",
|
||||
Label: "site id",
|
||||
Type: "string",
|
||||
Required: false,
|
||||
},
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type Account struct {
|
||||
Name string `json:"name" gorm:"primaryKey" validate:"required"`
|
||||
Index int `json:"index" validate:"required"`
|
||||
Index int `json:"index"`
|
||||
Type string `json:"type"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
@ -28,8 +28,8 @@ type Account struct {
|
||||
Zone string `json:"zone"`
|
||||
RedirectUri string `json:"redirect_uri"`
|
||||
SiteUrl string `json:"site_url"`
|
||||
SiteId string
|
||||
OnedriveType string `json:"onedrive_type"`
|
||||
SiteId string `json:"site_id"`
|
||||
OnedriveType string `json:"onedrive_type"`
|
||||
}
|
||||
|
||||
var accountsMap = map[string]Account{}
|
||||
|
@ -14,7 +14,7 @@ type SettingItem struct {
|
||||
Key string `json:"key" gorm:"primaryKey" validate:"required"`
|
||||
Value string `json:"value"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
//Type string `json:"type"`
|
||||
Group int `json:"group"`
|
||||
}
|
||||
|
||||
@ -22,6 +22,10 @@ func SaveSettings(items []SettingItem) error {
|
||||
return conf.DB.Save(items).Error
|
||||
}
|
||||
|
||||
func SaveSetting(item SettingItem) error {
|
||||
return conf.DB.Save(item).Error
|
||||
}
|
||||
|
||||
func GetSettingsPublic() (*[]SettingItem, error) {
|
||||
var items []SettingItem
|
||||
if err := conf.DB.Where("`group` <> ?", 1).Find(&items).Error; err != nil {
|
||||
|
@ -22,6 +22,7 @@ func SaveMeta(ctx *fiber.Ctx) error {
|
||||
if err := validate.Struct(req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
}
|
||||
req.Path = utils.ParsePath(req.Path)
|
||||
if err := model.SaveMeta(req); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user