Skip to content

Commit 7c6ba17

Browse files
committed
✨ 脚本编辑列表增加脚本搜索与批量置顶 #462
1 parent c1164ce commit 7c6ba17

7 files changed

Lines changed: 174 additions & 103 deletions

File tree

src/locales/ach-UG/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
"batch_operations": "crwdns6100:0crwdne6100:0",
155155
"export": "crwdns6102:0crwdne6102:0",
156156
"delete": "crwdns6104:0crwdne6104:0",
157+
"pin_to_top": "crwdns7020:0crwdne7020:0",
158+
"scripts_pinned_to_top": "crwdns7022:0crwdne7022:0",
157159
"unknown_operation": "crwdns6106:0crwdne6106:0",
158160
"confirm": "crwdns6108:0crwdne6108:0",
159161
"close": "crwdns6110:0crwdne6110:0",
@@ -405,5 +407,6 @@
405407
"invalid_script_code": "crwdns7000:0crwdne7000:0",
406408
"build_failed": "crwdns7002:0crwdne7002:0",
407409
"drag_script_here_to_upload": "crwdns7004:0crwdne7004:0",
408-
"sync_status": "crwdns7006:0crwdne7006:0"
410+
"sync_status": "crwdns7006:0crwdne7006:0",
411+
"search_scripts": "crwdns7024:0crwdne7024:0"
409412
}

src/locales/en/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
"batch_operations": "Batch Operations",
155155
"export": "Export",
156156
"delete": "Delete",
157+
"pin_to_top": "Pin Top",
158+
"scripts_pinned_to_top": "The selected script has been pinned",
157159
"unknown_operation": "Unknown Operation",
158160
"confirm": "Confirm",
159161
"close": "Close",
@@ -405,5 +407,6 @@
405407
"invalid_script_code": "Bad Code",
406408
"build_failed": "Failed to Build",
407409
"drag_script_here_to_upload": "Drag script here to upload it",
408-
"sync_status": "Sync Status"
410+
"sync_status": "Sync Status",
411+
"search_scripts": "Search script"
409412
}

src/locales/vi/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
"batch_operations": "Thao Tác Hàng Loạt",
155155
"export": "Xuất",
156156
"delete": "Xóa",
157+
"pin_to_top": "置顶",
158+
"scripts_pinned_to_top": "已将所选脚本置顶",
157159
"unknown_operation": "Thao Tác Không Xác Định",
158160
"confirm": "Xác Nhận",
159161
"close": "Đóng",
@@ -405,5 +407,6 @@
405407
"invalid_script_code": "错误的脚本代码",
406408
"build_failed": "构建失败",
407409
"drag_script_here_to_upload": "拖拽脚本到此处上传",
408-
"sync_status": "同步状态"
410+
"sync_status": "同步状态",
411+
"search_scripts": "搜索脚本"
409412
}

src/locales/zh-CN/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
"batch_operations": "批量操作",
155155
"export": "导出",
156156
"delete": "删除",
157+
"pin_to_top": "置顶",
158+
"scripts_pinned_to_top": "已将所选脚本置顶",
157159
"unknown_operation": "未知操作",
158160
"confirm": "确定",
159161
"close": "关闭",
@@ -405,5 +407,6 @@
405407
"invalid_script_code": "错误的脚本代码",
406408
"build_failed": "构建失败",
407409
"drag_script_here_to_upload": "拖拽脚本到此处上传",
408-
"sync_status": "同步状态"
410+
"sync_status": "同步状态",
411+
"search_scripts": "搜索脚本"
409412
}

src/locales/zh-TW/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
"batch_operations": "批次操作",
155155
"export": "匯出",
156156
"delete": "刪除",
157+
"pin_to_top": "置頂",
158+
"scripts_pinned_to_top": "已將所選腳本置頂",
157159
"unknown_operation": "未知操作",
158160
"confirm": "確定",
159161
"close": "關閉",
@@ -405,5 +407,6 @@
405407
"invalid_script_code": "錯誤的腳本程式碼",
406408
"build_failed": "建置失敗",
407409
"drag_script_here_to_upload": "拖曳腳本到此處上傳",
408-
"sync_status": "同步狀態"
410+
"sync_status": "同步狀態",
411+
"search_scripts": "搜索腳本"
409412
}

src/pages/options/routes/ScriptList.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,9 @@ function ScriptList() {
746746
<Select.Option key={"delete"} value="delete">
747747
{t("delete")}
748748
</Select.Option>
749+
<Select.Option key={"pin_to_top"} value="pin_to_top">
750+
{t("pin_to_top")}
751+
</Select.Option>
749752
<Select.Option key={"check_update"} value="check_update">
750753
{t("check_update")}
751754
</Select.Option>
@@ -793,6 +796,26 @@ function ScriptList() {
793796
Promise.allSettled(uuids.map((uuid) => scriptClient.delete(uuid)));
794797
}
795798
break;
799+
case "pin_to_top":
800+
// 将选中的脚本置顶
801+
if (select.length > 0) {
802+
// 获取当前所有脚本列表
803+
const currentScripts = store.getState().script.scripts;
804+
// 将选中的脚本依次置顶(从后往前,保持选中脚本之间的相对顺序)
805+
[...select].reverse().forEach((script) => {
806+
// 找到脚本当前的位置
807+
const scriptIndex = currentScripts.findIndex(s => s.uuid === script.uuid);
808+
if (scriptIndex > 0) { // 如果不是已经在最顶部
809+
// 将脚本置顶(移动到第一个位置)
810+
dispatch(sortScript({ active: script.uuid, over: currentScripts[0].uuid }));
811+
}
812+
});
813+
Message.success({
814+
content: t("scripts_pinned_to_top"),
815+
duration: 3000,
816+
});
817+
}
818+
break;
796819
// 批量检查更新
797820
case "check_update":
798821
if (confirm(t("list.confirm_update")!)) {

0 commit comments

Comments
 (0)