From 8261617a8dd3cf565a60603311ce342833851452 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Mon, 28 Aug 2023 10:23:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F=E5=92=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=A4=9A=E4=BD=99hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/useCommandComponent.ts | 100 ------------------ frontend/src/hooks/useDialog.ts | 18 ---- .../setting/organization/member/index.vue | 3 +- .../system/authorizedManagement/index.vue | 7 +- .../pluginManager/components/pluginTable.vue | 45 ++++---- .../pluginManager/components/tableExpand.vue | 6 +- .../components/updatePluginModal.vue | 8 +- .../pluginManager/components/uploadModel.vue | 54 +++++----- .../components/uploadSuccessModal.vue | 28 +++-- .../system/pluginManager/locale/en-US.ts | 1 + .../system/pluginManager/locale/zh-CN.ts | 1 + 11 files changed, 86 insertions(+), 185 deletions(-) delete mode 100644 frontend/src/hooks/useCommandComponent.ts delete mode 100644 frontend/src/hooks/useDialog.ts diff --git a/frontend/src/hooks/useCommandComponent.ts b/frontend/src/hooks/useCommandComponent.ts deleted file mode 100644 index f23b5886f5..0000000000 --- a/frontend/src/hooks/useCommandComponent.ts +++ /dev/null @@ -1,100 +0,0 @@ -/* eslint-disable no-restricted-syntax */ -import { - type AppContext, - type Component, - type ComponentPublicInstance, - createVNode, - getCurrentInstance, - render, - type VNode, -} from 'vue'; - -export type Components = Component; - -export interface Options { - visible?: boolean; - onClose?: () => void; - appendTo?: HTMLElement | string; - [key: string]: unknown; -} - -export interface CommandComponent1 { - (options: Options): VNode; - close: () => void; -} - -const getAppendToElement = (props: Options): HTMLElement => { - let appendTo: HTMLElement | null = document.body; - if (props.appendTo) { - if (typeof props.appendTo === 'string') { - appendTo = document.querySelector(props.appendTo); - } - if (props.appendTo instanceof HTMLElement) { - appendTo = props.appendTo; - } - if (!(appendTo instanceof HTMLElement)) { - appendTo = document.body; - } - } - return appendTo; -}; - -const initInstance = ( - // eslint-disable-next-line no-shadow - Component: T, - props: Options, - container: HTMLElement, - appContext: AppContext | null = null -) => { - const vNode = createVNode(Component, props); - vNode.appContext = appContext; - render(vNode, container); - - getAppendToElement(props).appendChild(container); - return vNode; -}; - -// eslint-disable-next-line no-shadow -export const useCommandComponent = (Component: T): CommandComponent1 => { - const appContext = getCurrentInstance()?.appContext; - if (appContext) { - const currentProvides = (getCurrentInstance() as any)?.provides; - Reflect.set(appContext, 'provides', { ...appContext.provides, ...currentProvides }); - } - - const container = document.createElement('div'); - - const close = () => { - render(null, container); - container.parentNode?.removeChild(container); - }; - - const CommandComponent = (options: Options): VNode => { - if (!Reflect.has(options, 'visible')) { - options.visible = true; - } - if (typeof options.onClose !== 'function') { - options.onClose = close; - } else { - const originOnClose = options.onClose; - options.onClose = () => { - originOnClose(); - close(); - }; - } - const vNode = initInstance(Component, options, container, appContext); - const vm = vNode.component?.proxy as ComponentPublicInstance; - for (const prop in options) { - if (Reflect.has(options, prop) && !Reflect.has(vm.$props, prop)) { - vm[prop as keyof ComponentPublicInstance] = options[prop]; - } - } - return vNode; - }; - - CommandComponent.close = close; - - return CommandComponent; -}; - -export default useCommandComponent; diff --git a/frontend/src/hooks/useDialog.ts b/frontend/src/hooks/useDialog.ts deleted file mode 100644 index f8bd96b237..0000000000 --- a/frontend/src/hooks/useDialog.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { computed } from 'vue'; - -export function useDialog(props: any, emits: any) { - const dialogVisible = computed({ - get() { - return props.visible; - }, - set(visible) { - emits('update:visible', visible); - if (!visible) { - emits('close'); - } - }, - }); - return { dialogVisible }; -} - -export default useDialog; diff --git a/frontend/src/views/setting/organization/member/index.vue b/frontend/src/views/setting/organization/member/index.vue index b835b24d2a..2edd5efb4f 100644 --- a/frontend/src/views/setting/organization/member/index.vue +++ b/frontend/src/views/setting/organization/member/index.vue @@ -26,7 +26,7 @@
  • - {{ t('system.authorized.authorityChecking') }} + {{ + t('system.authorized.authorityChecking') + }}
  • @@ -228,6 +230,9 @@ @apply flex justify-between; div { width: 100px; + span { + font-weight: 500; + } } } } diff --git a/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue b/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue index 9e47815975..2c04ff7a00 100644 --- a/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue +++ b/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue @@ -24,7 +24,7 @@
    {{ t('system.plugin.totalNum') }}{{ totalNum }}{{ t('system.plugin.totalNum') }}{{ totalNum }}{{ t('system.plugin.dataList') }}
    + @@ -175,20 +180,12 @@ import MsButton from '@/components/pure/ms-button/index.vue'; import UploadModel from './uploadModel.vue'; import UpdatePluginModal from './updatePluginModal.vue'; - import uploadSuccessModal from './uploadSuccessModal.vue'; + import UploadSuccessModal from './uploadSuccessModal.vue'; import scriptDetailDrawer from './scriptDetailDrawer.vue'; - import { useCommandComponent } from '@/hooks/useCommandComponent'; import useModal from '@/hooks/useModal'; import { Message, TableData, SelectOptionData } from '@arco-design/web-vue'; import useVisit from '@/hooks/useVisit'; - import type { - PluginForms, - PluginList, - PluginItem, - Options, - DrawerConfig, - UpdatePluginModel, - } from '@/models/setting/plugin'; + import type { PluginForms, PluginList, PluginItem, DrawerConfig, UpdatePluginModel } from '@/models/setting/plugin'; import dayjs from 'dayjs'; import TableExpand from './tableExpand.vue'; import { characterLimit } from '@/utils'; @@ -242,6 +239,7 @@ const uploadVisible = ref(false); const updateVisible = ref(false); const updateModalRef = ref(); + const getTime = (time: string): string => { return dayjs(time).format('YYYY-MM-DD HH:mm:ss'); }; @@ -316,25 +314,22 @@ updateVisible.value = true; updateModalRef.value.open(record); } - const myUploadSuccessDialog = useCommandComponent(uploadSuccessModal); - const uploadSuccessOptions = reactive({ - title: 'system.plugin.uploadPlugin', - visible: false, - onOpen: () => uploadPlugin(), - onClose: () => { - myUploadSuccessDialog.close(); - }, - }); - const dialogOpen = (options: Options) => { - options.visible = true; - myUploadSuccessDialog(uploadSuccessOptions); + + const uploadSuccessVisible = ref(false); + + const dialogSuccessOpen = () => { + uploadSuccessVisible.value = true; + }; + const closeHandler = () => { + uploadSuccessVisible.value = false; }; const okHandler = () => { const isOpen = getIsVisited(); if (!isOpen) { - dialogOpen(uploadSuccessOptions); + dialogSuccessOpen(); } }; + const disableHandler = (record: PluginItem) => { openModal({ type: 'info', diff --git a/frontend/src/views/setting/system/pluginManager/components/tableExpand.vue b/frontend/src/views/setting/system/pluginManager/components/tableExpand.vue index cfe9c3eedf..b907a1f9b1 100644 --- a/frontend/src/views/setting/system/pluginManager/components/tableExpand.vue +++ b/frontend/src/views/setting/system/pluginManager/components/tableExpand.vue @@ -8,7 +8,7 @@ >
    {{ index + 1 }} {{ index + 1 }} {{ item.name }}
    - {{ t('system.plugin.allOrganize') }} + {{ t('system.plugin.allOrganize') + }} + + {{ t('system.plugin.theOrganize') }} diff --git a/frontend/src/views/setting/system/pluginManager/components/uploadModel.vue b/frontend/src/views/setting/system/pluginManager/components/uploadModel.vue index d9a80305a2..30025f63a8 100644 --- a/frontend/src/views/setting/system/pluginManager/components/uploadModel.vue +++ b/frontend/src/views/setting/system/pluginManager/components/uploadModel.vue @@ -3,34 +3,37 @@
    - -
    - - - - {{ t('system.plugin.getPlugin') }} - - - - - - - -
    + + + + + {{ t('system.plugin.getPlugin') }} + + + + + + + - - {{ t('system.plugin.allOrganize') }} + + {{ t('system.plugin.allOrganize') }} + + + {{ t('system.plugin.theOrganize') }} @@ -51,12 +54,7 @@ - +
    diff --git a/frontend/src/views/setting/system/pluginManager/components/uploadSuccessModal.vue b/frontend/src/views/setting/system/pluginManager/components/uploadSuccessModal.vue index 4e6c4c387b..977519f7e7 100644 --- a/frontend/src/views/setting/system/pluginManager/components/uploadSuccessModal.vue +++ b/frontend/src/views/setting/system/pluginManager/components/uploadSuccessModal.vue @@ -6,7 +6,7 @@ :footer="false" @open="BeforeOpen" > - +
    {{ t('system.plugin.uploadSuccess') }}
    @@ -36,26 +36,37 @@ diff --git a/frontend/src/views/setting/system/pluginManager/locale/en-US.ts b/frontend/src/views/setting/system/pluginManager/locale/en-US.ts index 08feaa94d8..09ed9a8afa 100644 --- a/frontend/src/views/setting/system/pluginManager/locale/en-US.ts +++ b/frontend/src/views/setting/system/pluginManager/locale/en-US.ts @@ -104,4 +104,5 @@ export default { 'system.plugin.databaseDriver': 'Database Driver', 'system.plugin.deleteContentTip': 'After deletion, the defects/requirements of the platform cannot be synchronized, and the historical data is automatically switched to other templates. Please exercise caution!', + 'system.plugin.allOrganizeTip': 'This rule is common to new organizations', }; diff --git a/frontend/src/views/setting/system/pluginManager/locale/zh-CN.ts b/frontend/src/views/setting/system/pluginManager/locale/zh-CN.ts index a3afb6bfc6..c1078d381f 100644 --- a/frontend/src/views/setting/system/pluginManager/locale/zh-CN.ts +++ b/frontend/src/views/setting/system/pluginManager/locale/zh-CN.ts @@ -83,4 +83,5 @@ export default { 'system.plugin.pluginStatus': '插件状态', 'system.plugin.databaseDriver': '数据库驱动', 'system.plugin.deleteContentTip': '删除后,将无法同步该平台的缺陷/需求,历史数据自动切换为其它模板展示,请谨慎操作!', + 'system.plugin.allOrganizeTip': '新建组织通用此规则', };