Modify: clean modals

This commit is contained in:
HFO4
2020-03-11 15:22:21 +08:00
parent 4d70f9fa3e
commit 4ba24e0cf1
30 changed files with 22 additions and 598 deletions

View File

@@ -7,7 +7,7 @@ var BackendVersion = "3.0.0-alpha1"
var RequiredDBVersion = "3.0.0-alpha1"
// IsPro 是否为Pro版本
var IsPro = "true"
var IsPro = "false"
// LastCommit 最后commit id
var LastCommit = "a11f819"

View File

@@ -2,7 +2,6 @@ package hashid
import (
"errors"
"github.com/HFO4/cloudreve/bootstrap/constant"
"github.com/HFO4/cloudreve/pkg/conf"
)
import "github.com/speps/go-hashids"
@@ -62,7 +61,7 @@ func HashID(id uint, t int) string {
// DecodeHashID 计算HashID对应的数据库ID
func DecodeHashID(id string, t int) (uint, error) {
v, _ := HashDecode(id)
if len(v) != 2 || v[1] != constant.HashIDTable[t] {
if len(v) != 2 || v[1] != t {
return 0, ErrTypeNotMatch
}
return uint(v[0]), nil

View File

@@ -1,7 +1,6 @@
package hashid
import (
"github.com/HFO4/cloudreve/bootstrap/constant"
"github.com/stretchr/testify/assert"
"testing"
)
@@ -53,7 +52,6 @@ func TestHashDecode(t *testing.T) {
func TestDecodeHashID(t *testing.T) {
asserts := assert.New(t)
constant.HashIDTable = []int{0, 1, 2, 3, 4, 5}
// 成功
{

View File

@@ -57,7 +57,6 @@ func GiveGroup(user *model.User, groupInfo *serializer.GroupProducts, num int) e
// GiveScore 积分充值
func GiveScore(user *model.User, num int) error {
user.AddScore(num)
return nil
}

View File

@@ -22,17 +22,6 @@ func (pay *ScorePayment) Create(order *model.Order, pack *serializer.PackProduct
return nil, ErrUnsupportedPaymentMethod
}
// 扣除用户积分
if !user.PayScore(order.Price * order.Num) {
return nil, ErrScoreNotEnough
}
// 商品“发货”
if err := GiveProduct(user, pack, group, order.Num); err != nil {
user.AddScore(order.Price * order.Num)
return nil, err
}
// 创建订单记录
order.Status = model.OrderPaid
if _, err := order.Create(); err != nil {

View File

@@ -12,8 +12,6 @@ type SiteConfig struct {
QQLogin bool `json:"QQLogin"`
Themes string `json:"themes"`
DefaultTheme string `json:"defaultTheme"`
ScoreEnabled bool `json:"score_enabled"`
ShareScoreRate string `json:"share_score_rate"`
HomepageViewMethod string `json:"home_view_method"`
ShareViewMethod string `json:"share_view_method"`
Authn bool `json:"authn"'`
@@ -72,8 +70,6 @@ func BuildSiteConfig(settings map[string]string, user *model.User) Response {
QQLogin: model.IsTrueVal(checkSettingValue(settings, "qq_login")),
Themes: checkSettingValue(settings, "themes"),
DefaultTheme: checkSettingValue(settings, "defaultTheme"),
ScoreEnabled: model.IsTrueVal(checkSettingValue(settings, "score_enabled")),
ShareScoreRate: checkSettingValue(settings, "share_score_rate"),
HomepageViewMethod: checkSettingValue(settings, "home_view_method"),
ShareViewMethod: checkSettingValue(settings, "share_view_method"),
Authn: model.IsTrueVal(checkSettingValue(settings, "authn_enabled")),

View File

@@ -11,7 +11,6 @@ type Share struct {
Key string `json:"key"`
Locked bool `json:"locked"`
IsDir bool `json:"is_dir"`
Score int `json:"score"`
CreateDate string `json:"create_date,omitempty"`
Downloads int `json:"downloads"`
Views int `json:"views"`
@@ -36,7 +35,6 @@ type shareSource struct {
type myShareItem struct {
Key string `json:"key"`
IsDir bool `json:"is_dir"`
Score int `json:"score"`
Password string `json:"password"`
CreateDate string `json:"create_date,omitempty"`
Downloads int `json:"downloads"`
@@ -55,7 +53,6 @@ func BuildShareList(shares []model.Share, total int) Response {
item := myShareItem{
Key: hashid.HashID(shares[i].ID, hashid.ShareID),
IsDir: shares[i].IsDir,
Score: shares[i].Score,
Password: shares[i].Password,
CreateDate: shares[i].CreatedAt.Format("2006-01-02 15:04:05"),
Downloads: shares[i].Downloads,
@@ -101,7 +98,6 @@ func BuildShareResponse(share *model.Share, unlocked bool) Share {
Nick: creator.Nick,
GroupName: creator.Group.Name,
},
Score: share.Score,
CreateDate: share.CreatedAt.Format("2006-01-02 15:04:05"),
}

View File

@@ -24,7 +24,6 @@ type User struct {
Avatar string `json:"avatar"`
CreatedAt int64 `json:"created_at"`
PreferredTheme string `json:"preferred_theme"`
Score int `json:"score"`
Anonymous bool `json:"anonymous"`
Policy policy `json:"policy"`
Group group `json:"group"`
@@ -97,7 +96,6 @@ func BuildUser(user model.User) User {
Avatar: user.Avatar,
CreatedAt: user.CreatedAt.Unix(),
PreferredTheme: user.OptionsSerialized.PreferredTheme,
Score: user.Score,
Anonymous: user.IsAnonymous(),
Policy: policy{
SaveType: user.Policy.Type,
@@ -112,7 +110,6 @@ func BuildUser(user model.User) User {
AllowShare: user.Group.ShareEnabled,
AllowRemoteDownload: user.Group.OptionsSerialized.Aria2,
AllowArchiveDownload: user.Group.OptionsSerialized.ArchiveDownload,
ShareFreeEnabled: user.Group.OptionsSerialized.ShareFree,
ShareDownload: user.Group.OptionsSerialized.ShareDownload,
CompressEnabled: user.Group.OptionsSerialized.ArchiveTask,
WebDAVEnabled: user.Group.WebDAVEnabled,

View File

@@ -55,25 +55,6 @@ func BuildPolicySettingRes(policies []model.Policy, current *model.Policy) Respo
}
}
// BuildMountedFolderRes 构建已挂载目录响应list为当前用户可用存储策略ID
func BuildMountedFolderRes(folders []model.Folder, list []uint) []MountedFolders {
res := make([]MountedFolders, 0, len(folders))
for _, folder := range folders {
single := MountedFolders{
ID: hashid.HashID(folder.ID, hashid.FolderID),
Name: folder.Name,
PolicyName: "[已失效存储策略]",
}
if policy, err := model.GetPolicyByID(folder.PolicyID); err == nil && util.ContainsUint(list, policy.ID) {
single.PolicyName = policy.Name
}
res = append(res, single)
}
return res
}
// BuildUserQuotaResponse 序列化用户存储配额概况响应
func BuildUserQuotaResponse(user *model.User, packs []model.StoragePack) Response {
packSize := user.GetAvailablePackSize()

View File

@@ -356,17 +356,6 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *filesyst
fs.Use("AfterValidateFailed", filesystem.HookGiveBackCapacity)
ctx = context.WithValue(ctx, fsctx.FileModelCtx, *originFile)
} else {
// 检查父目录指定存储策略
if exist, folder := fs.IsPathExist(filePath); exist {
if folder.PolicyID != 0 {
// 尝试获取并重设存储策略
if policy, err := model.GetPolicyByID(fs.User.GetPolicyID(folder.PolicyID)); err == nil {
fs.User.Policy = policy
fs.DispatchHandler()
}
}
}
// 给文件系统分配钩子
fs.Use("BeforeUpload", filesystem.HookValidateFile)
fs.Use("BeforeUpload", filesystem.HookValidateCapacity)