Browse Source

fix: 主题样式设置无效,close #2685

vben 2 years ago
parent
commit
14ba72dd1c

+ 1 - 0
package.json

@@ -125,6 +125,7 @@
     "@vben/eslint-config": "workspace:*",
     "@vben/eslint-config": "workspace:*",
     "@vben/stylelint-config": "workspace:*",
     "@vben/stylelint-config": "workspace:*",
     "@vben/ts-config": "workspace:*",
     "@vben/ts-config": "workspace:*",
+    "@vben/types": "workspace:*",
     "@vben/vite-config": "workspace:*",
     "@vben/vite-config": "workspace:*",
     "@vue/compiler-sfc": "^3.2.47",
     "@vue/compiler-sfc": "^3.2.47",
     "@vue/test-utils": "^2.3.2",
     "@vue/test-utils": "^2.3.2",

+ 17 - 5
packages/types/src/utils.ts

@@ -1,9 +1,4 @@
 /**
 /**
- * 任意类型的函数
- */
-type AnyFunction = AnyNormalFunction | AnyPromiseFunction;
-
-/**
  * 任意类型的异步函数
  * 任意类型的异步函数
  */
  */
 type AnyPromiseFunction = (...arg: any) => PromiseLike<any>;
 type AnyPromiseFunction = (...arg: any) => PromiseLike<any>;
@@ -14,6 +9,11 @@ type AnyPromiseFunction = (...arg: any) => PromiseLike<any>;
 type AnyNormalFunction = (...arg: any) => any;
 type AnyNormalFunction = (...arg: any) => any;
 
 
 /**
 /**
+ * 任意类型的函数
+ */
+type AnyFunction = AnyNormalFunction | AnyPromiseFunction;
+
+/**
  *  T | null 包装
  *  T | null 包装
  */
  */
 type Nullable<T> = T | null;
 type Nullable<T> = T | null;
@@ -35,6 +35,16 @@ type ReadonlyRecordable<T = any> = {
   readonly [key: string]: T;
   readonly [key: string]: T;
 };
 };
 
 
+/**
+ * setTimeout 返回值类型
+ */
+type TimeoutHandle = ReturnType<typeof setTimeout>;
+
+/**
+ * setInterval 返回值类型
+ */
+type IntervalHandle = ReturnType<typeof setInterval>;
+
 export {
 export {
   type AnyFunction,
   type AnyFunction,
   type AnyPromiseFunction,
   type AnyPromiseFunction,
@@ -43,4 +53,6 @@ export {
   type NonNullable,
   type NonNullable,
   type Recordable,
   type Recordable,
   type ReadonlyRecordable,
   type ReadonlyRecordable,
+  type TimeoutHandle,
+  type IntervalHandle,
 };
 };

+ 3 - 0
pnpm-lock.yaml

@@ -176,6 +176,9 @@ importers:
       '@vben/ts-config':
       '@vben/ts-config':
         specifier: workspace:*
         specifier: workspace:*
         version: link:internal/ts-config
         version: link:internal/ts-config
+      '@vben/types':
+        specifier: workspace:*
+        version: link:packages/types
       '@vben/vite-config':
       '@vben/vite-config':
         specifier: workspace:*
         specifier: workspace:*
         version: link:internal/vite-config
         version: link:internal/vite-config

+ 1 - 1
src/components/SimpleMenu/src/components/Menu.vue

@@ -22,7 +22,7 @@
   import { useDesign } from '/@/hooks/web/useDesign';
   import { useDesign } from '/@/hooks/web/useDesign';
   import { propTypes } from '/@/utils/propTypes';
   import { propTypes } from '/@/utils/propTypes';
   import { createSimpleRootMenuContext } from './useSimpleMenuContext';
   import { createSimpleRootMenuContext } from './useSimpleMenuContext';
-  import mitt from '/@/utils/mitt';
+  import { mitt } from '/@/utils/mitt';
 
 
   export default defineComponent({
   export default defineComponent({
     name: 'Menu',
     name: 'Menu',

+ 4 - 3
src/components/SimpleMenu/src/components/SubMenuItem.vue

@@ -56,6 +56,7 @@
 </template>
 </template>
 
 
 <script lang="ts">
 <script lang="ts">
+  import { type TimeoutHandle, type Recordable } from '@vben/types';
   import type { CSSProperties, PropType } from 'vue';
   import type { CSSProperties, PropType } from 'vue';
   import type { SubMenuProvider } from './types';
   import type { SubMenuProvider } from './types';
   import {
   import {
@@ -77,7 +78,7 @@
   import { Icon } from '/@/components/Icon';
   import { Icon } from '/@/components/Icon';
   import { Popover } from 'ant-design-vue';
   import { Popover } from 'ant-design-vue';
   import { isBoolean, isObject } from '/@/utils/is';
   import { isBoolean, isObject } from '/@/utils/is';
-  import mitt from '/@/utils/mitt';
+  import { mitt } from '/@/utils/mitt';
 
 
   const DELAY = 200;
   const DELAY = 200;
   export default defineComponent({
   export default defineComponent({
@@ -267,14 +268,14 @@
 
 
         rootMenuEmitter.on(
         rootMenuEmitter.on(
           'on-update-opened',
           'on-update-opened',
-          (data: boolean | (string | number)[] | Recordable) => {
+          (data: boolean | (string | number)[] | Recordable<any>) => {
             if (unref(getCollapse)) return;
             if (unref(getCollapse)) return;
             if (isBoolean(data)) {
             if (isBoolean(data)) {
               state.opened = data;
               state.opened = data;
               return;
               return;
             }
             }
             if (isObject(data) && rootProps.accordion) {
             if (isObject(data) && rootProps.accordion) {
-              const { opend, parent, uidList } = data as Recordable;
+              const { opend, parent, uidList } = data as Recordable<any>;
               if (parent === instance?.parent) {
               if (parent === instance?.parent) {
                 state.opened = opend;
                 state.opened = opend;
               } else if (!uidList.includes(instance?.uid)) {
               } else if (!uidList.includes(instance?.uid)) {

+ 1 - 1
src/logics/mitt/routeChange.ts

@@ -2,7 +2,7 @@
  * Used to monitor routing changes to change the status of menus and tabs. There is no need to monitor the route, because the route status change is affected by the page rendering time, which will be slow
  * Used to monitor routing changes to change the status of menus and tabs. There is no need to monitor the route, because the route status change is affected by the page rendering time, which will be slow
  */
  */
 
 
-import mitt from '/@/utils/mitt';
+import { mitt } from '/@/utils/mitt';
 import type { RouteLocationNormalized } from 'vue-router';
 import type { RouteLocationNormalized } from 'vue-router';
 import { getRawRoute } from '/@/utils';
 import { getRawRoute } from '/@/utils';
 
 

+ 1 - 1
src/main.ts

@@ -1,7 +1,7 @@
 import 'uno.css';
 import 'uno.css';
 import '@/design/index.less';
 import '@/design/index.less';
 import '@/components/VxeTable/src/css/index.scss';
 import '@/components/VxeTable/src/css/index.scss';
-import 'ant-design-vue/dist/antd.css';
+import 'ant-design-vue/dist/antd.less';
 // Register icon sprite
 // Register icon sprite
 import 'virtual:svg-icons-register';
 import 'virtual:svg-icons-register';