From bff4a60c58dd406684829b676dddbb7abf6401c8 Mon Sep 17 00:00:00 2001 From: baiqi Date: Fri, 10 Nov 2023 10:23:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=BB=84=E4=BB=B6):=20=E8=84=91=E5=9B=BE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=96=B0=E5=8A=9F=E8=83=BD&=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BB=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pure/minder-editor/locale/en-US.ts | 11 ++ .../pure/minder-editor/locale/zh-CN.ts | 11 ++ .../pure/minder-editor/main/header.vue | 1 + .../pure/minder-editor/main/mainEditor.vue | 168 +++++++++++++++++- .../pure/minder-editor/menu/edit/editMenu.vue | 24 ++- .../pure/minder-editor/menu/edit/moveBox.vue | 1 + .../pure/minder-editor/menu/view/mold.vue | 86 ++++----- .../pure/minder-editor/minderEditor.vue | 26 +++ .../components/pure/minder-editor/props.ts | 24 +-- .../script/runtime/clipboard-mimetype.ts | 14 +- .../minder-editor/script/runtime/clipboard.ts | 15 +- .../pure/minder-editor/script/runtime/fsm.ts | 12 +- .../minder-editor/script/runtime/hotbox.ts | 47 ++++- .../minder-editor/script/runtime/jumping.ts | 13 +- .../pure/minder-editor/script/runtime/node.ts | 7 + .../minder-editor/script/runtime/receiver.ts | 84 ++++----- .../pure/ms-table/columnSelector.vue | 3 +- frontend/src/hooks/useTableStore.ts | 2 +- frontend/src/locale/en-US/common.ts | 52 +++--- frontend/src/locale/useLocale.ts | 2 +- frontend/src/store/index.ts | 3 +- .../modules/components/minder-editor/index.ts | 36 ++++ .../modules/components/minder-editor/types.ts | 17 ++ .../{ => components}/ms-table/types.ts | 0 frontend/src/utils/index.ts | 26 +++ .../featureCase/components/caseTable.vue | 68 ++++++- .../projectVersion/index.vue | 19 +- .../projectVersion/locale/en-US.ts | 5 +- .../system/log/components/logCards.vue | 5 +- 29 files changed, 588 insertions(+), 194 deletions(-) create mode 100644 frontend/src/store/modules/components/minder-editor/index.ts create mode 100644 frontend/src/store/modules/components/minder-editor/types.ts rename frontend/src/store/modules/{ => components}/ms-table/types.ts (100%) diff --git a/frontend/src/components/pure/minder-editor/locale/en-US.ts b/frontend/src/components/pure/minder-editor/locale/en-US.ts index 580f066da0..17bf6955e8 100644 --- a/frontend/src/components/pure/minder-editor/locale/en-US.ts +++ b/frontend/src/components/pure/minder-editor/locale/en-US.ts @@ -90,5 +90,16 @@ export default { priority: 'Priority', tag: 'Tag', }, + hotboxMenu: { + expand: 'Expand/Collapse', + insetParent: 'Insert one level up', + insetSon: 'Insert next level', + insetBrother: 'Insert sibling', + copy: 'Copy', + cut: 'Cut', + paste: 'Paste', + delete: 'Delete', + enterNode: 'Enter the current node', + }, }, }; diff --git a/frontend/src/components/pure/minder-editor/locale/zh-CN.ts b/frontend/src/components/pure/minder-editor/locale/zh-CN.ts index 22971627d2..baac07bfa6 100644 --- a/frontend/src/components/pure/minder-editor/locale/zh-CN.ts +++ b/frontend/src/components/pure/minder-editor/locale/zh-CN.ts @@ -84,5 +84,16 @@ export default { priority: '优先级', tag: '标签', }, + hotboxMenu: { + expand: '展开/收起', + insetParent: '插入上一级', + insetSon: '插入下一级', + insetBrother: '插入同级', + copy: '复制', + cut: '剪切', + paste: '粘贴', + delete: '删除', + enterNode: '进入当前节点', + }, }, }; diff --git a/frontend/src/components/pure/minder-editor/main/header.vue b/frontend/src/components/pure/minder-editor/main/header.vue index 2d95948515..9b73299d9d 100644 --- a/frontend/src/components/pure/minder-editor/main/header.vue +++ b/frontend/src/components/pure/minder-editor/main/header.vue @@ -4,6 +4,7 @@
- {{ - t('minder.main.main.save') - }} + + {{ t('minder.main.main.save') }} + + + + + +
+ + + {{ crumb.text }} + + +
diff --git a/frontend/src/components/pure/minder-editor/menu/edit/editMenu.vue b/frontend/src/components/pure/minder-editor/menu/edit/editMenu.vue index f49137f025..1fb15ff9a5 100644 --- a/frontend/src/components/pure/minder-editor/menu/edit/editMenu.vue +++ b/frontend/src/components/pure/minder-editor/menu/edit/editMenu.vue @@ -17,7 +17,7 @@ {{ t('minder.menu.expand.folding') }} - + @@ -39,10 +39,14 @@ :priority-start-with-zero="props.priorityStartWithZero" /> + diff --git a/frontend/src/components/pure/minder-editor/menu/edit/moveBox.vue b/frontend/src/components/pure/minder-editor/menu/edit/moveBox.vue index 2f85635d56..e828d66d40 100644 --- a/frontend/src/components/pure/minder-editor/menu/edit/moveBox.vue +++ b/frontend/src/components/pure/minder-editor/menu/edit/moveBox.vue @@ -40,6 +40,7 @@ const props = defineProps<{ moveEnable: boolean; + moveConfirm: any; }>(); let minder = reactive({}); diff --git a/frontend/src/components/pure/minder-editor/menu/view/mold.vue b/frontend/src/components/pure/minder-editor/menu/view/mold.vue index 286c2fc412..3aac927672 100644 --- a/frontend/src/components/pure/minder-editor/menu/view/mold.vue +++ b/frontend/src/components/pure/minder-editor/menu/view/mold.vue @@ -1,27 +1,34 @@ - - +@/store/modules/components/ms-table/types diff --git a/frontend/src/hooks/useTableStore.ts b/frontend/src/hooks/useTableStore.ts index caa43b4acc..21c7b26382 100644 --- a/frontend/src/hooks/useTableStore.ts +++ b/frontend/src/hooks/useTableStore.ts @@ -4,7 +4,7 @@ import localforage from 'localforage'; import { MsTableColumn, MsTableColumnData } from '@/components/pure/ms-table/type'; import { useAppStore } from '@/store'; -import { PageSizeMap, SelectorColumnMap, TableOpenDetailMode } from '@/store/modules/ms-table/types'; +import { PageSizeMap, SelectorColumnMap, TableOpenDetailMode } from '@/store/modules/components/ms-table/types'; import { isArraysEqualWithOrder } from '@/utils/equal'; import { SpecialColumnEnum } from '@/enums/tableEnum'; diff --git a/frontend/src/locale/en-US/common.ts b/frontend/src/locale/en-US/common.ts index 29620714e8..f1fadf5095 100644 --- a/frontend/src/locale/en-US/common.ts +++ b/frontend/src/locale/en-US/common.ts @@ -1,7 +1,7 @@ export default { - 'common.pleaseSelectMember': 'Please select member', + 'common.pleaseSelectMember': 'Please select a member', 'common.add': 'Add', - 'common.saveAndContinue': 'Save & Continue', + 'common.saveAndContinue': 'Save & continue', 'common.edit': 'Edit', 'common.delete': 'Delete', 'common.save': 'Save', @@ -17,6 +17,23 @@ export default { 'common.close': 'Close', 'common.create': 'Create', 'common.update': 'Update', + 'common.all': 'All', + 'common.operation': 'Operation', + 'common.remove': 'Remove', + 'common.revoked': 'Revoked', + 'common.createSuccess': 'Create success', + 'common.createFailed': 'Create failed', + 'common.updateSuccess': 'Update success', + 'common.updateFailed': 'Update failed', + 'common.deleteConfirm': 'Delete confirm', + 'common.deleteSuccess': 'Delete success', + 'common.deleteFailed': 'Delete failed', + 'common.addSuccess': 'Added successfully', + 'common.addFailed': 'Add failed', + 'common.editSuccess': 'Edit success', + 'common.editFailed': 'Edit failed', + 'common.saveSuccess': 'Save success', + 'common.saveFailed': 'Save failed', 'common.confirmEnable': 'Confirm enable', 'common.confirmDisable': 'Confirm disable', 'common.confirmClose': 'Confirm close', @@ -25,21 +42,6 @@ export default { 'common.enableFailed': 'Enable failed', 'common.closeSuccess': 'Close success', 'common.closeFailed': 'Close failed', - 'common.updateSuccess': 'Update success', - 'common.updateFailed': 'Update failed', - 'common.all': 'All', - 'common.operation': 'Operation', - 'common.remove': 'Remove', - 'common.revoked': 'Revoked', - 'common.deleteConfirm': 'Confirm delete?', - 'common.deleteSuccess': 'Delete success', - 'common.deleteFailed': 'Delete failed', - 'common.addSuccess': 'Add success', - 'common.addFailed': 'Add failed', - 'common.editSuccess': 'Edit success', - 'common.editFailed': 'Edit failed', - 'common.saveSuccess': 'Save success', - 'common.saveFailed': 'Save failed', 'common.operationSuccess': 'Operation success', 'common.operationFailed': 'Operation failed', 'common.removeSuccess': 'Remove success', @@ -48,18 +50,20 @@ export default { 'common.revokeDelete': 'Revoke delete', 'common.revokeDeleteSuccess': 'Revoke delete success', 'common.unSaveLeaveTitle': 'Leave this page?', - 'common.unSaveLeaveContent': 'The system may not save your changes', + 'common.unSaveLeaveContent': 'Your changes may not be saved', 'common.leave': 'Leave', 'common.rename': 'Rename', 'common.noData': 'No data', 'common.internal': 'Internal', 'common.custom': 'Custom', 'common.preview': 'Preview', - 'common.fullScreen': 'Full Screen', - 'common.offFullScreen': 'Exit', - 'common.allSelect': 'Select All', + 'common.fullScreen': 'Full screen', + 'common.offFullScreen': 'Off full screen', + 'common.allSelect': 'All select', 'common.setting': 'Setting', - 'common.resetDefault': 'Restore default', - 'common.pleaseSelect': 'Please Select', - 'common.quickAddMember': 'Quick Add Member', + 'common.resetDefault': 'Reset default', + 'common.tagPlaceholder': 'Add tag and press Enter to end', + 'common.batchModify': 'Batch Edit', + 'common.pleaseSelect': 'please choose', + 'common.quickAddMember': 'Quickly add members', }; diff --git a/frontend/src/locale/useLocale.ts b/frontend/src/locale/useLocale.ts index f213ceeb93..659e8cb6be 100644 --- a/frontend/src/locale/useLocale.ts +++ b/frontend/src/locale/useLocale.ts @@ -35,10 +35,10 @@ function setI18nLanguage(locale: LocaleType) { async function changeLocale(locale: LocaleType) { const globalI18n = i18n.global; const currentLocale = unref(globalI18n.locale); - Message.loading(currentLocale === 'zh-CN' ? '语言切换中...' : 'Language switching...'); if (currentLocale === locale) { return locale; } + Message.loading(currentLocale === 'zh-CN' ? '语言切换中...' : 'Language switching...'); if (loadLocalePool.includes(locale)) { setI18nLanguage(locale); diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index f4bf438ffe..b6afde796d 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -4,11 +4,12 @@ import useTableStore from '@/hooks/useTableStore'; import useAppStore from './modules/app'; import useVisitStore from './modules/app/visit'; +import useMinderStore from './modules/components/minder-editor'; import useUserStore from './modules/user'; import { debouncePlugin } from './plugins'; import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; const pinia = createPinia().use(debouncePlugin).use(piniaPluginPersistedstate); -export { useAppStore, useTableStore, useUserStore, useVisitStore }; +export { useAppStore, useMinderStore, useTableStore, useUserStore, useVisitStore }; export default pinia; diff --git a/frontend/src/store/modules/components/minder-editor/index.ts b/frontend/src/store/modules/components/minder-editor/index.ts new file mode 100644 index 0000000000..c9d6049250 --- /dev/null +++ b/frontend/src/store/modules/components/minder-editor/index.ts @@ -0,0 +1,36 @@ +import { defineStore } from 'pinia'; + +import { MinderNodePosition, MinderState } from './types'; + +// 脑图组件的 store +const useMinderStore = defineStore('minder', { + state: (): MinderState => ({ + event: { + name: '', + timestamp: 0, + nodePosition: { + x: 0, + y: 0, + }, + nodeDom: undefined, + nodeData: undefined, + }, + mold: 0, + }), + actions: { + dispatchEvent(name: string, position: MinderNodePosition, nodeDom?: HTMLElement, nodeData?: Record) { + this.event = { + name, + timestamp: Date.now(), + nodePosition: position, + nodeDom, + nodeData, + }; + }, + setMold(val: number) { + this.mold = val; + }, + }, +}); + +export default useMinderStore; diff --git a/frontend/src/store/modules/components/minder-editor/types.ts b/frontend/src/store/modules/components/minder-editor/types.ts new file mode 100644 index 0000000000..d8bbe78b36 --- /dev/null +++ b/frontend/src/store/modules/components/minder-editor/types.ts @@ -0,0 +1,17 @@ +export interface MinderNodePosition { + x: number; + y: number; +} + +export interface MinderEvent { + name: string; + timestamp: number; + nodePosition: MinderNodePosition; + nodeDom?: HTMLElement; + nodeData?: Record; +} + +export interface MinderState { + event: MinderEvent; + mold: number; +} diff --git a/frontend/src/store/modules/ms-table/types.ts b/frontend/src/store/modules/components/ms-table/types.ts similarity index 100% rename from frontend/src/store/modules/ms-table/types.ts rename to frontend/src/store/modules/components/ms-table/types.ts diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 7377c184b2..ef68836fd8 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -234,6 +234,32 @@ export function findNodeByKey(trees: TreeNode[], targetKey: string, custom return null; // 如果在整个树形数组中都没有找到匹配的节点,则返回 null } +/** + * 根据 key 遍历树,并返回找到的节点路径和节点 + */ +export function findNodePathByKey( + tree: TreeNode[], + targetKey: string, + dataKey?: string, + customKey = 'key' +): TreeNode | null { + for (let i = 0; i < tree.length; i++) { + const node = tree[i]; + if (dataKey ? node[dataKey]?.[customKey] === targetKey : node[customKey] === targetKey) { + return { ...node, treePath: [dataKey ? node[dataKey] : node] }; // 如果当前节点的 key 与目标 key 匹配,则返回当前节点 + } + + if (Array.isArray(node.children) && node.children.length > 0) { + const result = findNodePathByKey(node.children, targetKey, dataKey, customKey); // 递归在子节点中查找 + if (result) { + result.treePath.unshift(dataKey ? node[dataKey] : node); + return result; // 如果在子节点中找到了匹配的节点,则返回该节点 + } + } + } + + return null; +} /** * 找出俩数组之间的差异项并返回 * @param targetMap 目标项 diff --git a/frontend/src/views/feature-test/featureCase/components/caseTable.vue b/frontend/src/views/feature-test/featureCase/components/caseTable.vue index 6cc60a1433..b304c2f109 100644 --- a/frontend/src/views/feature-test/featureCase/components/caseTable.vue +++ b/frontend/src/views/feature-test/featureCase/components/caseTable.vue @@ -33,13 +33,23 @@ - + + + {{ nodeData.text }} +