vben
2021-02-22 be3a3ed699f73d352d49623ef07288093a3332c4
perf: remove useless code
8个文件已删除
15个文件已修改
567 ■■■■■ 已修改文件
.env.production 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/App.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Form/src/hooks/useFormEvents.ts 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Menu/src/useOpenKeys.ts 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/SimpleMenu/src/useOpenKeys.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/VirtualScroll/src/index.tsx 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/registerGlobComp.ts 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/types.ts 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/util.tsx 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/hooks/core/useDebouncedRef.ts 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/hooks/core/useEffect.ts 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/hooks/core/useState.ts 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layouts/iframe/index.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layouts/iframe/useFrameKeepAlive.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/guard/permissionGuard.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/types.ts 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/types/shims-volar.d.ts 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/auth/index.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/cache/cookie.ts 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/domUtils.ts 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/encryption/aesEncryption.ts 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/http/axios/index.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/index.ts 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.env.production
@@ -7,7 +7,7 @@
# Delete console
VITE_DROP_CONSOLE = true
# Whether to enable gizp or brotli compression
# Whether to enable gzip or brotli compression
# Optional: gzip | brotli | none
# If you need multiple forms, you can use `,` to separate
VITE_BUILD_COMPRESS = 'none'
src/App.vue
@@ -22,10 +22,12 @@
    setup() {
      // support Multi-language
      const { antConfigLocale, setLocale } = useLocale();
      setLocale();
      // Initialize vuex internal system configuration
      initAppConfigStore();
      // Create a lock screen monitor
      const lockEvent = useLockPage();
src/components/Form/src/hooks/useFormEvents.ts
@@ -5,10 +5,10 @@
import { unref, toRaw } from 'vue';
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
import { deepMerge, unique } from '/@/utils';
import { deepMerge } from '/@/utils';
import { dateItemType, handleInputNumberValue } from '../helper';
import { dateUtil } from '/@/utils/dateUtil';
import { cloneDeep } from 'lodash-es';
import { cloneDeep, uniqBy } from 'lodash-es';
import { error } from '/@/utils/log';
interface UseFormActionContext {
@@ -160,7 +160,7 @@
        }
      });
    });
    schemaRef.value = unique(schema, 'field');
    schemaRef.value = uniqBy(schema, 'field');
  }
  function getFieldsValue(): Recordable {
src/components/Menu/src/useOpenKeys.ts
@@ -5,7 +5,7 @@
import { computed, Ref, toRaw } from 'vue';
import { unref } from 'vue';
import { es6Unique } from '/@/utils';
import { uniq } from 'lodash-es';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { getAllParentPath } from '/@/router/helper/menuHelper';
import { useTimeoutFn } from '/@/hooks/core/useTimeout';
@@ -31,10 +31,7 @@
          return;
        }
        if (!unref(accordion)) {
          menuState.openKeys = es6Unique([
            ...menuState.openKeys,
            ...getAllParentPath(menuList, path),
          ]);
          menuState.openKeys = uniq([...menuState.openKeys, ...getAllParentPath(menuList, path)]);
        } else {
          menuState.openKeys = getAllParentPath(menuList, path);
        }
src/components/SimpleMenu/src/useOpenKeys.ts
@@ -4,8 +4,9 @@
import { computed, Ref, toRaw } from 'vue';
import { unref } from 'vue';
import { es6Unique } from '/@/utils';
import { uniq } from 'lodash-es';
import { getAllParentPath } from '/@/router/helper/menuHelper';
import { useTimeoutFn } from '/@/hooks/core/useTimeout';
export function useOpenKeys(
@@ -31,7 +32,7 @@
        }
        const keys = getAllParentPath(menuList, path);
        if (!unref(accordion)) {
          menuState.openNames = es6Unique([...menuState.openNames, ...keys]);
          menuState.openNames = uniq([...menuState.openNames, ...keys]);
        } else {
          menuState.openNames = keys;
        }
