2026年3月14日14:37:06
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user