From 1a15faad4289e832627fb41cfc2afb02c3f31a3d Mon Sep 17 00:00:00 2001 From: Jiangchunfu Date: Wed, 10 Jul 2024 14:05:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20edit=20vuex=E8=BF=81=E7=A7=BBpinia=20(#?= =?UTF-8?q?325)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build: dev reload optimized * feat: edit store change pinia * feat: store中状态修改增加方法 * feat: js改为ts --------- Co-authored-by: jiangchunfu --- web/src/management/hooks/useQuestionInfo.js | 12 +- web/src/management/hooks/useResizeObserver.js | 2 +- .../analysis/components/StatisticsItem.vue | 2 +- .../pages/edit/components/MaterialGroup.vue | 8 +- .../pages/edit/components/ModuleNavbar.vue | 7 +- web/src/management/pages/edit/index.vue | 11 +- .../modules/contentModule/HistoryPanel.vue | 15 +- .../modules/contentModule/PublishPanel.vue | 11 +- .../edit/modules/contentModule/SavePanel.vue | 13 +- .../modules/questionModule/PreviewPanel.vue | 38 +- .../modules/questionModule/SetterPanel.vue | 18 +- .../components/QuestionCatalog.vue | 24 +- .../questionModule/components/TypeList.vue | 20 +- .../modules/settingModule/SettingPanel.vue | 11 +- .../settingModule/result/CatalogPanel.vue | 12 +- .../settingModule/result/PreviewPanel.vue | 15 +- .../settingModule/result/SetterPanel.vue | 18 +- .../settingModule/skin/CatalogPanel.vue | 5 +- .../settingModule/skin/PreviewPanel.vue | 18 +- .../settingModule/skin/SetterPanel.vue | 10 +- .../pages/edit/pages/edit/LogicEditPage.vue | 10 +- .../management/pages/publish/PublishPage.vue | 15 +- web/src/management/stores/edit.ts | 343 ++++++++++++++++++ web/vite.config.ts | 8 +- 24 files changed, 494 insertions(+), 152 deletions(-) create mode 100644 web/src/management/stores/edit.ts diff --git a/web/src/management/hooks/useQuestionInfo.js b/web/src/management/hooks/useQuestionInfo.js index f8f66e3f..19049008 100644 --- a/web/src/management/hooks/useQuestionInfo.js +++ b/web/src/management/hooks/useQuestionInfo.js @@ -1,17 +1,19 @@ import { computed } from 'vue' -import store from '@/management/store' +import { storeToRefs } from 'pinia' +import { useEditStore } from '@/management/stores/edit' import { cleanRichText } from '@/common/xss' export const useQuestionInfo = (field) => { + const editStore = useEditStore() + const { questionDataList } = storeToRefs(editStore) + const getQuestionTitle = computed(() => { - const questionDataList = store.state.edit.schema.questionDataList return () => { - return questionDataList.find((item) => item.field === field)?.title + return questionDataList.value.find((item) => item.field === field)?.title } }) const getOptionTitle = computed(() => { - const questionDataList = store.state.edit.schema.questionDataList return (value) => { - const options = questionDataList.find((item) => item.field === field)?.options || [] + const options = questionDataList.value.find((item) => item.field === field)?.options || [] if (value instanceof Array) { return options .filter((item) => value.includes(item.hash)) diff --git a/web/src/management/hooks/useResizeObserver.js b/web/src/management/hooks/useResizeObserver.js index 486962f2..cbf400ea 100644 --- a/web/src/management/hooks/useResizeObserver.js +++ b/web/src/management/hooks/useResizeObserver.js @@ -1,5 +1,5 @@ // 引入防抖函数 -import _debounce from 'lodash/debounce' +import { debounce as _debounce } from 'lodash-es' /** * @description: 监听元素尺寸变化 * @param {*} el 元素dom diff --git a/web/src/management/pages/analysis/components/StatisticsItem.vue b/web/src/management/pages/analysis/components/StatisticsItem.vue index 7cd95b1e..9d43ce2d 100644 --- a/web/src/management/pages/analysis/components/StatisticsItem.vue +++ b/web/src/management/pages/analysis/components/StatisticsItem.vue @@ -34,7 +34,7 @@