src/components/VirtualScroll/src/index.tsx
@@ -11,12 +11,22 @@
} from 'vue';
import { useEventListener } from '/@/hooks/event/useEventListener';
import { convertToUnit } from '/@/components/util';
import { props as basicProps } from './props';
import { getSlot } from '/@/utils/helper/tsxHelper';
import './index.less';
const prefixCls = 'virtual-scroll';
function convertToUnit(str: string | number | null | undefined, unit = 'px'): string | undefined {
  if (str == null || str === '') {
    return undefined;
  } else if (isNaN(+str!)) {
    return String(str);
  } else {
    return `${Number(str)}${unit}`;
  }
}
export default defineComponent({
  name: 'VirtualScroll',
  props: basicProps,
src/components/registerGlobComp.ts
@@ -3,42 +3,6 @@
import {
  // Need
  Button as AntButton,
  // Optional
  // Select,
  // Alert,
  // Checkbox,
  // DatePicker,
  // Radio,
  // Switch,
  // Card,
  // List,
  // Tabs,
  // Descriptions,
  // Tree,
  // Table,
  // Divider,
  // Modal,
  // Drawer,
  // Dropdown,
  // Tag,
  // Tooltip,
  // Badge,
  // Popover,
  // Upload,
  // Transfer,
  // Steps,
  // PageHeader,
  // Result,
  // Empty,
  // Avatar,
  // Menu,
  // Breadcrumb,
  // Form,
  // Input,
  // Row,
  // Col,
  // Spin,
} from 'ant-design-vue';
import { App } from 'vue';
@@ -47,45 +11,6 @@
export function registerGlobComp(app: App) {
  compList.forEach((comp: any) => {
    app.component(comp.name, comp);
    app.component(comp.name || comp.displayName, comp);
  });
  // Optional
  // If you need to customize global components, you can write here
  // If you don’t need it, you can delete it
  // app
  //   .use(Select)
  //   .use(Alert)
  //   .use(Breadcrumb)
  //   .use(Checkbox)
  //   .use(DatePicker)
  //   .use(Radio)
  //   .use(Switch)
  //   .use(Card)
  //   .use(List)
  //   .use(Descriptions)
  //   .use(Tree)
  //   .use(Table)
  //   .use(Divider)
  //   .use(Modal)
  //   .use(Drawer)
  //   .use(Dropdown)
  //   .use(Tag)
  //   .use(Tooltip)
  //   .use(Badge)
  //   .use(Popover)
  //   .use(Upload)
  //   .use(Transfer)
  //   .use(Steps)
  //   .use(PageHeader)
  //   .use(Result)
  //   .use(Empty)
  //   .use(Avatar)
  //   .use(Menu)
  //   .use(Tabs)
  //   .use(Form)
  //   .use(Input)
  //   .use(Row)
  //   .use(Col)
  //   .use(Spin);
}
src/components/types.ts
File was deleted
src/components/util.tsx
File was deleted
src/hooks/core/useDebouncedRef.ts
File was deleted
src/hooks/core/useEffect.ts
File was deleted
src/hooks/core/useState.ts
File was deleted
src/layouts/iframe/index.vue
@@ -21,9 +21,7 @@
    setup() {
      const { getFramePages, hasRenderFrame, showIframe } = useFrameKeepAlive();
      const showFrame = computed(() => {
        return unref(getFramePages).length > 0;
      });
      const showFrame = computed(() => unref(getFramePages).length > 0);
      return { getFramePages, hasRenderFrame, showIframe, showFrame };
    },
src/layouts/iframe/useFrameKeepAlive.ts
@@ -4,7 +4,7 @@
import { tabStore } from '/@/store/modules/tab';
import { unique } from '/@/utils';
import { uniqBy } from 'lodash-es';
import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
@@ -40,7 +40,7 @@
        res.push(...getAllFramePages(children));
      }
    }
    res = unique(res, 'name');
    res = uniqBy(res, 'name');
    return res;
  }
