2026年3月14日14:37:06

This commit is contained in:
Alex-larget
2026-03-14 14:37:17 +08:00
parent db4b4b8b87
commit 8778a42429
452 changed files with 92375 additions and 1014 deletions

View File

@@ -18,7 +18,6 @@ const linkedMpConfigKey = "linked_miniprograms"
// LinkedMpItem 关联小程序项key 为 32 位密钥,链接标签存 key小程序端用 key 查 appId
type LinkedMpItem struct {
Key string `json:"key"`
ID string `json:"id,omitempty"` // 兼容旧数据,新数据 key 即主标识
Name string `json:"name"`
AppID string `json:"appId"`
Path string `json:"path,omitempty"`
@@ -41,12 +40,6 @@ func AdminLinkedMpList(c *gin.Context) {
if list == nil {
list = []LinkedMpItem{}
}
// 兼容旧数据:无 key 时用 id 作为 key
for i := range list {
if list[i].Key == "" && list[i].ID != "" {
list[i].Key = list[i].ID
}
}
c.JSON(http.StatusOK, gin.H{"success": true, "data": list})
}
@@ -136,14 +129,11 @@ func AdminLinkedMpUpdate(c *gin.Context) {
}
found := false
for i := range list {
if list[i].Key == body.Key || (list[i].Key == "" && list[i].ID == body.Key) {
if list[i].Key == body.Key {
list[i].Name = body.Name
list[i].AppID = body.AppID
list[i].Path = body.Path
list[i].Sort = body.Sort
if list[i].Key == "" {
list[i].Key = list[i].ID
}
found = true
break
}
@@ -181,7 +171,7 @@ func AdminLinkedMpDelete(c *gin.Context) {
}
newList := make([]LinkedMpItem, 0, len(list))
for _, item := range list {
if item.Key != key && (item.Key != "" || item.ID != key) {
if item.Key != key {
newList = append(newList, item)
}
}