From 431b04a01173691b36fa47079cd2609cd65abaad Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 29 Jan 2024 13:23:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E5=88=97=E8=A1=A8=E6=97=B6=E7=9A=84=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=EF=BC=88#1621=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/lang/en-us.json | 1 + src/lang/zh-cn.json | 1 + src/lang/zh-tw.json | 1 + src/renderer/components/common/ListAddModal.vue | 7 +++++-- src/renderer/components/common/ListAddMultipleModal.vue | 7 +++++-- src/renderer/views/List/MyList/useEditList.ts | 5 ++++- 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 814bca7798..c06fdaa85a 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -24,6 +24,7 @@ - 改进本地音乐在线信息的匹配机制 - 优化任务下载状态显示,现在下载时若数据传输完成但数据写入未完成时会显示相应的状态 - 添加对下载歌曲时封面图片大小的控制处理(#1609) +- 添加创建同名列表时的二次确认(#1621) ### 修复 diff --git a/src/lang/en-us.json b/src/lang/en-us.json index b855de3dcb..daca91049e 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -119,6 +119,7 @@ "list_add__title_first_add": "Add", "list_add__title_first_move": "Move", "list_add__title_last": "to...", + "list_duplicate_tip": "A list with the same name already exists. Do you want to continue creating it?", "list_import_tip__alldata": "Import failed, this is an all data backup file, you need to go here to import: \nSettings -> Backup and Restore -> All Data -> Import", "list_import_tip__playlist": "Import failed, this is a list backup file, you need to go here to import: \nSettings -> Backup and Restore -> Import List", "list_import_tip__playlist_part": "The import failed, this is a single-list file, you need to go here to import: \nMy List -> Right-click on any list name -> Select Import in the pop-up menu", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index 473af09e54..99a085a95b 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -119,6 +119,7 @@ "list_add__title_first_add": "添加", "list_add__title_first_move": "移动", "list_add__title_last": "到...", + "list_duplicate_tip": "已存在同名列表,是否仍要继续创建?", "list_import_tip__alldata": "导入失败,这是一个所有数据备份文件,你需要去这里导入:\n设置 -> 备份与恢复 -> 所有数据 -> 导入", "list_import_tip__playlist": "导入失败,这是一个列表备份文件,你需要去这里导入:\n设置 -> 备份与恢复 -> 部分数据 -> 导入列表", "list_import_tip__playlist_part": "导入失败,这是一个单列表文件,你需要去这里导入:\n我的列表 -> 右击任意一个列表名 -> 在弹出的菜单中选择导入", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index 6c24a174eb..29b9b1f90e 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -119,6 +119,7 @@ "list_add__title_first_add": "添加", "list_add__title_first_move": "移動", "list_add__title_last": "到...", + "list_duplicate_tip": "已存在同名列表,是否仍要繼續建立?", "list_import_tip__alldata": "導入失敗,這是一個所有資料備份文件,你需要去這裡導入:\n設定 -> 備份與還原 -> 所有資料 -> 匯入", "list_import_tip__playlist": "導入失敗,這是一個列表備份文件,你需要去這裡導入:\n設定 -> 備份與還原 -> 部分資料 -> 匯入列表", "list_import_tip__playlist_part": "導入失敗,這是一個單列表文件,你需要去這裡導入:\n我的清單 -> 右鍵點選任何一個清單名稱 -> 在彈出的選單中選擇導入", diff --git a/src/renderer/components/common/ListAddModal.vue b/src/renderer/components/common/ListAddModal.vue index afc47c8ed3..825e753f0f 100644 --- a/src/renderer/components/common/ListAddModal.vue +++ b/src/renderer/components/common/ListAddModal.vue @@ -23,6 +23,7 @@ import { defaultList, loveList, userLists } from '@renderer/store/list/state' import { addListMusics, moveListMusics, createUserList, getMusicExistListIds } from '@renderer/store/list/action' import useKeyDown from '@renderer/utils/compositions/useKeyDown' import { useI18n } from '@root/lang' +import { dialog } from '@renderer/plugins/Dialog' export default { props: { @@ -168,11 +169,13 @@ export default { this.isEditing = true this.$nextTick(() => event.currentTarget.querySelector('.' + this.$style.newListInput).focus()) }, - handleSaveList(event) { + async handleSaveList(event) { let name = event.target.value this.newListName = event.target.value = '' this.isEditing = false - if (!name) return + if (!name || ( + userLists.some(l => l.name == name) && !(await dialog.confirm(window.i18n.t('list_duplicate_tip')))) + ) return void createUserList({ name }) }, }, diff --git a/src/renderer/components/common/ListAddMultipleModal.vue b/src/renderer/components/common/ListAddMultipleModal.vue index 80df9ff7ce..3224c58846 100644 --- a/src/renderer/components/common/ListAddMultipleModal.vue +++ b/src/renderer/components/common/ListAddMultipleModal.vue @@ -22,6 +22,7 @@ import { defaultList, loveList, userLists } from '@renderer/store/list/state' import { addListMusics, moveListMusics, createUserList } from '@renderer/store/list/action' import useKeyDown from '@renderer/utils/compositions/useKeyDown' import { useI18n } from '@root/lang' +import { dialog } from '@renderer/plugins/Dialog' export default { props: { @@ -129,11 +130,13 @@ export default { this.isEditing = true this.$nextTick(() => event.currentTarget.querySelector('.' + this.$style.newListInput).focus()) }, - handleSaveList(event) { + async handleSaveList(event) { let name = event.target.value this.newListName = event.target.value = '' this.isEditing = false - if (!name) return + if (!name || ( + userLists.some(l => l.name == name) && !(await dialog.confirm(window.i18n.t('list_duplicate_tip')))) + ) return void createUserList({ name }) }, }, diff --git a/src/renderer/views/List/MyList/useEditList.ts b/src/renderer/views/List/MyList/useEditList.ts index 22f62acd54..942b654c64 100644 --- a/src/renderer/views/List/MyList/useEditList.ts +++ b/src/renderer/views/List/MyList/useEditList.ts @@ -1,6 +1,7 @@ import { ref, nextTick, useCssModule, type Ref } from '@common/utils/vueTools' import { userLists } from '@renderer/store/list/state' import { updateUserList, createUserList } from '@renderer/store/list/action' +import { dialog } from '@renderer/plugins/Dialog' export default ({ dom_lists_list }: { dom_lists_list: Ref @@ -39,7 +40,9 @@ export default ({ dom_lists_list }: { let name = target.value.trim() target.readOnly = true - if (name == '') { + if (name == '' || ( + userLists.some(l => l.name == name) && !(await dialog.confirm(window.i18n.t('list_duplicate_tip')))) + ) { isShowNewList.value = false return }