From 385cf4b6b8c79654e95d7c7f5bb3b41eaadaf84d Mon Sep 17 00:00:00 2001 From: hsingyin Date: Thu, 5 Dec 2024 10:43:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/locales/en.ts | 2 + src/locales/zh.ts | 2 + src/types/pages/home.d.ts | 2 + src/types/store/subsStore.d.ts | 1 + src/utils/actionsOperate.ts | 8 ++- src/utils/actionsToPorcess.ts | 3 +- src/views/FileEditor.vue | 11 +++- src/views/SubEditor.vue | 10 +++- src/views/editor/ActionBlock.vue | 97 ++++++++++++++++++++++++-------- 10 files changed, 108 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 3c0113382..5a5afd2d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sub-store-front-end", - "version": "2.14.307", + "version": "2.14.308", "private": true, "scripts": { "dev": "vite --host", diff --git a/src/locales/en.ts b/src/locales/en.ts index a60bf05fb..d1969949a 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -372,6 +372,8 @@ export default { placeholder: "Failed to read the clipboard automatically, please paste the data manually in this text box.", }, + enable: 'Enable', + disable: 'Disable', }, nodeActions: { "Flag Operator": { diff --git a/src/locales/zh.ts b/src/locales/zh.ts index c21699444..3b66a5447 100644 --- a/src/locales/zh.ts +++ b/src/locales/zh.ts @@ -389,6 +389,8 @@ export default { label: '从剪贴板导入', placeholder: '自动读取剪贴板失败, 请在此文本框内手动粘贴数据' }, + enable: '启用', + disable: '禁用', }, nodeActions: { 'Script Operator': { diff --git a/src/types/pages/home.d.ts b/src/types/pages/home.d.ts index ae77a519c..71c3d207b 100644 --- a/src/types/pages/home.d.ts +++ b/src/types/pages/home.d.ts @@ -4,4 +4,6 @@ type ActionModuleProps = { type: string; component: any; tipsDes: string; + disabled?: boolean; + enabled?: boolean; }; diff --git a/src/types/store/subsStore.d.ts b/src/types/store/subsStore.d.ts index a24a886ea..28a340cf4 100644 --- a/src/types/store/subsStore.d.ts +++ b/src/types/store/subsStore.d.ts @@ -27,6 +27,7 @@ interface Process { id?: string; customName?: string; args?: ProcessArg; + disabled?: boolean; } interface Sub { diff --git a/src/utils/actionsOperate.ts b/src/utils/actionsOperate.ts index 4bee9ddb4..ce025867a 100644 --- a/src/utils/actionsOperate.ts +++ b/src/utils/actionsOperate.ts @@ -15,16 +15,17 @@ export const addItem = ( const id = Math.random() * 100000000 + ''; const type = selectedOptions[0].value; const args = selectedOptions[0].args; + const enabled = true; const obj = { id, customName: "", type, tipsDes: t(`editorPage.subConfig.nodeActions['${type}'].tipsDes`), component: null, + enabled, }; actionsChecked.push([id, true]); - switch (type) { case 'Flag Operator': case 'Sort Operator': @@ -110,3 +111,8 @@ export const deleteItem = (form, actionsList, actionsChecked, id) => { actionsList.splice(actionsIndex, 1); actionsChecked.splice(checkedIndex, 1); }; + +export const toggleItem = (actionsList, id) => { + const index = actionsList.findIndex((item) => item.id === id); + actionsList[index].enabled = !actionsList[index].enabled; +}; diff --git a/src/utils/actionsToPorcess.ts b/src/utils/actionsToPorcess.ts index 57fca4aee..4dbb39f3d 100644 --- a/src/utils/actionsToPorcess.ts +++ b/src/utils/actionsToPorcess.ts @@ -1,7 +1,7 @@ export const actionsToProcess = ( process: Process[], actionsList: ActionModuleProps[], - ignoreList: string[] + ignoreList: string[], ): Process[] => { const findProcess = (id: string) => process.find((item) => item.id === id); const newProcess = process.filter((item) => { @@ -14,6 +14,7 @@ export const actionsToProcess = ( args: findProcess(item.id).args, customName: findProcess(item.id).customName, id: item.id, + disabled: !item.enabled, }); }); return newProcess; diff --git a/src/views/FileEditor.vue b/src/views/FileEditor.vue index d211a2968..be2140f85 100644 --- a/src/views/FileEditor.vue +++ b/src/views/FileEditor.vue @@ -269,6 +269,7 @@ @updateCustomNameModeFlag="updateCustomNameModeFlag" @addAction="addAction" @deleteAction="deleteAction" + @toggleAction="toggleAction" /> @@ -320,7 +321,7 @@ import { useGlobalStore } from "@/store/global"; import { useSettingsStore } from '@/store/settings'; import { useSubsStore } from "@/store/subs"; import ActionBlock from "@/views/editor/ActionBlock.vue"; -import { addItem, deleteItem } from "@/utils/actionsOperate"; +import { addItem, deleteItem, toggleItem } from "@/utils/actionsOperate"; import { actionsToProcess } from "@/utils/actionsToPorcess"; import Script from "@/views/editor/components/Script.vue"; import IconPopup from "@/views/icon/IconPopup.vue"; @@ -424,7 +425,7 @@ watchEffect(() => { form.process = newProcess; if (sourceData.process.length > 0) { form.process.forEach((item) => { - const { type, id, customName } = item; + const { type, id, customName, disabled } = item; actionsChecked.push([id, true]); const action = { type, @@ -432,6 +433,7 @@ watchEffect(() => { customName, tipsDes: t(`editorPage.subConfig.nodeActions['${type}'].tipsDes`), component: null, + enabled: !disabled, }; switch (type) { case "Script Operator": @@ -456,6 +458,11 @@ const addAction = (val) => { const deleteAction = (id) => { deleteItem(form, actionsList, actionsChecked, id); }; + +const toggleAction = (id) => { + toggleItem(actionsList, id); +} + const closePreview = () => { document.querySelector("html").style["overflow-y"] = ""; document.querySelector("html").style.height = ""; diff --git a/src/views/SubEditor.vue b/src/views/SubEditor.vue index da8241d50..e9b35ce38 100644 --- a/src/views/SubEditor.vue +++ b/src/views/SubEditor.vue @@ -379,6 +379,7 @@ @updateCustomNameModeFlag="updateCustomNameModeFlag" @addAction="addAction" @deleteAction="deleteAction" + @toggleAction="toggleAction" /> @@ -434,7 +435,7 @@ import { useAppNotifyStore } from "@/store/appNotify"; import { useGlobalStore } from "@/store/global"; import { useSettingsStore } from '@/store/settings'; import { useSubsStore } from "@/store/subs"; -import { addItem, deleteItem } from "@/utils/actionsOperate"; +import { addItem, deleteItem, toggleItem } from "@/utils/actionsOperate"; import { actionsToProcess } from "@/utils/actionsToPorcess"; import { initStores } from "@/utils/initApp"; import CompareTable from "@/views/CompareTable.vue"; @@ -641,7 +642,7 @@ watchEffect(() => { if (sourceData.process.length > 0) { form.process.forEach((item) => { - const { type, id, customName } = item; + const { type, id, customName, disabled } = item; if (!ignoreList.includes(type)) { actionsChecked.push([id, true]); @@ -651,6 +652,7 @@ watchEffect(() => { customName, tipsDes: t(`editorPage.subConfig.nodeActions['${type}'].tipsDes`), component: null, + enabled: !disabled, }; switch (type) { case "Flag Operator": @@ -695,6 +697,10 @@ const deleteAction = (id) => { deleteItem(form, actionsList, actionsChecked, id); }; +const toggleAction = (id) => { + toggleItem(actionsList, id); +}; + const closeCompare = () => { document.querySelector("html").style["overflow-y"] = ""; document.querySelector("html").style.height = ""; diff --git a/src/views/editor/ActionBlock.vue b/src/views/editor/ActionBlock.vue index b552400f0..97f3b8cbb 100644 --- a/src/views/editor/ActionBlock.vue +++ b/src/views/editor/ActionBlock.vue @@ -19,18 +19,32 @@ {{ $t(`editorPage.subConfig.basic.nodeActionsHelp`) }} - +