Parcourir la source

chore: miscellaneous modifications

vben il y a 4 ans
Parent
commit
f7aa93f5b0

+ 1 - 1
package.json

@@ -84,7 +84,7 @@
     "lint-staged": "^10.5.1",
     "portfinder": "^1.0.28",
     "postcss-import": "^12.0.1",
-    "prettier": "^2.1.2",
+    "prettier": "^2.2.0",
     "rimraf": "^3.0.2",
     "rollup-plugin-visualizer": "^4.1.2",
     "stylelint": "^13.8.0",

+ 3 - 1
src/hooks/core/useSetting.ts

@@ -20,7 +20,9 @@ const {
 } = ENV;
 
 if (!reg.test(VITE_GLOB_APP_SHORT_NAME)) {
-  warn(`VITE_GLOB_APP_SHORT_NAME 变量只能是字符/下划线,请在环境变量中修改并重新运行。`);
+  warn(
+    `VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`
+  );
 }
 
 export const useSetting = (): SettingWrap => {

+ 1 - 5
src/router/index.ts

@@ -18,11 +18,7 @@ const router = createRouter({
 
 // reset router
 export function resetRouter() {
-  const resetWhiteNameList = [
-    'Login',
-    'Root',
-    // 'FullErrorPage'
-  ];
+  const resetWhiteNameList = ['Login', 'Root'];
   router.getRoutes().forEach((route) => {
     const { name } = route;
     if (name && !resetWhiteNameList.includes(name as string)) {

+ 1 - 0
src/router/types.d.ts

@@ -69,6 +69,7 @@ export interface Menu {
 
   tag?: MenuTag;
 }
+
 export interface MenuModule {
   orderNo?: number;
   menu: Menu;

+ 4 - 5
src/store/modules/app.ts

@@ -81,7 +81,7 @@ class App extends VuexModule {
   public async setPageLoadingAction(loading: boolean): Promise<void> {
     if (loading) {
       clearTimeout(timeId);
-      // 防止闪动
+      // Prevent flicker
       timeId = setTimeout(() => {
         this.commitPageLoadingState(loading);
       }, 100);
@@ -91,9 +91,9 @@ class App extends VuexModule {
     }
   }
 
-  // /**
-  //  * @description: unlock page
-  //  */
+  /**
+   * @description: unlock page
+   */
   @Action
   public async unLockAction({ password, valid = true }: { password: string; valid?: boolean }) {
     if (!valid) {
@@ -125,5 +125,4 @@ class App extends VuexModule {
     return res;
   }
 }
-export { App };
 export const appStore = getModule<App>(App);

+ 0 - 1
src/store/modules/error.ts

@@ -78,5 +78,4 @@ class Error extends VuexModule implements ErrorState {
     this.commitErrorInfoState(errInfo as ErrorInfo);
   }
 }
-export { Error };
 export const errorStore = getModule<Error>(Error);

+ 0 - 1
src/store/modules/menu.ts

@@ -64,5 +64,4 @@ class Menu extends VuexModule {
   }
 }
 
-export { Menu };
 export const menuStore = getModule<Menu>(Menu);

+ 0 - 1
src/store/modules/permission.ts

@@ -128,5 +128,4 @@ class Permission extends VuexModule {
     return routes;
   }
 }
-export { Permission };
 export const permissionStore = getModule<Permission>(Permission);

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

@@ -15,6 +15,7 @@ import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/constant';
 import { getCurrentTo } from '/@/utils/helper/routeHelper';
 
 type CacheName = string | symbol | null | undefined;
+
 /**
  * @description:  vuex Tab模块
  */
@@ -29,6 +30,7 @@ export interface TabItem {
 }
 
 const NAME = 'tab';
+
 hotModuleUnregisterModule(NAME);
 
 const getOpenKeepAliveRef = computed(() => appStore.getProjectConfig.openKeepAlive);
@@ -252,5 +254,4 @@ class Tab extends VuexModule {
     this.closeMultipleTab({ pathList, nameList });
   }
 }
-export { Tab };
 export const tabStore = getModule<Tab>(Tab);

+ 0 - 1
src/store/modules/user.ts

@@ -154,5 +154,4 @@ class User extends VuexModule {
     });
   }
 }
-export { User };
 export const userStore = getModule<User>(User);

+ 2 - 0
src/types/config.d.ts

@@ -138,9 +138,11 @@ export type SetProjectSettingFn = <T extends keyof ProjectConfig>(
   key: T,
   value: ProjectConfig[T]
 ) => void;
+
 interface GlobWrap {
   globSetting: Readonly<GlobConfig>;
 }
+
 interface ProjectSettingWrap {
   projectSetting: Readonly<ProjectConfig>;
 }

+ 6 - 0
src/types/global.d.ts

@@ -37,6 +37,12 @@ declare type DeepPartial<T> = {
   [P in keyof T]?: DeepPartial<T[P]>;
 };
 
+// type DeepPartial<T> = T extends Function
+//   ? T
+//   : T extends object
+//   ? { [K in keyof T]?: DeepPartial<T[K]> }
+//   : T;
+
 declare type LabelValueOptions = {
   label: string;
   value: any;

+ 1 - 9
src/types/shim-tsx.d.ts

@@ -13,21 +13,13 @@ declare global {
     // tslint:disable no-empty-interface
     type ElementClass = ComponentRenderProxy;
     interface ElementAttributesProperty {
-      $props: any; // 定义要使用的属性名称
+      $props: any;
     }
     interface IntrinsicElements {
       [elem: string]: any;
     }
     interface IntrinsicAttributes {
-      // ['v-if']?: unknown;
-      // ['v-else-if']?: unknown;
-      // ['v-else']?: unknown;
-      // need
-      // ['v-show']?: unknown;
       [elem: string]: any;
-      // ['v-html']?: unknown;
-      // ['v-text']?: unknown;
-      // ['v-model']?: unknown;
     }
   }
 }

+ 0 - 0
src/utils/file/stream.ts → src/utils/file/base64.ts


+ 1 - 1
src/utils/file/download.ts

@@ -1,4 +1,4 @@
-import { dataURLtoBlob, urlToBase64 } from './stream';
+import { dataURLtoBlob, urlToBase64 } from './base64';
 
 /**
  * Download online pictures

+ 6 - 6
src/utils/helper/persistent.ts

@@ -7,8 +7,8 @@ const ls = createStorage(localStorage);
 const ss = createStorage();
 
 interface CacheStore {
-  local?: any;
-  session?: any;
+  local: Record<string, any>;
+  session: Record<string, any>;
 }
 
 /**
@@ -25,14 +25,14 @@ function initCache() {
   cacheStore.local = ls.get(BASE_LOCAL_CACHE_KEY) || {};
   cacheStore.session = ss.get(BASE_SESSION_CACHE_KEY) || {};
 }
+
 initCache();
 
 export function setLocal(key: string, value: any, immediate = false) {
   cacheStore.local[BASE_LOCAL_CACHE_KEY] = cacheStore.local[BASE_LOCAL_CACHE_KEY] || {};
   cacheStore.local[BASE_LOCAL_CACHE_KEY][key] = value;
   if (immediate) {
-    const localCache = cacheStore.local;
-    ls.set(BASE_LOCAL_CACHE_KEY, localCache);
+    ls.set(BASE_LOCAL_CACHE_KEY, cacheStore.local);
   }
 }
 
@@ -43,6 +43,7 @@ export function getLocal<T>(key: string): T | null {
     return null;
   }
 }
+
 export function removeLocal(key: string) {
   if (cacheStore.local[BASE_LOCAL_CACHE_KEY]) {
     Reflect.deleteProperty(cacheStore.local[BASE_LOCAL_CACHE_KEY], key);
@@ -91,8 +92,6 @@ export function clearAll() {
     const localCache = cacheStore.local;
     const sessionCache = cacheStore.session;
 
-    // const ss = createStorage();
-
     ls.set(BASE_LOCAL_CACHE_KEY, localCache);
     ss.set(BASE_SESSION_CACHE_KEY, sessionCache);
   });
@@ -114,6 +113,7 @@ export function clearAll() {
       }
     }
   }
+
   if (isIeFn() && (document as any).attachEvent) {
     (document as any).attachEvent('onstorage', storageChange);
   } else {

+ 1 - 0
src/utils/helper/treeHelper.ts

@@ -158,6 +158,7 @@ export function forEach<T = any>(
 export function treeMap(treeData: any[], opt: { children?: string; conversion: Fn }) {
   return treeData.map((item) => treeMapEach(item, opt));
 }
+
 /**
  * @description: 提取tree指定结构
  */

+ 4 - 4
yarn.lock

@@ -6343,10 +6343,10 @@ prettier-linter-helpers@^1.0.0:
   dependencies:
     fast-diff "^1.1.2"
 
-prettier@^2.1.2:
-  version "2.1.2"
-  resolved "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
-  integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
+prettier@^2.2.0:
+  version "2.2.0"
+  resolved "https://registry.npmjs.org/prettier/-/prettier-2.2.0.tgz#8a03c7777883b29b37fb2c4348c66a78e980418b"
+  integrity sha512-yYerpkvseM4iKD/BXLYUkQV5aKt4tQPqaGW6EsZjzyu0r7sVZZNPJW4Y8MyKmicp6t42XUPcBVA+H6sB3gqndw==
 
 pretty-bytes@^5.3.0:
   version "5.4.1"