Преглед на файлове

perf(架构): router支持query:pageKey,支持同个路由根据pageKey打开多个tab

shizhongming преди 2 години
родител
ревизия
284095f694

+ 3 - 2
src/layouts/page/index.vue

@@ -16,9 +16,9 @@
       >
         <SmartPageProvider>
           <keep-alive v-if="openCache" :include="getCaches">
-            <component :is="Component" :key="route.fullPath" />
+            <component :is="Component" :key="getPageKey(route)" />
           </keep-alive>
-          <component v-else :is="Component" :key="route.fullPath" />
+          <component v-else :is="Component" :key="getPageKey(route)" />
         </SmartPageProvider>
       </transition>
     </template>
@@ -39,6 +39,7 @@
 
   import { useMultipleTabStore } from '@/store/modules/multipleTab';
   import { SmartPageProvider } from '@/components/SmartPageProvider';
+  import { getPageKey } from '@/router/helper/routeHelper';
 
   defineOptions({ name: 'PageLayout' });
 

+ 1 - 2
src/modules/smart-code/views/codeDesign/CodeDesignPage.vue

@@ -217,8 +217,7 @@
 
   const { handleSave, saveLoading, pageTableSettingRef, pageSearchSettingRef, pageFormSettingRef } =
     useSaveConfig(t, isSyncRef, validateFields, dbDataRef, (configId) => {
-      const { fullPath, query, path } = route;
-      console.log(fullPath);
+      const { query, path } = route;
       router.push({
         path: path,
         query: {

+ 3 - 3
src/modules/smart-code/views/codeList/CodeListView.vue

@@ -51,7 +51,7 @@
     router.push({
       path: '/code/codeDesign',
       query: {
-        setKey: buildUUID(),
+        pageKey: buildUUID(),
         configId,
         systemId: currentSystem.id,
       },
@@ -61,7 +61,7 @@
   let currentSystem: Recordable = {};
   const handleSelectSystemChange = (row) => {
     currentSystem = row;
-    reload();
+    query();
   };
 
   const getTableAction = (row): ActionItem[] => {
@@ -80,7 +80,7 @@
   // 生成代码弹窗
   const [registerCodeCreateModal, { openModal: openCodeCreateModal }] = useModal();
 
-  const [registerTable, { reload }] = useSmartTable({
+  const [registerTable, { query }] = useSmartTable({
     id: 'smart-tool-code-codeList',
     customConfig: { storage: true },
     showOverflow: 'tooltip',

+ 10 - 1
src/router/helper/routeHelper.ts

@@ -4,7 +4,7 @@ import type { RouteLocationNormalized, Router, RouteRecordNormalized } from 'vue
 import { getParentLayout, LAYOUT, EXCEPTION_COMPONENT } from '@/router/constant';
 import { cloneDeep, omit } from 'lodash-es';
 import { warn } from '@/utils/log';
-import { createRouter, createWebHashHistory } from 'vue-router';
+import { createRouter, createWebHashHistory, RouteLocationNormalizedLoaded } from 'vue-router';
 
 export type LayoutMapKey = 'LAYOUT';
 const IFRAME = () => import('@/views/sys/iframe/FrameBlank.vue');
@@ -208,3 +208,12 @@ const getComponents = (): Record<string, () => Promise<Recordable>> => {
   });
   return result;
 };
+
+/**
+ * 获取route pagekey
+ * @param route
+ */
+export const getPageKey = (route: RouteLocationNormalizedLoaded) => {
+  const pageKey = route.query?.pageKey;
+  return pageKey || route.fullPath || route.path;
+};

+ 2 - 1
src/store/modules/multipleTab.ts

@@ -14,6 +14,7 @@ import { MULTIPLE_TABS_KEY } from '@/enums/cacheEnum';
 
 import projectSetting from '@/settings/projectSetting';
 import { useUserStore } from '@/store/modules/user';
+import { getPageKey } from '@/router/helper/routeHelper';
 
 export interface MultipleTabState {
   cacheTabList: Set<string>;
@@ -134,7 +135,7 @@ export const useMultipleTabStore = defineStore({
       // Existing pages, do not add tabs repeatedly
       const tabHasExits = this.tabList.some((tab, index) => {
         updateIndex = index;
-        return (tab.fullPath || tab.path) === (fullPath || path);
+        return getPageKey(tab) === getPageKey(route);
       });
 
       // If the tab already exists, perform the update operation

+ 18 - 0
src/utils/form.ts

@@ -0,0 +1,18 @@
+import { useI18n } from '@/hooks/web/useI18n';
+
+/**
+ * 获取启用停用下拉列
+ */
+export const getUseYnSelectOptions = () => {
+  const { t } = useI18n();
+  return [
+    {
+      label: t('common.form.use'),
+      value: 1,
+    },
+    {
+      label: t('common.form.noUse'),
+      value: 0,
+    },
+  ];
+};

+ 2 - 0
src/utils/http/axios/index.ts

@@ -319,4 +319,6 @@ export enum ApiServiceEnum {
   SMART_CODE = 'smart-code',
   // 消息服务,包括短信等
   SMART_MESSAGE = 'smart-message',
+  // kettle管理模块
+  SMART_KETTLE = 'smart-kettle',
 }