src/router/guard/permissionGuard.ts
@@ -3,7 +3,7 @@
import { permissionStore } from '/@/store/modules/permission';
import { PageEnum } from '/@/enums/pageEnum';
import { getToken } from '/@/utils/auth';
import { userStore } from '/@/store/modules/user';
import { PAGE_NOT_FOUND_ROUTE } from '/@/router/constant';
@@ -25,7 +25,7 @@
      return;
    }
    const token = getToken();
    const token = userStore.getTokenState;
    // token does not exist
    if (!token) {
src/router/types.ts
@@ -1,7 +1,12 @@
import type { RouteRecordRaw } from 'vue-router';
import { RoleEnum } from '/@/enums/roleEnum';
import type { Component } from '/@/components/types';
import { defineComponent } from 'vue';
export type Component<T extends any = any> =
  | ReturnType<typeof defineComponent>
  | (() => Promise<typeof import('*.vue')>)
  | (() => Promise<T>);
export interface RouteMeta {
  // title
src/types/shims-volar.d.ts
File was deleted
src/utils/auth/index.ts
File was deleted
src/utils/cache/cookie.ts
File was deleted
src/utils/domUtils.ts
@@ -73,13 +73,13 @@
  }
}
/**
 * 获取当前元素的left、top偏移
 *   left:元素最左侧距离文档左侧的距离
 *   top:元素最顶端距离文档顶端的距离
 *   right:元素最右侧距离文档右侧的距离
 *   bottom:元素最底端距离文档底端的距离
 *   rightIncludeBody:元素最左侧距离文档右侧的距离
 *   bottomIncludeBody:元素最底端距离文档最底部的距离
 * Get the left and top offset of the current element
 * left: the distance between the leftmost element and the left side of the document
 * top: the distance from the top of the element to the top of the document
 * right: the distance from the far right of the element to the right of the document
 * bottom: the distance from the bottom of the element to the bottom of the document
 * rightIncludeBody: the distance between the leftmost element and the right side of the document
 * bottomIncludeBody: the distance from the bottom of the element to the bottom of the document
 *
 * @description:
 */
src/utils/encryption/aesEncryption.ts
@@ -14,7 +14,7 @@
    this.iv = CryptoES.enc.Utf8.parse(iv);
  }
  get getOpt(): CryptoES.lib.CipherCfg {
  get getOptions(): CryptoES.lib.CipherCfg {
    return {
      mode: CryptoES.mode.CBC as any,
      padding: CryptoES.pad.Pkcs7,
@@ -23,13 +23,11 @@
  }
  encryptByAES(str: string) {
    const encrypted = CryptoES.AES.encrypt(str, this.key, this.getOpt);
    return encrypted.toString();
    return CryptoES.AES.encrypt(str, this.key, this.getOptions).toString();
  }
  decryptByAES(str: string) {
    const decrypted = CryptoES.AES.decrypt(str, this.key, this.getOpt);
    return decrypted.toString(CryptoES.enc.Utf8);
    return CryptoES.AES.decrypt(str, this.key, this.getOptions).toString(CryptoES.enc.Utf8);
  }
}
export default Encryption;
src/utils/http/axios/index.ts
@@ -4,7 +4,6 @@
import type { AxiosResponse } from 'axios';
import type { CreateAxiosOptions, RequestOptions, Result } from './types';
import { VAxios } from './Axios';
import { getToken } from '/@/utils/auth';
import { AxiosTransform } from './axiosTransform';
import { checkStatus } from './checkStatus';
@@ -20,6 +19,7 @@
import { errorResult } from './const';
import { useI18n } from '/@/hooks/web/useI18n';
import { createNow, formatRequestDate } from './helper';
import { userStore } from '/@/store/modules/user';
const globSetting = useGlobSetting();
const prefix = globSetting.urlPrefix;
@@ -137,7 +137,7 @@
   */
  requestInterceptors: (config) => {
    // 请求之前处理config
    const token = getToken();
    const token = userStore.getTokenState;
    if (token) {
      // jwt token
      config.headers.Authorization = token;
src/utils/index.ts
@@ -38,24 +38,6 @@
  return src;
}
/**
 * @description: Deduplication according to the value of an object in the array
 */
export function unique<T = any>(arr: T[], key: string): T[] {
  const map = new Map();
  return arr.filter((item) => {
    const _item = item as any;
    return !map.has(_item[key]) && map.set(_item[key], 1);
  });
}
/**
 * @description: es6 array to repeat
 */
export function es6Unique<T>(arr: T[]): T[] {
  return Array.from(new Set(arr));
}
export function openWindow(
  url: string,
  opt?: { target?: TargetContext | string; noopener?: boolean; noreferrer?: boolean }
@@ -78,20 +60,6 @@
  });
  return ret as Partial<U>;
}
export function getLastItem<T extends any>(list: T) {
  if (Array.isArray(list)) {
    return list.slice(-1)[0];
  }
  if (list instanceof Set) {
    return Array.from(list).slice(-1)[0];
  }
  if (list instanceof Map) {
    return Array.from(list.values()).slice(-1)[0];
  }
}
/**