提交 fcee7d4e 作者: Vben

perf: move src/types to root

上级 a84586e2
......@@ -10,6 +10,7 @@
- 修复 github 仓库体积过大问题.
- 默认隐藏表格全屏按钮
- `crypto-es`改为`crypto-js`,减小打包体积
- `types`目录移动到根目录,兼容其他目录全局类型
### 🐛 Bug Fixes
......
......@@ -36,7 +36,7 @@
import CollapseHeader from './CollapseHeader.vue';
import LazyContainer from '../LazyContainer.vue';
import { triggerWindowResize } from '/@/utils/event/triggerWindowResizeEvent';
import { triggerWindowResize } from '/@/utils/event';
// hook
import { useTimeoutFn } from '/@/hooks/core/useTimeout';
import { propTypes } from '/@/utils/propTypes';
......
......@@ -7,7 +7,7 @@ import { getDynamicProps } from '/@/utils';
import type { FormProps, FormActionType, UseFormReturnType, FormSchema } from '../types/form';
import type { NamePath } from 'ant-design-vue/lib/form/interface';
import type { DynamicProps } from '/@/types/utils';
import type { DynamicProps } from '/#/utils';
export declare type ValidateFields = (nameList?: NamePath[]) => Promise<Recordable>;
......
......@@ -17,7 +17,7 @@
</div>
</template>
<script lang="ts">
import { addResizeListener, removeResizeListener } from '/@/utils/event/resizeEvent';
import { addResizeListener, removeResizeListener } from '/@/utils/event';
import componentSetting from '/@/settings/componentSetting';
const { scrollbar } = componentSetting;
import { toObject } from './util';
......
import type { BasicTableProps, TableActionType, FetchParams, BasicColumn } from '../types/table';
import type { PaginationProps } from '../types/pagination';
import type { DynamicProps } from '/@/types/utils';
import type { DynamicProps } from '/#/utils';
import { getDynamicProps } from '/@/utils';
import { ref, onUnmounted, unref, watch, toRaw } from 'vue';
......
......@@ -26,7 +26,7 @@
import plugins from './plugins';
import { getTinymce } from './getTinymce';
import { useScript } from '/@/hooks/web/useScript';
import { shortUuid } from '/@/utils/uuid';
import { buildShortUUID } from '/@/utils/uuid';
import { bindHandlers } from './helper';
import lineHeight from './lineHeight';
import { onMountedOrActivated } from '/@/hooks/core/onMountedOrActivated';
......@@ -45,7 +45,7 @@
emits: ['change', 'update:modelValue'],
setup(props, { emit, attrs }) {
const editorRef = ref<any>(null);
const tinymceId = ref<string>(shortUuid('tiny-vue'));
const tinymceId = ref<string>(buildShortUUID('tiny-vue'));
const elRef = ref<Nullable<HTMLElement>>(null);
const { prefixCls } = useDesign('tinymce-container');
......@@ -104,7 +104,7 @@
}
);
onMountedOrActivated(() => {
tinymceId.value = shortUuid('tiny-vue');
tinymceId.value = buildShortUUID('tiny-vue');
nextTick(() => {
init();
});
......
import { useDebounce } from '/@/hooks/core/useDebounce';
import { addResizeListener, removeResizeListener } from '/@/utils/event/resizeEvent';
import { addResizeListener, removeResizeListener } from '/@/utils/event';
interface WindowSizeOptions {
once?: boolean;
......
import type { ProjectConfig, GlobConfig, GlobEnvConfig } from '/@/types/config';
import type { ProjectConfig, GlobConfig, GlobEnvConfig } from '/#/config';
import { getConfigFileName } from '../../../build/getConfigFileName';
......
import type { HeaderSetting } from '/@/types/config';
import type { HeaderSetting } from '/#/config';
import { computed, unref } from 'vue';
......
import type { LocaleSetting } from '/@/types/config';
import type { LocaleSetting } from '/#/config';
import { computed, unref } from 'vue';
import { appStore } from '/@/store/modules/app';
......
import type { MenuSetting } from '/@/types/config';
import type { MenuSetting } from '/#/config';
import { computed, unref, ref } from 'vue';
......
import type { MultiTabsSetting } from '/@/types/config';
import type { MultiTabsSetting } from '/#/config';
import { computed, unref } from 'vue';
......
import type { ProjectConfig } from '/@/types/config';
import type { ProjectConfig } from '/#/config';
import { computed, unref } from 'vue';
......
import type { TransitionSetting } from '/@/types/config';
import type { TransitionSetting } from '/#/config';
import { computed, unref } from 'vue';
......
......@@ -4,7 +4,7 @@ import { updateColorWeak } from '/@/logics/theme/updateColorWeak';
import { updateGrayMode } from '/@/logics/theme/updateGrayMode';
import { appStore } from '/@/store/modules/app';
import { ProjectConfig } from '/@/types/config';
import { ProjectConfig } from '/#/config';
import { changeTheme } from '/@/logics/theme';
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
......
......@@ -2,7 +2,7 @@
* Application configuration
*/
import type { ProjectConfig } from '/@/types/config';
import type { ProjectConfig } from '/#/config';
import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
......
import type { ProjectConfig } from '/@/types/config';
import type { ProjectConfig } from '/#/config';
import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum';
import { CacheTypeEnum } from '/@/enums/cacheEnum';
......
import type { ProjectConfig } from '/@/types/config';
import type { ProjectConfig } from '/#/config';
import { VuexModule, getModule, Module, Mutation, Action } from 'vuex-module-decorators';
import store from '/@/store';
......@@ -24,7 +24,7 @@ let timeId: TimeoutHandle;
const NAME = 'app';
hotModuleUnregisterModule(NAME);
@Module({ dynamic: true, namespaced: true, store, name: NAME })
class App extends VuexModule {
export default class App extends VuexModule {
// Page loading status
private pageLoadingState = false;
......
import type { lib } from 'crypto-js';
import { encrypt, decrypt } from 'crypto-js/aes';
import Uft8, { parse } from 'crypto-js/enc-utf8';
import pkcs7 from 'crypto-js/pad-pkcs7';
export interface EncryptionParams {
key: string;
iv: string;
}
export class Encryption {
private key: lib.WordArray;
private iv: lib.WordArray;
constructor(opt: EncryptionParams) {
const { key, iv } = opt;
this.key = parse(key);
this.iv = parse(iv);
}
get getOptions() {
return {
// mode: mode.CBC,
padding: pkcs7,
iv: this.iv,
};
}
encryptByAES(str: string) {
return encrypt(str, this.key, this.getOptions).toString();
}
decryptByAES(str: string) {
return decrypt(str, this.key, this.getOptions).toString(Uft8);
}
}
export default Encryption;
import { cacheCipher } from '/@/settings/encryptionSetting';
import Encryption, { EncryptionParams } from './aesEncryption';
import type { EncryptionParams } from '/@/utils/cipher';
import { AesEncryption } from '/@/utils/cipher';
export interface CreateStorageParams extends EncryptionParams {
prefixKey: string;
......@@ -20,7 +22,7 @@ export const createStorage = ({
throw new Error('When hasEncrypt is true, the key or iv must be 16 bits!');
}
const encryption = new Encryption({ key, iv });
const encryption = new AesEncryption({ key, iv });
/**
*Cache class
......@@ -31,7 +33,7 @@ export const createStorage = ({
const WebStorage = class WebStorage {
private storage: Storage;
private prefixKey?: string;
private encryption: Encryption;
private encryption: AesEncryption;
private hasEncrypt: boolean;
/**
*
......
import { encrypt, decrypt } from 'crypto-js/aes';
import { parse } from 'crypto-js/enc-utf8';
import pkcs7 from 'crypto-js/pad-pkcs7';
import ECB from 'crypto-js/mode-ecb';
import md5 from 'crypto-js/md5';
import UTF8 from 'crypto-js/enc-utf8';
import Base64 from 'crypto-js/enc-base64';
export interface EncryptionParams {
key: string;
iv: string;
}
export class AesEncryption {
private key;
private iv;
constructor(opt: Partial<EncryptionParams> = {}) {
const { key, iv } = opt;
if (key) {
this.key = parse(key);
}
if (iv) {
this.iv = parse(iv);
}
}
get getOptions() {
return {
mode: ECB,
padding: pkcs7,
iv: this.iv,
};
}
encryptByAES(cipherText: string) {
return encrypt(cipherText, this.key, this.getOptions).toString();
}
decryptByAES(cipherText: string) {
return decrypt(cipherText, this.key, this.getOptions).toString(UTF8);
}
}
export function encryptByBase64(cipherText: string) {
return Base64.parse(cipherText).toString(UTF8);
}
export function decodeByBase64(cipherText: string) {
return Base64.parse(cipherText).toString(UTF8);
}
export function encryptByMd5(password: string) {
return md5(password).toString();
}
import type { GlobEnvConfig } from '/@/types/config';
import type { GlobEnvConfig } from '/#/config';
import { useGlobSetting } from '/@/hooks/setting';
import pkg from '../../package.json';
......
......@@ -33,3 +33,10 @@ export function removeResizeListener(element: any, fn: () => any) {
element.__ro__.disconnect();
}
}
export function triggerWindowResize() {
const event = document.createEvent('HTMLEvents');
event.initEvent('resize', true, true);
(event as any).eventType = 'message';
window.dispatchEvent(event);
}
/**
* triggter window.resize
*/
export function triggerWindowResize() {
const event = document.createEvent('HTMLEvents');
event.initEvent('resize', true, true);
(event as any).eventType = 'message';
window.dispatchEvent(event);
}
......@@ -20,7 +20,7 @@ export function buildUUID(): string {
}
let unique = 0;
export function shortUuid(prefix = ''): string {
export function buildShortUUID(prefix = ''): string {
const time = Date.now();
const random = Math.floor(Math.random() * 1000000000);
unique++;
......
......@@ -18,13 +18,23 @@
"experimentalDecorators": true,
"lib": ["dom", "esnext"],
"types": ["vite/client"],
"typeRoots": ["./node_modules/@types/", "./types"],
"incremental": true,
"noImplicitAny": false,
"skipLibCheck": true,
"paths": {
"/@/*": ["src/*"]
"/@/*": ["src/*"],
"/#/*": ["types/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"types/**/*.d.ts",
"types/**/*.ts",
"mock/**/*.ts"
],
"exclude": ["node_modules", "dist", "**/*.js"]
}
......@@ -35,6 +35,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
find: /^\/@\//,
replacement: pathResolve('src') + '/',
},
{
// /@/xxxx => src/xxx
find: /^\/#\//,
replacement: pathResolve('types') + '/',
},
],
},
server: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论