Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-06-18 18:04:23 +08:00
commit e019c39330
2 changed files with 82 additions and 17 deletions

View file

@ -3035,23 +3035,23 @@ func sortAttributeViewRow(operation *Operation) (err error) {
return
}
var rowID string
var itemID string
var idx, previousIndex int
for i, r := range view.Table.RowIDs {
if r == operation.ID {
rowID = r
idx = i
break
}
}
if "" == rowID {
rowID = operation.ID
view.Table.RowIDs = append(view.Table.RowIDs, rowID)
idx = len(view.Table.RowIDs) - 1
}
switch view.LayoutType {
case av.LayoutTypeTable:
for i, r := range view.Table.RowIDs {
if r == operation.ID {
itemID = r
idx = i
break
}
}
if "" == itemID {
itemID = operation.ID
view.Table.RowIDs = append(view.Table.RowIDs, itemID)
idx = len(view.Table.RowIDs) - 1
}
view.Table.RowIDs = append(view.Table.RowIDs[:idx], view.Table.RowIDs[idx+1:]...)
for i, r := range view.Table.RowIDs {
if r == operation.PreviousID {
@ -3059,8 +3059,20 @@ func sortAttributeViewRow(operation *Operation) (err error) {
break
}
}
view.Table.RowIDs = util.InsertElem(view.Table.RowIDs, previousIndex, rowID)
view.Table.RowIDs = util.InsertElem(view.Table.RowIDs, previousIndex, itemID)
case av.LayoutTypeGallery:
for i, c := range view.Gallery.CardIDs {
if c == operation.ID {
itemID = c
idx = i
break
}
}
if "" == itemID {
itemID = operation.ID
view.Gallery.CardIDs = append(view.Gallery.CardIDs, itemID)
idx = len(view.Gallery.CardIDs) - 1
}
view.Gallery.CardIDs = append(view.Gallery.CardIDs[:idx], view.Gallery.CardIDs[idx+1:]...)
for i, c := range view.Gallery.CardIDs {
if c == operation.PreviousID {
@ -3068,6 +3080,7 @@ func sortAttributeViewRow(operation *Operation) (err error) {
break
}
}
view.Gallery.CardIDs = util.InsertElem(view.Gallery.CardIDs, previousIndex, itemID)
}
err = av.SaveAttributeView(attrView)

View file

@ -126,7 +126,9 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
if err != nil {
return err
}
if d == nil {
return nil
}
if !d.IsDir() && strings.HasSuffix(d.Name(), ".sy") {
syPaths = append(syPaths, path)
}
@ -231,6 +233,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
if gulu.File.IsExist(storageAvDir) {
// 重新生成数据库数据
filelock.Walk(storageAvDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if !strings.HasSuffix(path, ".json") || !ast.IsNodeIDPattern(strings.TrimSuffix(d.Name(), ".json")) {
return nil
}
@ -468,7 +476,9 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
if err != nil {
return err
}
if d == nil {
return nil
}
if d.IsDir() && ast.IsNodeIDPattern(d.Name()) {
renamePaths[path] = path
}
@ -540,6 +550,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
// 将包含的资源文件统一移动到 data/assets/ 下
var assetsDirs []string
filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if strings.Contains(path, "assets") && d.IsDir() {
assetsDirs = append(assetsDirs, path)
}
@ -559,6 +575,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
// 将包含的自定义表情统一移动到 data/emojis/ 下
unzipRootEmojisPath := filepath.Join(unzipRootPath, "emojis")
filelock.Walk(unzipRootEmojisPath, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if !util.IsValidUploadFileName(d.Name()) {
emojiFullName := filepath.Join(unzipRootEmojisPath, d.Name())
fullPathFilteredName := filepath.Join(unzipRootEmojisPath, util.FilterUploadFileName(d.Name()))
@ -572,6 +594,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
})
var emojiDirs []string
filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if strings.Contains(path, "emojis") && d.IsDir() {
emojiDirs = append(emojiDirs, path)
}
@ -607,6 +635,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
var treePaths []string
filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if d.IsDir() {
if strings.HasPrefix(d.Name(), ".") {
return filepath.SkipDir
@ -690,6 +724,12 @@ func ImportData(zipPath string) (err error) {
tmpDataPath := filepath.Join(unzipPath, dirs[0].Name())
tmpDataEmojisPath := filepath.Join(tmpDataPath, "emojis")
filelock.Walk(tmpDataEmojisPath, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if !util.IsValidUploadFileName(d.Name()) {
emojiFullName := filepath.Join(tmpDataEmojisPath, d.Name())
fullPathFilteredName := filepath.Join(tmpDataEmojisPath, util.FilterUploadFileName(d.Name()))
@ -754,6 +794,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
// 收集所有资源文件
assets := map[string]string{}
filelock.Walk(localPath, func(currentPath string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if localPath == currentPath {
return nil
}
@ -775,6 +821,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
count := 0
// md 转换 sy
filelock.Walk(localPath, func(currentPath string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d == nil {
return nil
}
if strings.HasPrefix(d.Name(), ".") {
if d.IsDir() {
return filepath.SkipDir