提交 8a9ca498 作者: Vben

chore: remove useless code

上级 5ffac409
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Get the configuration file variable name * Get the configuration file variable name
* @param env * @param env
*/ */
export const getShortName = (env: any) => { export const getConfigFileName = (env: Record<string, any>) => {
return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__` return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`
.toUpperCase() .toUpperCase()
.replace(/\s/g, ''); .replace(/\s/g, '');
......
...@@ -5,8 +5,8 @@ import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant'; ...@@ -5,8 +5,8 @@ import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant';
import fs, { writeFileSync } from 'fs-extra'; import fs, { writeFileSync } from 'fs-extra';
import chalk from 'chalk'; import chalk from 'chalk';
import { getCwdPath, getEnvConfig } from '../utils'; import { getRootPath, getEnvConfig } from '../utils';
import { getShortName } from '../getShortName'; import { getConfigFileName } from '../getConfigFileName';
import pkg from '../../package.json'; import pkg from '../../package.json';
...@@ -27,8 +27,8 @@ function createConfig( ...@@ -27,8 +27,8 @@ function createConfig(
writable: false, writable: false,
}); });
`.replace(/\s/g, ''); `.replace(/\s/g, '');
fs.mkdirp(getCwdPath(OUTPUT_DIR)); fs.mkdirp(getRootPath(OUTPUT_DIR));
writeFileSync(getCwdPath(`${OUTPUT_DIR}/${configFileName}`), configStr); writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr);
console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`); console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
console.log(chalk.gray(OUTPUT_DIR + '/' + chalk.green(configFileName)) + '\n'); console.log(chalk.gray(OUTPUT_DIR + '/' + chalk.green(configFileName)) + '\n');
...@@ -39,6 +39,6 @@ function createConfig( ...@@ -39,6 +39,6 @@ function createConfig(
export function runBuildConfig() { export function runBuildConfig() {
const config = getEnvConfig(); const config = getEnvConfig();
const configFileName = getShortName(config); const configFileName = getConfigFileName(config);
createConfig({ config, configName: configFileName }); createConfig({ config, configName: configFileName });
} }
...@@ -14,6 +14,7 @@ export const runBuild = async () => { ...@@ -14,6 +14,7 @@ export const runBuild = async () => {
if (!argvList.includes('no-conf')) { if (!argvList.includes('no-conf')) {
await runBuildConfig(); await runBuildConfig();
} }
console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!'); console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
} catch (error) { } catch (error) {
console.log(chalk.red('vite build error:\n' + error)); console.log(chalk.red('vite build error:\n' + error));
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
"moduleResolution": "node", "moduleResolution": "node",
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"jsx": "react",
"baseUrl": ".", "baseUrl": ".",
"esModuleInterop": true, "esModuleInterop": true,
"noUnusedLocals": true, "noUnusedLocals": true,
......
...@@ -2,3 +2,5 @@ declare module '*.json' { ...@@ -2,3 +2,5 @@ declare module '*.json' {
const src: any; const src: any;
export default src; export default src;
} }
declare type Recordable = Record<string, any>;
...@@ -2,12 +2,6 @@ import fs from 'fs'; ...@@ -2,12 +2,6 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
export const isFunction = (arg: unknown): arg is (...args: any[]) => any =>
typeof arg === 'function';
export const isRegExp = (arg: unknown): arg is RegExp =>
Object.prototype.toString.call(arg) === '[object RegExp]';
export function isDevFn(mode: string): boolean { export function isDevFn(mode: string): boolean {
return mode === 'development'; return mode === 'development';
} }
...@@ -34,18 +28,18 @@ export interface ViteEnv { ...@@ -34,18 +28,18 @@ export interface ViteEnv {
VITE_USE_CDN: boolean; VITE_USE_CDN: boolean;
VITE_DROP_CONSOLE: boolean; VITE_DROP_CONSOLE: boolean;
VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none'; VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
VITE_DYNAMIC_IMPORT: boolean;
VITE_LEGACY: boolean; VITE_LEGACY: boolean;
VITE_USE_IMAGEMIN: boolean; VITE_USE_IMAGEMIN: boolean;
} }
// Read all environment variable configuration files to process.env // Read all environment variable configuration files to process.env
export function wrapperEnv(envConf: any): ViteEnv { export function wrapperEnv(envConf: Recordable): ViteEnv {
const ret: any = {}; const ret: any = {};
for (const envName of Object.keys(envConf)) { for (const envName of Object.keys(envConf)) {
let realName = envConf[envName].replace(/\\n/g, '\n'); let realName = envConf[envName].replace(/\\n/g, '\n');
realName = realName === 'true' ? true : realName === 'false' ? false : realName; realName = realName === 'true' ? true : realName === 'false' ? false : realName;
if (envName === 'VITE_PORT') { if (envName === 'VITE_PORT') {
realName = Number(realName); realName = Number(realName);
} }
...@@ -70,10 +64,10 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = ['.env', '.env.pr ...@@ -70,10 +64,10 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = ['.env', '.env.pr
confFiles.forEach((item) => { confFiles.forEach((item) => {
try { try {
const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item))); const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)));
envConfig = { ...envConfig, ...env }; envConfig = { ...envConfig, ...env };
} catch (error) {} } catch (error) {}
}); });
Object.keys(envConfig).forEach((key) => { Object.keys(envConfig).forEach((key) => {
const reg = new RegExp(`^(${match})`); const reg = new RegExp(`^(${match})`);
if (!reg.test(key)) { if (!reg.test(key)) {
...@@ -87,6 +81,6 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = ['.env', '.env.pr ...@@ -87,6 +81,6 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = ['.env', '.env.pr
* Get user root directory * Get user root directory
* @param dir file path * @param dir file path
*/ */
export function getCwdPath(...dir: string[]) { export function getRootPath(...dir: string[]) {
return path.resolve(process.cwd(), ...dir); return path.resolve(process.cwd(), ...dir);
} }
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import type { ViteEnv } from '../../utils';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx'; import vueJsx from '@vitejs/plugin-vue-jsx';
...@@ -6,7 +7,6 @@ import legacy from '@vitejs/plugin-legacy'; ...@@ -6,7 +7,6 @@ import legacy from '@vitejs/plugin-legacy';
import PurgeIcons from 'vite-plugin-purge-icons'; import PurgeIcons from 'vite-plugin-purge-icons';
import { ViteEnv } from '../../utils';
import { configHtmlPlugin } from './html'; import { configHtmlPlugin } from './html';
import { configPwaConfig } from './pwa'; import { configPwaConfig } from './pwa';
import { configMockPlugin } from './mock'; import { configMockPlugin } from './mock';
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
* Zero-config PWA for Vite * Zero-config PWA for Vite
* https://github.com/antfu/vite-plugin-pwa * https://github.com/antfu/vite-plugin-pwa
*/ */
import type { ViteEnv } from '../../utils';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
import { ViteEnv } from '../../utils';
export function configPwaConfig(env: ViteEnv) { export function configPwaConfig(env: ViteEnv) {
const { VITE_USE_PWA, VITE_GLOB_APP_TITLE, VITE_GLOB_APP_SHORT_NAME } = env; const { VITE_USE_PWA, VITE_GLOB_APP_TITLE, VITE_GLOB_APP_SHORT_NAME } = env;
......
import windiCSS from 'vite-plugin-windicss';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import windiCSS from 'vite-plugin-windicss';
export function configWindiCssPlugin(): Plugin[] { export function configWindiCssPlugin(): Plugin[] {
return windiCSS({ return windiCSS({
safelist: 'no-select', safelist: 'no-select',
......
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'; import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
// @ts-ignore
const modules = import.meta.globEager('./**/*.ts'); const modules = import.meta.globEager('./**/*.ts');
const mockModules: any[] = []; const mockModules: any[] = [];
......
...@@ -18,13 +18,11 @@ export function resultPageSuccess<T = any>( ...@@ -18,13 +18,11 @@ export function resultPageSuccess<T = any>(
const pageData = pagination(page, pageSize, list); const pageData = pagination(page, pageSize, list);
return { return {
code: 0, ...resultSuccess({
result: {
items: pageData, items: pageData,
total: list.length, total: list.length,
}, }),
message, message,
type: 'success',
}; };
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"name": "vben-admin", "name": "vben-admin",
"version": "2.0.1", "version": "2.0.1",
"scripts": { "scripts": {
"bootstrap": "yarn install",
"serve": "vite", "serve": "vite",
"dev": "vite", "dev": "vite",
"build": "vite build && esno ./build/script/postBuild.ts", "build": "vite build && esno ./build/script/postBuild.ts",
...@@ -9,9 +10,9 @@ ...@@ -9,9 +10,9 @@
"report": "cross-env REPORT=true npm run build ", "report": "cross-env REPORT=true npm run build ",
"preview": "npm run build && vite preview", "preview": "npm run build && vite preview",
"preview:dist": "vite preview", "preview:dist": "vite preview",
"log": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "log": "conventional-changelog -p angular -i CHANGELOG.md -s",
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite", "clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
"clean:lib": "npx rimraf node_modules", "clean:lib": "rimraf node_modules",
"lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix", "lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", "lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", "lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
...@@ -39,8 +40,8 @@ ...@@ -39,8 +40,8 @@
"qrcode": "^1.4.4", "qrcode": "^1.4.4",
"sortablejs": "^1.13.0", "sortablejs": "^1.13.0",
"vditor": "^3.8.1", "vditor": "^3.8.1",
"vue": "^3.0.6", "vue": "3.0.5",
"vue-i18n": "9.0.0-rc.7", "vue-i18n": "9.0.0-rc.8",
"vue-router": "^4.0.4", "vue-router": "^4.0.4",
"vue-types": "^3.0.2", "vue-types": "^3.0.2",
"vuex": "^4.0.0", "vuex": "^4.0.0",
...@@ -50,7 +51,7 @@ ...@@ -50,7 +51,7 @@
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^12.0.0", "@commitlint/cli": "^12.0.0",
"@commitlint/config-conventional": "^12.0.0", "@commitlint/config-conventional": "^12.0.0",
"@iconify/json": "^1.1.307", "@iconify/json": "^1.1.308",
"@ls-lint/ls-lint": "^1.9.2", "@ls-lint/ls-lint": "^1.9.2",
"@purge-icons/generated": "^0.7.0", "@purge-icons/generated": "^0.7.0",
"@types/fs-extra": "^9.0.7", "@types/fs-extra": "^9.0.7",
...@@ -68,7 +69,7 @@ ...@@ -68,7 +69,7 @@
"@vitejs/plugin-legacy": "^1.3.1", "@vitejs/plugin-legacy": "^1.3.1",
"@vitejs/plugin-vue": "^1.1.4", "@vitejs/plugin-vue": "^1.1.4",
"@vitejs/plugin-vue-jsx": "^1.1.2", "@vitejs/plugin-vue-jsx": "^1.1.2",
"@vue/compiler-sfc": "^3.0.6", "@vue/compiler-sfc": "3.0.5",
"autoprefixer": "^10.2.4", "autoprefixer": "^10.2.4",
"commitizen": "^4.2.3", "commitizen": "^4.2.3",
"conventional-changelog-cli": "^2.1.1", "conventional-changelog-cli": "^2.1.1",
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
import plugins from './plugins'; import plugins from './plugins';
import { getTinymce } from './getTinymce'; import { getTinymce } from './getTinymce';
import { useScript } from '/@/hooks/web/useScript'; import { useScript } from '/@/hooks/web/useScript';
import { snowUuid } from '/@/utils/uuid'; import { shortUuid } from '/@/utils/uuid';
import { bindHandlers } from './helper'; import { bindHandlers } from './helper';
import lineHeight from './lineHeight'; import lineHeight from './lineHeight';
import { onMountedOrActivated } from '/@/hooks/core/onMountedOrActivated'; import { onMountedOrActivated } from '/@/hooks/core/onMountedOrActivated';
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
emits: ['change', 'update:modelValue'], emits: ['change', 'update:modelValue'],
setup(props, { emit, attrs }) { setup(props, { emit, attrs }) {
const editorRef = ref<any>(null); const editorRef = ref<any>(null);
const tinymceId = ref<string>(snowUuid('tiny-vue')); const tinymceId = ref<string>(shortUuid('tiny-vue'));
const elRef = ref<Nullable<HTMLElement>>(null); const elRef = ref<Nullable<HTMLElement>>(null);
const { prefixCls } = useDesign('tinymce-container'); const { prefixCls } = useDesign('tinymce-container');
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
} }
); );
onMountedOrActivated(() => { onMountedOrActivated(() => {
tinymceId.value = snowUuid('tiny-vue'); tinymceId.value = shortUuid('tiny-vue');
nextTick(() => { nextTick(() => {
init(); init();
}); });
......
import type { ProjectConfig, GlobConfig, GlobEnvConfig } from '/@/types/config'; import type { ProjectConfig, GlobConfig, GlobEnvConfig } from '/@/types/config';
import { getConfigFileName } from '../../../build/getConfigFileName';
import getProjectSetting from '/@/settings/projectSetting'; import getProjectSetting from '/@/settings/projectSetting';
import { getShortName } from '../../../build/getShortName';
import { warn } from '/@/utils/log'; import { warn } from '/@/utils/log';
import { getGlobEnvConfig, isDevMode } from '/@/utils/env'; import { getGlobEnvConfig, isDevMode } from '/@/utils/env';
const reg = /[a-zA-Z\_]*/;
const ENV_NAME = getShortName(import.meta.env);
const ENV = ((isDevMode()
? getGlobEnvConfig()
: window[ENV_NAME as any]) as unknown) as GlobEnvConfig;
const {
VITE_GLOB_APP_TITLE,
VITE_GLOB_API_URL,
VITE_GLOB_APP_SHORT_NAME,
VITE_GLOB_API_URL_PREFIX,
VITE_GLOB_UPLOAD_URL,
} = ENV;
if (!reg.test(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 useGlobSetting = (): Readonly<GlobConfig> => { export const useGlobSetting = (): Readonly<GlobConfig> => {
const ENV_NAME = getConfigFileName(import.meta.env);
const ENV = ((isDevMode()
? getGlobEnvConfig()
: window[ENV_NAME as any]) as unknown) as GlobEnvConfig;
const {
VITE_GLOB_APP_TITLE,
VITE_GLOB_API_URL,
VITE_GLOB_APP_SHORT_NAME,
VITE_GLOB_API_URL_PREFIX,
VITE_GLOB_UPLOAD_URL,
} = ENV;
if (!/[a-zA-Z\_]*/.test(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.`
);
}
// Take global configuration // Take global configuration
const glob: Readonly<GlobConfig> = { const glob: Readonly<GlobConfig> = {
title: VITE_GLOB_APP_TITLE, title: VITE_GLOB_APP_TITLE,
......
...@@ -2,8 +2,6 @@ import { useTimeoutFn } from '/@/hooks/core/useTimeout'; ...@@ -2,8 +2,6 @@ import { useTimeoutFn } from '/@/hooks/core/useTimeout';
import { tryOnUnmounted } from '/@/utils/helper/vueHelper'; import { tryOnUnmounted } from '/@/utils/helper/vueHelper';
import { unref, Ref, nextTick } from 'vue'; import { unref, Ref, nextTick } from 'vue';
import ApexCharts from 'apexcharts';
interface CallBackFn { interface CallBackFn {
(instance: Nullable<ApexCharts>): void; (instance: Nullable<ApexCharts>): void;
} }
...@@ -13,21 +11,22 @@ export function useApexCharts(elRef: Ref<HTMLDivElement>) { ...@@ -13,21 +11,22 @@ export function useApexCharts(elRef: Ref<HTMLDivElement>) {
function setOptions(options: any, callback?: CallBackFn) { function setOptions(options: any, callback?: CallBackFn) {
nextTick(() => { nextTick(() => {
useTimeoutFn(() => { useTimeoutFn(async () => {
const el = unref(elRef); const el = unref(elRef);
if (!el || !unref(el)) return; if (!el || !unref(el)) return;
const ApexCharts = await (await import('apexcharts')).default;
chartInstance = new ApexCharts(el, options); chartInstance = new ApexCharts(el, options);
chartInstance && chartInstance.render(); chartInstance && chartInstance.render();
// setOptions增加callback方法,返回chartInstance,以便于对图表进行再操作,例如调用updateOptions方法更新图表 // The callback method is added to setOptions to return the chartInstance to facilitate the re-operation of the chart, such as calling the updateOptions method to update the chart
callback && callback(chartInstance); callback && callback(chartInstance);
}, 30); }, 30);
}); });
} }
// 新增调用ApexCharts的updateOptions方法更新图表 // Call the updateOptions method of ApexCharts to update the chart
function updateOptions( function updateOptions(
chartInstance: Nullable<ApexCharts>, chartInstance: Nullable<ApexCharts>,
options: any, options: any,
......
...@@ -65,9 +65,3 @@ export function useLockPage() { ...@@ -65,9 +65,3 @@ export function useLockPage() {
} }
}); });
} }
export const getIsLock = computed(() => {
const { getLockInfo } = lockStore;
const { isLock } = getLockInfo;
return isLock;
});
...@@ -40,7 +40,7 @@ export function usePermission() { ...@@ -40,7 +40,7 @@ export function usePermission() {
resetRouter(); resetRouter();
const routes = await permissionStore.buildRoutesAction(id); const routes = await permissionStore.buildRoutesAction(id);
routes.forEach((route) => { routes.forEach((route) => {
router.addRoute(route as RouteRecordRaw); router.addRoute((route as unknown) as RouteRecordRaw);
}); });
permissionStore.commitLastBuildMenuTimeState(); permissionStore.commitLastBuildMenuTimeState();
const { closeAll } = useTabs(); const { closeAll } = useTabs();
......
import Sortable from 'sortablejs';
import { nextTick, unref } from 'vue'; import { nextTick, unref } from 'vue';
import type { Ref } from 'vue'; import type { Ref } from 'vue';
import type { Options } from 'sortablejs';
export function useSortable(el: HTMLElement | Ref<HTMLElement>, options?: Sortable.Options) { export function useSortable(el: HTMLElement | Ref<HTMLElement>, options?: Options) {
function initSortable() { function initSortable() {
nextTick(() => { nextTick(async () => {
if (!el) return; if (!el) return;
const Sortable = (await import('sortablejs')).default;
Sortable.create(unref(el), { Sortable.create(unref(el), {
animation: 500, animation: 500,
delay: 400, delay: 400,
......
...@@ -43,7 +43,7 @@ export function initAffixTabs(): string[] { ...@@ -43,7 +43,7 @@ export function initAffixTabs(): string[] {
addAffixTabs(); addAffixTabs();
isAddAffix = true; isAddAffix = true;
} }
return affixList.value.map((item) => item.meta?.title).filter(Boolean); return affixList.value.map((item) => item.meta?.title).filter(Boolean) as string[];
} }
export function useTabsDrag(affixTextList: string[]) { export function useTabsDrag(affixTextList: string[]) {
......
...@@ -7,7 +7,7 @@ import type { ProjectConfig } from '/@/types/config'; ...@@ -7,7 +7,7 @@ import type { ProjectConfig } from '/@/types/config';
import { PROJ_CFG_KEY } from '/@/enums/cacheEnum'; import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
import projectSetting from '/@/settings/projectSetting'; import projectSetting from '/@/settings/projectSetting';
import { getLocal } from '/@/utils/helper/persistent'; import { getLocal } from '/@/utils/cache/persistent';
import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground'; import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground';
import { updateColorWeak } from '/@/logics/theme/updateColorWeak'; import { updateColorWeak } from '/@/logics/theme/updateColorWeak';
import { updateGrayMode } from '/@/logics/theme/updateGrayMode'; import { updateGrayMode } from '/@/logics/theme/updateGrayMode';
......
...@@ -46,12 +46,6 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) { ...@@ -46,12 +46,6 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
const cloneRouteModList = cloneDeep(routeModList); const cloneRouteModList = cloneDeep(routeModList);
const routeList: AppRouteRecordRaw[] = []; const routeList: AppRouteRecordRaw[] = [];
// cloneRouteModList = filter(cloneRouteModList, (node) => {
// if (Reflect.has(node?.meta ?? {}, 'hideMenu')) {
// return !node?.meta.hideMenu;
// }
// return true;
// });
cloneRouteModList.forEach((item) => { cloneRouteModList.forEach((item) => {
if (item.meta?.single) { if (item.meta?.single) {
const realItem = item?.children?.[0]; const realItem = item?.children?.[0];
......
...@@ -3,9 +3,8 @@ import type { App } from 'vue'; ...@@ -3,9 +3,8 @@ import type { App } from 'vue';
import { createRouter, createWebHashHistory } from 'vue-router'; import { createRouter, createWebHashHistory } from 'vue-router';
import { createGuard } from './guard/'; import { createGuard } from './guard';
import { basicRoutes } from './routes';
import { basicRoutes } from './routes/';
import { REDIRECT_NAME } from './constant'; import { REDIRECT_NAME } from './constant';
// app router // app router
...@@ -33,8 +32,4 @@ export function setupRouter(app: App<Element>) { ...@@ -33,8 +32,4 @@ export function setupRouter(app: App<Element>) {
createGuard(router); createGuard(router);
} }
// router.onError((error) => {
// console.error(error);
// });
export default router; export default router;
...@@ -6,7 +6,7 @@ import store from '/@/store'; ...@@ -6,7 +6,7 @@ import store from '/@/store';
import { PROJ_CFG_KEY } from '/@/enums/cacheEnum'; import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper'; import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
import { setLocal, getLocal, clearSession, clearLocal } from '/@/utils/helper/persistent'; import { setLocal, getLocal, clearSession, clearLocal } from '/@/utils/cache/persistent';
import { deepMerge } from '/@/utils'; import { deepMerge } from '/@/utils';
import { resetRouter } from '/@/router'; import { resetRouter } from '/@/router';
......
...@@ -4,7 +4,7 @@ import store from '/@/store'; ...@@ -4,7 +4,7 @@ import store from '/@/store';
import { LOCK_INFO_KEY } from '/@/enums/cacheEnum'; import { LOCK_INFO_KEY } from '/@/enums/cacheEnum';
import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper'; import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
import { setLocal, getLocal, removeLocal } from '/@/utils/helper/persistent'; import { setLocal, getLocal, removeLocal } from '/@/utils/cache/persistent';
import { userStore } from './user'; import { userStore } from './user';
......
...@@ -18,7 +18,7 @@ import router from '/@/router'; ...@@ -18,7 +18,7 @@ import router from '/@/router';
import { loginApi, getUserInfoById } from '/@/api/sys/user'; import { loginApi, getUserInfoById } from '/@/api/sys/user';
import { setLocal, getLocal, getSession, setSession } from '/@/utils/helper/persistent'; import { setLocal, getLocal, getSession, setSession } from '/@/utils/cache/persistent';
import { useProjectSetting } from '/@/hooks/setting'; import { useProjectSetting } from '/@/hooks/setting';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { ErrorMessageMode } from '/@/utils/http/axios/types'; import { ErrorMessageMode } from '/@/utils/http/axios/types';
...@@ -37,7 +37,6 @@ function getCache<T>(key: string) { ...@@ -37,7 +37,6 @@ function getCache<T>(key: string) {
function setCache(USER_INFO_KEY: string, info: any) { function setCache(USER_INFO_KEY: string, info: any) {
if (!info) return; if (!info) return;
// const fn = permissionCacheType === CacheTypeEnum.LOCAL ? setLocal : setSession;
setLocal(USER_INFO_KEY, info, true); setLocal(USER_INFO_KEY, info, true);
// TODO // TODO
setSession(USER_INFO_KEY, info, true); setSession(USER_INFO_KEY, info, true);
......
...@@ -6,9 +6,10 @@ import { ...@@ -6,9 +6,10 @@ import {
RouterTransitionEnum, RouterTransitionEnum,
SettingButtonPositionEnum, SettingButtonPositionEnum,
} from '/@/enums/appEnum'; } from '/@/enums/appEnum';
import { CacheTypeEnum } from '/@/enums/cacheEnum'; import { CacheTypeEnum } from '/@/enums/cacheEnum';
import type { LocaleType } from '/@/locales/types'; import type { LocaleType } from '/@/locales/types';
import { ThemeMode } from '../../build/config/lessModifyVars'; import { ThemeMode } from '../../build/config/themeConfig';
export interface MenuSetting { export interface MenuSetting {
bgColor: string; bgColor: string;
...@@ -32,16 +33,10 @@ export interface MenuSetting { ...@@ -32,16 +33,10 @@ export interface MenuSetting {
} }
export interface MultiTabsSetting { export interface MultiTabsSetting {
// 是否显示
show: boolean; show: boolean;
// 开启快速操作
showQuick: boolean; showQuick: boolean;
canDrag: boolean; canDrag: boolean;
// 显示刷新按钮
showRedo: boolean; showRedo: boolean;
// 显示折叠按钮
showFold: boolean; showFold: boolean;
} }
...@@ -50,16 +45,14 @@ export interface HeaderSetting { ...@@ -50,16 +45,14 @@ export interface HeaderSetting {
fixed: boolean; fixed: boolean;
show: boolean; show: boolean;
theme: ThemeEnum; theme: ThemeEnum;
// Turn on full screen
// 显示全屏按钮
showFullScreen: boolean; showFullScreen: boolean;
// 开启全屏功能 // Whether to show the lock screen
useLockPage: boolean; useLockPage: boolean;
// 显示文档按钮 // Show document button
showDoc: boolean; showDoc: boolean;
// 显示消息中心按钮 // Show message center button
showNotice: boolean; showNotice: boolean;
showSearch: boolean; showSearch: boolean;
} }
...@@ -76,96 +69,90 @@ export interface LocaleSetting { ...@@ -76,96 +69,90 @@ export interface LocaleSetting {
export interface TransitionSetting { export interface TransitionSetting {
// Whether to open the page switching animation // Whether to open the page switching animation
enable: boolean; enable: boolean;
// Route basic switching animation // Route basic switching animation
basicTransition: RouterTransitionEnum; basicTransition: RouterTransitionEnum;
// Whether to open page switching loading // Whether to open page switching loading
openPageLoading: boolean; openPageLoading: boolean;
// Whether to open the top progress bar // Whether to open the top progress bar
openNProgress: boolean; openNProgress: boolean;
} }
export interface ProjectConfig { export interface ProjectConfig {
// Multilingual configuration
locale: LocaleSetting; locale: LocaleSetting;
// Storage location of permission related information
permissionCacheType: CacheTypeEnum; permissionCacheType: CacheTypeEnum;
// Whether to show the configuration button
// 是否显示配置按钮
showSettingButton: boolean; showSettingButton: boolean;
// Configure where the button is displayed
settingButtonPosition: SettingButtonPositionEnum; settingButtonPosition: SettingButtonPositionEnum;
// 权限模式 // Permission mode
permissionMode: PermissionModeEnum; permissionMode: PermissionModeEnum;
// 网站灰色模式,用于可能悼念的日期开启 // Website gray mode, open for possible mourning dates
grayMode: boolean; grayMode: boolean;
// 是否开启色弱模式 // Whether to turn on the color weak mode
colorWeak: boolean; colorWeak: boolean;
// 主题色 // Theme color
themeColor: string; themeColor: string;
themeMode: ThemeMode; themeMode: ThemeMode;
// 全屏显示主界面,不显示菜单,及顶部 // The main interface is displayed in full screen, the menu is not displayed, and the top
fullContent: boolean; fullContent: boolean;
// 区域宽度 // content width
contentMode: ContentEnum; contentMode: ContentEnum;
// 是否显示logo // Whether to display the logo
showLogo: boolean; showLogo: boolean;
// Whether to show the global footer
showFooter: boolean; showFooter: boolean;
headerSetting: HeaderSetting;
// 菜单类型
// menuType: MenuTypeEnum; // menuType: MenuTypeEnum;
headerSetting: HeaderSetting;
// menuSetting
menuSetting: MenuSetting; menuSetting: MenuSetting;
// Multi-tab settings
// 多标签页设置
multiTabsSetting: MultiTabsSetting; multiTabsSetting: MultiTabsSetting;
// Animation configuration
transitionSetting: TransitionSetting; transitionSetting: TransitionSetting;
// pageLayout whether to enable keep-alive
// pageLayout是否开启keep-alive
openKeepAlive: boolean; openKeepAlive: boolean;
// Lock screen time
//
// 锁屏时间
lockTime: number; lockTime: number;
// 显示面包屑 // Show breadcrumbs
showBreadCrumb: boolean; showBreadCrumb: boolean;
// 显示面包屑图标 // Show breadcrumb icon
showBreadCrumbIcon: boolean; showBreadCrumbIcon: boolean;
// 使用error-handler-plugin // Use error-handler-plugin
useErrorHandle: boolean; useErrorHandle: boolean;
// 是否开启回到顶部 // Whether to open back to top
useOpenBackTop: boolean; useOpenBackTop: boolean;
// 是否可以嵌入iframe页面 // Is it possible to embed iframe pages
canEmbedIFramePage: boolean; canEmbedIFramePage: boolean;
// 切换界面的时候是否删除未关闭的message及notify // Whether to delete unclosed messages and notify when switching the interface
closeMessageOnSwitch: boolean; closeMessageOnSwitch: boolean;
// 切换界面的时候是否取消已经发送但是未响应的http请求。 // Whether to cancel the http request that has been sent but not responded when switching the interface.
removeAllHttpPending: boolean; removeAllHttpPending: boolean;
} }
export interface GlobConfig { export interface GlobConfig {
// 网站标题 // Site title
title: string; title: string;
// 项目路径 // Service interface url
apiUrl: string; apiUrl: string;
// Upload url
uploadUrl?: string; uploadUrl?: string;
// Service interface url prefix
urlPrefix?: string; urlPrefix?: string;
// Project abbreviation
shortName: string; shortName: string;
} }
export interface GlobEnvConfig { export interface GlobEnvConfig {
// 网站标题 // Site title
VITE_GLOB_APP_TITLE: string; VITE_GLOB_APP_TITLE: string;
// 项目路径 // Service interface url
VITE_GLOB_API_URL: string; VITE_GLOB_API_URL: string;
// Service interface url prefix
VITE_GLOB_API_URL_PREFIX?: string; VITE_GLOB_API_URL_PREFIX?: string;
// Project abbreviation
VITE_GLOB_APP_SHORT_NAME: string; VITE_GLOB_APP_SHORT_NAME: string;
// Upload url
VITE_GLOB_UPLOAD_URL?: string; VITE_GLOB_UPLOAD_URL?: string;
} }
interface GlobWrap {
globSetting: Readonly<GlobConfig>;
}
interface ProjectSettingWrap {
projectSetting: Readonly<ProjectConfig>;
}
...@@ -16,9 +16,9 @@ export function getBoundingClientRect(element: Element): DOMRect | number { ...@@ -16,9 +16,9 @@ export function getBoundingClientRect(element: Element): DOMRect | number {
return element.getBoundingClientRect(); return element.getBoundingClientRect();
} }
const trim = function (string: string) { function trim(string: string) {
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ''); return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
}; }
/* istanbul ignore next */ /* istanbul ignore next */
export function hasClass(el: Element, cls: string) { export function hasClass(el: Element, cls: string) {
......
import type { GlobEnvConfig } from '/@/types/config'; import type { GlobEnvConfig } from '/@/types/config';
import { useGlobSetting } from '/@/hooks/setting';
import pkg from '../../package.json';
/** /**
* Get the global configuration (the configuration will be extracted independently when packaging) * Get the global configuration (the configuration will be extracted independently when packaging)
*/ */
...@@ -8,6 +11,12 @@ export function getGlobEnvConfig(): GlobEnvConfig { ...@@ -8,6 +11,12 @@ export function getGlobEnvConfig(): GlobEnvConfig {
return (env as unknown) as GlobEnvConfig; return (env as unknown) as GlobEnvConfig;
} }
// Generate cache key according to version
export function getStorageShortName() {
const globSetting = useGlobSetting();
return `${globSetting.shortName}__${getEnv()}${`__${pkg.version}`}__`.toUpperCase();
}
/** /**
* @description: Development model * @description: Development model
*/ */
......
...@@ -4,6 +4,7 @@ import { isObject } from '/@/utils/is'; ...@@ -4,6 +4,7 @@ import { isObject } from '/@/utils/is';
export const clamp = (n: number, min: number, max: number) => Math.min(max, Math.max(min, n)); export const clamp = (n: number, min: number, max: number) => Math.min(max, Math.max(min, n));
export const noop = () => {}; export const noop = () => {};
export const now = () => Date.now(); export const now = () => Date.now();
/** /**
* @description: Set ui mount node * @description: Set ui mount node
*/ */
......
...@@ -20,7 +20,7 @@ export function buildUUID(): string { ...@@ -20,7 +20,7 @@ export function buildUUID(): string {
} }
let unique = 0; let unique = 0;
export function snowUuid(prefix = ''): string { export function shortUuid(prefix = ''): string {
const time = Date.now(); const time = Date.now();
const random = Math.floor(Math.random() * 1000000000); const random = Math.floor(Math.random() * 1000000000);
unique++; unique++;
......
...@@ -4,13 +4,20 @@ ...@@ -4,13 +4,20 @@
</transition> </transition>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent, computed } from 'vue';
import LockPage from './LockPage.vue'; import LockPage from './LockPage.vue';
import { getIsLock } from '/@/hooks/web/useLockPage';
import { lockStore } from '/@/store/modules/lock';
export default defineComponent({ export default defineComponent({
name: 'Lock', name: 'Lock',
components: { LockPage }, components: { LockPage },
setup() { setup() {
const getIsLock = computed(() => {
const { getLockInfo } = lockStore;
const { isLock } = getLockInfo;
return isLock;
});
return { getIsLock }; return { getIsLock };
}, },
}); });
......
...@@ -28,6 +28,7 @@ module.exports = { ...@@ -28,6 +28,7 @@ module.exports = {
ignore: ['after-comment', 'first-nested'], ignore: ['after-comment', 'first-nested'],
}, },
], ],
'unit-no-unknown': [true, { ignoreUnits: ['rpx'] }],
// Specify the alphabetical order of the attributes in the declaration block // Specify the alphabetical order of the attributes in the declaration block
'order/properties-order': [ 'order/properties-order': [
'position', 'position',
...@@ -178,4 +179,5 @@ module.exports = { ...@@ -178,4 +179,5 @@ module.exports = {
'speak', 'speak',
], ],
}, },
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'],
}; };
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论