diff --git a/.eslintrc.js b/.eslintrc.js index 5fcac9eb6..9aa3e10ce 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,4 @@ -// @ts-check -const { defineConfig } = require('eslint-define-config'); -module.exports = defineConfig({ +module.exports = { root: true, env: { browser: true, @@ -20,9 +18,7 @@ module.exports = defineConfig({ extends: [ 'plugin:vue/vue3-recommended', 'plugin:@typescript-eslint/recommended', - 'prettier', 'plugin:prettier/recommended', - 'plugin:jest/recommended', ], rules: { 'vue/script-setup-uses-vars': 'error', @@ -62,6 +58,7 @@ module.exports = defineConfig({ 'vue/singleline-html-element-content-newline': 'off', 'vue/attribute-hyphenation': 'off', 'vue/require-default-prop': 'off', + 'vue/require-explicit-emits': 'off', 'vue/html-self-closing': [ 'error', { @@ -74,5 +71,6 @@ module.exports = defineConfig({ math: 'always', }, ], + 'vue/multi-word-component-names': 'off', }, -}); +}; diff --git a/.gitpod.yml b/.gitpod.yml index 219189500..866381fcc 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -2,5 +2,5 @@ ports: - port: 3344 onOpen: open-preview tasks: - - init: yarn - command: yarn dev + - init: pnpm install + command: pnpm run dev diff --git a/.husky/lintstagedrc.js b/.husky/lintstagedrc.js deleted file mode 100644 index 08d8c9e81..000000000 --- a/.husky/lintstagedrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - '*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'], - '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': ['prettier --write--parser json'], - 'package.json': ['prettier --write'], - '*.vue': ['eslint --fix', 'prettier --write', 'stylelint --fix'], - '*.{scss,less,styl,html}': ['stylelint --fix', 'prettier --write'], - '*.md': ['prettier --write'], -}; diff --git a/.husky/pre-commit b/.husky/pre-commit index c7d15f247..35f92427c 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -6,5 +6,3 @@ # Format and submit code according to lintstagedrc.js configuration npm run lint:lint-staged - -npm run lint:pretty diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 0af47dea9..94dc8139f 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ - "octref.vetur", + "johnsoncodehk.volar", "dbaeumer.vscode-eslint", "stylelint.vscode-stylelint", "esbenp.prettier-vscode", diff --git a/.vscode/launch.json b/.vscode/launch.json index 72e95d0d6..c5b8cb4f3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "type": "chrome", "request": "launch", "name": "Launch Chrome", - "url": "http://localhost:3100", + "url": "https://localhost:3100", "webRoot": "${workspaceFolder}/src", "sourceMaps": true } diff --git a/.vscode/settings.json b/.vscode/settings.json index e0ed52f3a..d3c7c8257 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,23 +1,10 @@ { "typescript.tsdk": "./node_modules/typescript/lib", - "typescript.enablePromptUseWorkspaceTsdk": true, "volar.tsPlugin": true, "volar.tsPluginStatus": false, - //=========================================== - //============= Editor ====================== - //=========================================== - "explorer.openEditors.visible": 0, + "npm.packageManager": "pnpm", "editor.tabSize": 2, "editor.defaultFormatter": "esbenp.prettier-vscode", - "diffEditor.ignoreTrimWhitespace": false, - //=========================================== - //============= Other ======================= - //=========================================== - "breadcrumbs.enabled": true, - "open-in-browser.default": "chrome", - //=========================================== - //============= files ======================= - //=========================================== "files.eol": "\n", "search.exclude": { "**/node_modules": true, @@ -68,16 +55,10 @@ "**/yarn.lock": true }, "stylelint.enable": true, - "stylelint.packageManager": "yarn", - "liveServer.settings.donotShowInfoMsg": true, - "telemetry.enableCrashReporter": false, - "workbench.settings.enableNaturalLanguageSearch": false, + "stylelint.validate": ["css", "less", "postcss", "scss", "vue", "sass"], "path-intellisense.mappings": { "/@/": "${workspaceRoot}/src" }, - "prettier.requireConfig": true, - "typescript.updateImportsOnFileMove.enabled": "always", - "workbench.sideBar.location": "left", "[javascriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, @@ -107,7 +88,8 @@ }, "[vue]": { "editor.codeActionsOnSave": { - "source.fixAll.eslint": false + "source.fixAll.eslint": true, + "source.fixAll.stylelint": true } }, "i18n-ally.localesPaths": ["src/locales/lang"], @@ -150,6 +132,8 @@ "lintstagedrc", "brotli", "tailwindcss", - "sider" + "sider", + "pnpm", + "antd" ] } diff --git a/.yarnclean b/.yarnclean deleted file mode 100644 index 3e556ef3a..000000000 --- a/.yarnclean +++ /dev/null @@ -1,48 +0,0 @@ -# test directories -__tests__ -test -tests -powered-test - -# asset directories -docs -doc -website -images -assets - -# examples -example -examples - -# code coverage directories -coverage -.nyc_output - -# build scripts -Makefile -Gulpfile.js -Gruntfile.js - -# configs -appveyor.yml -circle.yml -codeship-services.yml -codeship-steps.yml -wercker.yml -.tern-project -.gitattributes -.editorconfig -.*ignore -.eslintrc -.jshintrc -.flowconfig -.documentup.json -.yarn-metadata.json -.travis.yml - -# misc -*.md - -!istanbul-reports/lib/html/assets -!istanbul-api/node_modules/istanbul-reports/lib/html/assets diff --git a/CHANGELOG.en_US.md b/CHANGELOG.en_US.md index 93ad84685..345e8333a 100644 --- a/CHANGELOG.en_US.md +++ b/CHANGELOG.en_US.md @@ -1,3 +1,37 @@ +## 2.8.0(2021-11.03) + +### Upgrade Instructions + +- Package manager changed from `yarn` to `pnpm` +- Delete `node_modules` and `yarn.lock`, install `pnpm` globally +- Execute `pnpm install` + +### ✨ Features + +- **Others** + - The `VITE_PROXY` configuration in the `.env` file supports single quotes + - Remove warnings during build + +### 🐛 Bug Fixes + +- **BasicTable** + - Fix the issue that editable cells cannot be submitted in some cases + - Fix the problem that the `inset` attribute does not work + - Fix the problem that the performance of `useTable` and `reload` method `await` of `BasicTable` instance are inconsistent + - Fix the issue that `clickToRowSelect` would ignore the disabled state of the row selection box + - Fix the problem that the page of `BasicTable` will be reset in some cases + - Modify the `deleteTableDataRecord` method +- **BasicModal** + - Fixed the problem that `Modal` could not be closed even when clicking on the mask and pressing the `Esc` key + - Fixed the issue that clicking the close button and the blank area next to the maximize button would also cause `Modal` to close +- **BasicTree** Fix the problem that the node slot does not work +- **CodeEditor** Fix the problem that may cause `Build` failure +- **BasicForm** Fix the problem that the content width of the custom FormItem component may be out of range +- **ApiTreeSelect** Fix the problem that the change of `params` failed to trigger the re-request of api data +- **Others** -Fixed an issue where multiple tabs would not jump to routing when closing tabs in some cases + - Fix the issue that some components may cause abnormal hot update + - Fix the problem that some sub-components of `antdv` will be reported in the build process when directly `import` part of the `antdv`, such as: TabPane, RadioGroup + ## 2.7.2(2021-09-14) ### ✨ Features diff --git a/CHANGELOG.md b/CHANGELOG.md index 873027d37..41ddf1f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [2.7.2](https://github.com/anncwb/vue-vben-admin/compare/v2.7.1...v2.7.2) (2021-09-13) +## [2.8.0](https://github.com/anncwb/vue-vben-admin/compare/v2.7.2...v2.8.0) (2021-11-03) ### Bug Fixes diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 3181b20da..acf8957ea 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -1,3 +1,38 @@ +## 2.8.0(2021-11.03) + +### 升级说明 + +- 包管理器由`yarn`改为 `pnpm` +- 删除`node_modules`和`yarn.lock`,全局安装`pnpm` +- 执行`pnpm install` + +### ✨ Features + +- **其它** + - `.env`文件中的`VITE_PROXY`配置支持单引号 + - 移除 build 过程中的警告 + +### 🐛 Bug Fixes + +- **BasicTable** + - 修复可编辑单元格某些情况下无法提交的问题 + - 修复`inset`属性不起作用的问题 + - 修复`useTable`与`BasicTable`实例的`reload`方法`await`表现不一致的问题 + - 修复`clickToRowSelect`会无视行选择框 disabled 状态的问题 + - 修复`BasicTable`在某些情况下,分页会被重置的问题 + - 修改 `deleteTableDataRecord` 方法 +- **BasicModal** + - 修复点击遮罩、按下`Esc`键都不能关闭`Modal`的问题 + - 修复点击关闭按钮、最大化按钮旁边的空白区域也会导致`Modal`关闭的问题 +- **BasicTree** 修复节点插槽不起作用的问题 +- **CodeEditor** 修复可能会造成的`Build`失败的问题 +- **BasicForm** 修复自定义 FormItem 组件的内容宽度可能超出范围的问题 +- **ApiTreeSelect** 修复`params`变化未能触发重新请求 api 数据的问题 +- **其它** + - 修复多标签在某些情况下关闭页签不会跳转路由的问题 + - 修复部分组件可能会造成热更新异常的问题 + - 修复直接`import`部分`antdv`子组件时会在 build 过程中报错的问题,如:TabPane、RadioGroup + ## 2.7.2(2021-09-14) ### ✨ Features diff --git a/README.md b/README.md index d15f76674..b39b305d3 100644 --- a/README.md +++ b/README.md @@ -70,20 +70,20 @@ git clone https://github.com/anncwb/vue-vben-admin.git ```bash cd vue-vben-admin -yarn install +pnpm install ``` - run ```bash -yarn serve +pnpm serve ``` - build ```bash -yarn build +pnpm build ``` ## Change Log diff --git a/README.zh-CN.md b/README.zh-CN.md index acb575f52..408af3cc8 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -70,20 +70,20 @@ git clone https://github.com/anncwb/vue-vben-admin.git ```bash cd vue-vben-admin -yarn install +pnpm install ``` - 运行 ```bash -yarn serve +pnpm serve ``` - 打包 ```bash -yarn build +pnpm build ``` ## 更新日志 diff --git a/build/generate/icon/index.ts b/build/generate/icon/index.ts index c78cb09f2..b01fec4cb 100644 --- a/build/generate/icon/index.ts +++ b/build/generate/icon/index.ts @@ -1,7 +1,7 @@ import path from 'path'; import fs from 'fs-extra'; import inquirer from 'inquirer'; -import chalk from 'chalk'; +import colors from 'picocolors'; import pkg from '../../../package.json'; async function generateIcon() { @@ -64,7 +64,7 @@ async function generateIcon() { } fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite')); console.log( - `✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`, + `✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`, ); }); } diff --git a/build/script/buildConf.ts b/build/script/buildConf.ts index 48ed4d9be..aa7b84399 100644 --- a/build/script/buildConf.ts +++ b/build/script/buildConf.ts @@ -3,20 +3,21 @@ */ import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant'; import fs, { writeFileSync } from 'fs-extra'; -import chalk from 'chalk'; +import colors from 'picocolors'; -import { getRootPath, getEnvConfig } from '../utils'; +import { getEnvConfig, getRootPath } from '../utils'; import { getConfigFileName } from '../getConfigFileName'; import pkg from '../../package.json'; -function createConfig( - { - configName, - config, - configFileName = GLOB_CONFIG_FILE_NAME, - }: { configName: string; config: any; configFileName?: string } = { configName: '', config: {} }, -) { +interface CreateConfigParams { + configName: string; + config: any; + configFileName?: string; +} + +function createConfig(params: CreateConfigParams) { + const { configName, config, configFileName } = params; try { const windowConf = `window.${configName}`; // Ensure that the variable will not be modified @@ -30,15 +31,15 @@ function createConfig( fs.mkdirp(getRootPath(OUTPUT_DIR)); writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr); - console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`); - console.log(chalk.gray(OUTPUT_DIR + '/' + chalk.green(configFileName)) + '\n'); + console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`); + console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n'); } catch (error) { - console.log(chalk.red('configuration file configuration file failed to package:\n' + error)); + console.log(colors.red('configuration file configuration file failed to package:\n' + error)); } } export function runBuildConfig() { const config = getEnvConfig(); const configFileName = getConfigFileName(config); - createConfig({ config, configName: configFileName }); + createConfig({ config, configName: configFileName, configFileName: GLOB_CONFIG_FILE_NAME }); } diff --git a/build/script/compilerElectron.ts b/build/script/compilerElectron.ts index 0477061d9..454ffa4af 100644 --- a/build/script/compilerElectron.ts +++ b/build/script/compilerElectron.ts @@ -14,7 +14,7 @@ const TAG = '[compiler-electron]'; export function startCompilerElectron(port = 80) { // 因为 vite 不会重定向到 index.html,所以直接写 index.html 路由。 - const ELECTRON_URL = `http://localhost:${port}/index.html`; + const ELECTRON_URL = `https://localhost:${port}/index.html`; const spinner = ora(`${TAG} Electron build...`); const electron = electronConnect.server.create({ stopOnClose: true }); diff --git a/build/script/postBuild.ts b/build/script/postBuild.ts index e1554bff7..42635d88b 100644 --- a/build/script/postBuild.ts +++ b/build/script/postBuild.ts @@ -1,7 +1,7 @@ // #!/usr/bin/env node import { runBuildConfig } from './buildConf'; -import chalk from 'chalk'; +import colors from 'picocolors'; import pkg from '../../package.json'; @@ -14,9 +14,9 @@ export const runBuild = async () => { runBuildConfig(); } - console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!'); + console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!'); } catch (error) { - console.log(chalk.red('vite build error:\n' + error)); + console.log(colors.red('vite build error:\n' + error)); process.exit(1); } }; diff --git a/build/utils.ts b/build/utils.ts index 58694077d..c201514f9 100644 --- a/build/utils.ts +++ b/build/utils.ts @@ -28,9 +28,9 @@ export function wrapperEnv(envConf: Recordable): ViteEnv { if (envName === 'VITE_PORT') { realName = Number(realName); } - if (envName === 'VITE_PROXY') { + if (envName === 'VITE_PROXY' && realName) { try { - realName = JSON.parse(realName); + realName = JSON.parse(realName.replace(/'/g, '"')); } catch (error) { realName = ''; } diff --git a/build/vite/optimizer.ts b/build/vite/optimizer.ts deleted file mode 100644 index 8bb0fec19..000000000 --- a/build/vite/optimizer.ts +++ /dev/null @@ -1,21 +0,0 @@ -// TODO -import type { GetManualChunk } from 'rollup'; - -// -const vendorLibs: { match: string[]; output: string }[] = [ - // { - // match: ['xlsx'], - // output: 'xlsx', - // }, -]; - -// @ts-ignore -export const configManualChunk: GetManualChunk = (id: string) => { - if (/[\\/]node_modules[\\/]/.test(id)) { - const matchItem = vendorLibs.find((item) => { - const reg = new RegExp(`[\\/]node_modules[\\/]_?(${item.match.join('|')})(.*)`, 'ig'); - return reg.test(id); - }); - return matchItem ? matchItem.output : null; - } -}; diff --git a/build/vite/plugin/compress.ts b/build/vite/plugin/compress.ts index 3ad32be12..ff4f6311d 100644 --- a/build/vite/plugin/compress.ts +++ b/build/vite/plugin/compress.ts @@ -2,16 +2,16 @@ * Used to package and output gzip. Note that this does not work properly in Vite, the specific reason is still being investigated * https://github.com/anncwb/vite-plugin-compression */ -import type { Plugin } from 'vite'; +import type { PluginOption } from 'vite'; import compressPlugin from 'vite-plugin-compression'; export function configCompressPlugin( compress: 'gzip' | 'brotli' | 'none', deleteOriginFile = false, -): Plugin | Plugin[] { +): PluginOption | PluginOption[] { const compressList = compress.split(','); - const plugins: Plugin[] = []; + const plugins: PluginOption[] = []; if (compressList.includes('gzip')) { plugins.push( diff --git a/build/vite/plugin/hmr.ts b/build/vite/plugin/hmr.ts deleted file mode 100644 index 807fdb96a..000000000 --- a/build/vite/plugin/hmr.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { Plugin } from 'vite'; - -/** - * TODO - * Temporarily solve the Vite circular dependency problem, and wait for a better solution to fix it later. I don't know what problems this writing will bring. - * @returns - */ - -export function configHmrPlugin(): Plugin { - return { - name: 'singleHMR', - handleHotUpdate({ modules, file }) { - if (file.match(/xml$/)) return []; - - modules.forEach((m) => { - if (!m.url.match(/\.(css|less)/)) { - m.importedModules = new Set(); - m.importers = new Set(); - } - }); - - return modules; - }, - }; -} diff --git a/build/vite/plugin/html.ts b/build/vite/plugin/html.ts index 848190bd8..6af034ac4 100644 --- a/build/vite/plugin/html.ts +++ b/build/vite/plugin/html.ts @@ -2,8 +2,8 @@ * Plugin to minimize and use ejs template syntax in index.html. * https://github.com/anncwb/vite-plugin-html */ -import type { Plugin } from 'vite'; -import html from 'vite-plugin-html'; +import type { PluginOption } from 'vite'; +import { createHtmlPlugin } from 'vite-plugin-html'; import pkg from '../../../package.json'; import { GLOB_CONFIG_FILE_NAME } from '../../constant'; @@ -16,7 +16,7 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`; }; - const htmlPlugin: Plugin[] = html({ + const htmlPlugin: PluginOption[] = createHtmlPlugin({ minify: isBuild, inject: { // Inject data into ejs template diff --git a/build/vite/plugin/index.ts b/build/vite/plugin/index.ts index 9c0924a0d..0efe660db 100644 --- a/build/vite/plugin/index.ts +++ b/build/vite/plugin/index.ts @@ -1,9 +1,10 @@ -import type { Plugin } from 'vite'; +import { PluginOption } from 'vite'; import vue from '@vitejs/plugin-vue'; import vueJsx from '@vitejs/plugin-vue-jsx'; import legacy from '@vitejs/plugin-legacy'; import purgeIcons from 'vite-plugin-purge-icons'; import windiCSS from 'vite-plugin-windicss'; +import VitePluginCertificate from 'vite-plugin-mkcert'; import vueSetupExtend from 'vite-plugin-vue-setup-extend'; import { configHtmlPlugin } from './html'; import { configPwaConfig } from './pwa'; @@ -14,7 +15,6 @@ import { configVisualizerConfig } from './visualizer'; import { configThemePlugin } from './theme'; import { configImageminPlugin } from './imagemin'; import { configSvgIconsPlugin } from './svgSprite'; -import { configHmrPlugin } from './hmr'; export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { const { @@ -25,21 +25,21 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE, } = viteEnv; - const vitePlugins: (Plugin | Plugin[])[] = [ + const vitePlugins: (PluginOption | PluginOption[])[] = [ // have to vue(), // have to vueJsx(), // support name vueSetupExtend(), + VitePluginCertificate({ + source: 'coding', + }), ]; // vite-plugin-windicss vitePlugins.push(windiCSS()); - // TODO - !isBuild && vitePlugins.push(configHmrPlugin()); - // @vitejs/plugin-legacy VITE_LEGACY && isBuild && vitePlugins.push(legacy()); @@ -61,12 +61,12 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { // rollup-plugin-visualizer vitePlugins.push(configVisualizerConfig()); - //vite-plugin-theme + // vite-plugin-theme vitePlugins.push(configThemePlugin(isBuild)); // The following plugins only work in the production environment if (isBuild) { - //vite-plugin-imagemin + // vite-plugin-imagemin VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin()); // rollup-plugin-gzip diff --git a/build/vite/plugin/styleImport.ts b/build/vite/plugin/styleImport.ts index 786580f85..5f96746cc 100644 --- a/build/vite/plugin/styleImport.ts +++ b/build/vite/plugin/styleImport.ts @@ -2,19 +2,75 @@ * Introduces component library styles on demand. * https://github.com/anncwb/vite-plugin-style-import */ -import styleImport from 'vite-plugin-style-import'; +import { createStyleImportPlugin } from 'vite-plugin-style-import'; -export function configStyleImportPlugin(isBuild: boolean) { - if (!isBuild) { - return []; - } - const styleImportPlugin = styleImport({ +export function configStyleImportPlugin(_isBuild: boolean) { + // if (!isBuild) { + // return []; + // } + const styleImportPlugin = createStyleImportPlugin({ libs: [ { libraryName: 'ant-design-vue', esModule: true, resolveStyle: (name) => { - return `ant-design-vue/es/${name}/style/index`; + // 这里是无需额外引入样式文件的“子组件”列表 + const ignoreList = [ + 'anchor-link', + 'sub-menu', + 'menu-item', + 'menu-divider', + 'menu-item-group', + 'breadcrumb-item', + 'breadcrumb-separator', + 'form-item', + 'step', + 'select-option', + 'select-opt-group', + 'card-grid', + 'card-meta', + 'collapse-panel', + 'descriptions-item', + 'list-item', + 'list-item-meta', + 'table-column', + 'table-column-group', + 'tab-pane', + 'tab-content', + 'timeline-item', + 'tree-node', + 'skeleton-input', + 'skeleton-avatar', + 'skeleton-title', + 'skeleton-paragraph', + 'skeleton-image', + 'skeleton-button', + ]; + // 这里是需要额外引入样式的子组件列表 + // 单独引入子组件时需引入组件样式,否则会在打包后导致子组件样式丢失 + const replaceList = { + 'typography-text': 'typography', + 'typography-title': 'typography', + 'typography-paragraph': 'typography', + 'typography-link': 'typography', + 'dropdown-button': 'dropdown', + 'input-password': 'input', + 'input-search': 'input', + 'input-group': 'input', + 'radio-group': 'radio', + 'checkbox-group': 'checkbox', + 'layout-sider': 'layout', + 'layout-content': 'layout', + 'layout-footer': 'layout', + 'layout-header': 'layout', + 'month-picker': 'date-picker', + }; + + return ignoreList.includes(name) + ? '' + : replaceList.hasOwnProperty(name) + ? `ant-design-vue/es/${replaceList[name]}/style/index` + : `ant-design-vue/es/${name}/style/index`; }, }, ], diff --git a/build/vite/plugin/svgSprite.ts b/build/vite/plugin/svgSprite.ts index 3817acbfc..61f637f4e 100644 --- a/build/vite/plugin/svgSprite.ts +++ b/build/vite/plugin/svgSprite.ts @@ -3,11 +3,11 @@ * https://github.com/anncwb/vite-plugin-svg-icons */ -import SvgIconsPlugin from 'vite-plugin-svg-icons'; +import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; import path from 'path'; export function configSvgIconsPlugin(isBuild: boolean) { - const svgIconsPlugin = SvgIconsPlugin({ + const svgIconsPlugin = createSvgIconsPlugin({ iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], svgoOptions: isBuild, // default diff --git a/build/vite/plugin/theme.ts b/build/vite/plugin/theme.ts index c54f1a834..118983f77 100644 --- a/build/vite/plugin/theme.ts +++ b/build/vite/plugin/theme.ts @@ -2,7 +2,7 @@ * Vite plugin for website theme color switching * https://github.com/anncwb/vite-plugin-theme */ -import type { Plugin } from 'vite'; +import type { PluginOption } from 'vite'; import path from 'path'; import { viteThemePlugin, @@ -14,7 +14,7 @@ import { import { getThemeColors, generateColors } from '../../config/themeConfig'; import { generateModifyVars } from '../../generate/generateModifyVars'; -export function configThemePlugin(isBuild: boolean): Plugin[] { +export function configThemePlugin(isBuild: boolean): PluginOption[] { const colors = generateColors({ mixDarken, mixLighten, @@ -85,5 +85,5 @@ export function configThemePlugin(isBuild: boolean): Plugin[] { }), ]; - return plugin as unknown as Plugin[]; + return plugin as unknown as PluginOption[]; } diff --git a/build/vite/proxy.ts b/build/vite/proxy.ts index dc23646d5..8525397b6 100644 --- a/build/vite/proxy.ts +++ b/build/vite/proxy.ts @@ -7,7 +7,7 @@ type ProxyItem = [string, string]; type ProxyList = ProxyItem[]; -type ProxyTargetList = Record string }>; +type ProxyTargetList = Record; const httpsRE = /^https:\/\//; diff --git a/commitlint.config.js b/commitlint.config.js index ac977af17..54598876e 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -7,6 +7,7 @@ module.exports = { 'header-max-length': [2, 'always', 108], 'subject-empty': [2, 'never'], 'type-empty': [2, 'never'], + 'subject-case': [0], 'type-enum': [ 2, 'always', diff --git a/electron-main/index.ts b/electron-main/index.ts index 0846b48ca..1baeeeab5 100644 --- a/electron-main/index.ts +++ b/electron-main/index.ts @@ -26,7 +26,7 @@ class createWin { backgroundColor: '#fff', }); const URL = is_dev - ? `http://localhost:${process.env.PORT}` // vite 启动的服务器地址 + ? `https://localhost:${process.env.PORT}` // vite 启动的服务器地址 : `file://${join(__dirname, '../index.html')}`; // vite 构建后的静态文件地址 mainWindow.loadURL(URL); diff --git a/index.html b/index.html index 5b99faf67..f615e97cc 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,6 @@ name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" /> - <%= title %> @@ -30,7 +29,7 @@ } html[data-theme='dark'] .app-loading .app-loading-title { - color: rgba(255, 255, 255, 0.85); + color: rgb(255 255 255 / 85%); } .app-loading { @@ -48,7 +47,6 @@ top: 50%; left: 50%; display: flex; - -webkit-transform: translate3d(-50%, -50%, 0); transform: translate3d(-50%, -50%, 0); justify-content: center; align-items: center; @@ -66,7 +64,7 @@ display: flex; margin-top: 30px; font-size: 30px; - color: rgba(0, 0, 0, 0.85); + color: rgb(0 0 0 / 85%); justify-content: center; align-items: center; } @@ -97,7 +95,7 @@ height: 20px; background-color: #0065cc; border-radius: 100%; - opacity: 0.3; + opacity: 30%; transform: scale(0.75); animation: antSpinMove 1s infinite linear alternate; transform-origin: 50% 50%; @@ -111,43 +109,38 @@ .dot i:nth-child(2) { top: 0; right: 0; - -webkit-animation-delay: 0.4s; animation-delay: 0.4s; } .dot i:nth-child(3) { right: 0; bottom: 0; - -webkit-animation-delay: 0.8s; animation-delay: 0.8s; } .dot i:nth-child(4) { bottom: 0; left: 0; - -webkit-animation-delay: 1.2s; animation-delay: 1.2s; } @keyframes antRotate { to { - -webkit-transform: rotate(405deg); transform: rotate(405deg); } } - @-webkit-keyframes antRotate { + @keyframes antRotate { to { - -webkit-transform: rotate(405deg); transform: rotate(405deg); } } @keyframes antSpinMove { to { - opacity: 1; + opacity: 100%; } } - @-webkit-keyframes antSpinMove { + @keyframes antSpinMove { to { - opacity: 1; + opacity: 100%; } } diff --git a/jest.config.mjs b/jest.config.mjs deleted file mode 100644 index 162e72b39..000000000 --- a/jest.config.mjs +++ /dev/null @@ -1,36 +0,0 @@ -export default { - preset: 'ts-jest', - roots: ['/tests/'], - clearMocks: true, - moduleDirectories: ['node_modules', 'src'], - moduleFileExtensions: ['js', 'ts', 'vue', 'tsx', 'jsx', 'json', 'node'], - modulePaths: ['/src', '/node_modules'], - testMatch: [ - '**/tests/**/*.[jt]s?(x)', - '**/?(*.)+(spec|test).[tj]s?(x)', - '(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$', - ], - testPathIgnorePatterns: [ - '/tests/server/', - '/tests/__mocks__/', - '/node_modules/', - ], - transform: { - '^.+\\.tsx?$': 'ts-jest', - }, - transformIgnorePatterns: ['/tests/__mocks__/', '/node_modules/'], - // A map from regular expressions to module names that allow to stub out resources with a single module - moduleNameMapper: { - '\\.(vs|fs|vert|frag|glsl|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': - '/tests/__mocks__/fileMock.ts', - '\\.(sass|s?css|less)$': '/tests/__mocks__/styleMock.ts', - '\\?worker$': '/tests/__mocks__/workerMock.ts', - '^/@/(.*)$': '/src/$1', - }, - testEnvironment: 'jsdom', - verbose: true, - collectCoverage: false, - coverageDirectory: 'coverage', - collectCoverageFrom: ['src/**/*.{js,ts,vue}'], - coveragePathIgnorePatterns: ['^.+\\.d\\.ts$'], -}; diff --git a/mock/demo/account.ts b/mock/demo/account.ts index 4ba247d19..a39249315 100644 --- a/mock/demo/account.ts +++ b/mock/demo/account.ts @@ -1,5 +1,6 @@ import { MockMethod } from 'vite-plugin-mock'; import { resultSuccess, resultError } from '../_util'; +import { ResultEnum } from '../../src/enums/httpEnum'; const userInfo = { name: 'Vben', @@ -59,4 +60,12 @@ export default [ return resultError(); }, }, + { + url: '/basic-api/user/tokenExpired', + method: 'post', + statusCode: 200, + response: () => { + return resultError('Token Expired!', { code: ResultEnum.TIMEOUT as number }); + }, + }, ] as MockMethod[]; diff --git a/mock/demo/api-cascader.ts b/mock/demo/api-cascader.ts new file mode 100644 index 000000000..6334ef5b1 --- /dev/null +++ b/mock/demo/api-cascader.ts @@ -0,0 +1,325 @@ +import { MockMethod } from 'vite-plugin-mock'; +import { resultSuccess } from '../_util'; + +const areaList: any[] = [ + { + id: '530825900854620160', + code: '430000', + parentCode: '100000', + levelType: 1, + name: '湖南省', + province: '湖南省', + city: null, + district: null, + town: null, + village: null, + parentPath: '430000', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 16:33:42', + customized: false, + usable: true, + }, + { + id: '530825900883980288', + code: '430100', + parentCode: '430000', + levelType: 2, + name: '长沙市', + province: '湖南省', + city: '长沙市', + district: null, + town: null, + village: null, + parentPath: '430000,430100', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 16:33:42', + customized: false, + usable: true, + }, + { + id: '530825900951089152', + code: '430102', + parentCode: '430100', + levelType: 3, + name: '芙蓉区', + province: '湖南省', + city: '长沙市', + district: '芙蓉区', + town: null, + village: null, + parentPath: '430000,430100,430102', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 16:33:42', + customized: false, + usable: true, + }, + { + id: '530825901014003712', + code: '430104', + parentCode: '430100', + levelType: 3, + name: '岳麓区', + province: '湖南省', + city: '长沙市', + district: '岳麓区', + town: null, + village: null, + parentPath: '430000,430100,430104', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 16:33:42', + customized: false, + usable: true, + }, + { + id: '530825900988837888', + code: '430103', + parentCode: '430100', + levelType: 3, + name: '天心区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: null, + village: null, + parentPath: '430000,430100,430103', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 16:33:42', + customized: false, + usable: true, + }, + { + id: '530826672489115648', + code: '430103002', + parentCode: '430103', + levelType: 4, + name: '坡子街街道', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: null, + parentPath: '430000,430100,430103,430103002', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-12-14 15:26:43', + customized: false, + usable: true, + }, + { + id: '530840241171607552', + code: '430103002001', + parentCode: '430103002', + levelType: 5, + name: '八角亭社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '八角亭社区', + parentPath: '430000,430100,430103,430103002,430103002001', + createTime: '2020-11-30 15:47:31', + updateTime: '2021-01-20 14:07:23', + customized: false, + usable: true, + }, + { + id: '530840241200967680', + code: '430103002002', + parentCode: '430103002', + levelType: 5, + name: '西牌楼社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '西牌楼社区', + parentPath: '430000,430100,430103,430103002,430103002002', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241230327808', + code: '430103002003', + parentCode: '430103002', + levelType: 5, + name: '太平街社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '太平街社区', + parentPath: '430000,430100,430103,430103002,430103002003', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241259687936', + code: '430103002005', + parentCode: '430103002', + levelType: 5, + name: '坡子街社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '坡子街社区', + parentPath: '430000,430100,430103,430103002,430103002005', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241284853760', + code: '430103002006', + parentCode: '430103002', + levelType: 5, + name: '青山祠社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '青山祠社区', + parentPath: '430000,430100,430103,430103002,430103002006', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241310019584', + code: '430103002007', + parentCode: '430103002', + levelType: 5, + name: '沙河社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '沙河社区', + parentPath: '430000,430100,430103,430103002,430103002007', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241381322752', + code: '430103002008', + parentCode: '430103002', + levelType: 5, + name: '碧湘社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '碧湘社区', + parentPath: '430000,430100,430103,430103002,430103002008', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241410682880', + code: '430103002009', + parentCode: '430103002', + levelType: 5, + name: '创远社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '创远社区', + parentPath: '430000,430100,430103,430103002,430103002009', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241431654400', + code: '430103002010', + parentCode: '430103002', + levelType: 5, + name: '楚湘社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '楚湘社区', + parentPath: '430000,430100,430103,430103002,430103002010', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241465208832', + code: '430103002011', + parentCode: '430103002', + levelType: 5, + name: '西湖社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '西湖社区', + parentPath: '430000,430100,430103,430103002,430103002011', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241502957568', + code: '430103002012', + parentCode: '430103002', + levelType: 5, + name: '登仁桥社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '登仁桥社区', + parentPath: '430000,430100,430103,430103002,430103002012', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, + { + id: '530840241553289216', + code: '430103002013', + parentCode: '430103002', + levelType: 5, + name: '文庙坪社区', + province: '湖南省', + city: '长沙市', + district: '天心区', + town: '坡子街街道', + village: '文庙坪社区', + parentPath: '430000,430100,430103,430103002,430103002013', + createTime: '2020-11-30 15:47:31', + updateTime: '2020-11-30 17:30:41', + customized: false, + usable: true, + }, +]; +export default [ + { + url: '/basic-api/cascader/getAreaRecord', + timeout: 1000, + method: 'post', + response: ({ body }) => { + const { parentCode } = body || {}; + if (!parentCode) { + return resultSuccess(areaList.filter((it) => it.code === '430000')); + } + return resultSuccess(areaList.filter((it) => it.parentCode === parentCode)); + }, + }, +] as MockMethod[]; diff --git a/mock/demo/select-demo.ts b/mock/demo/select-demo.ts index fc35a395d..631c6bb05 100644 --- a/mock/demo/select-demo.ts +++ b/mock/demo/select-demo.ts @@ -1,11 +1,11 @@ import { MockMethod } from 'vite-plugin-mock'; import { resultSuccess } from '../_util'; -const demoList = (keyword) => { +const demoList = (keyword, count = 20) => { const result = { list: [] as any[], }; - for (let index = 0; index < 20; index++) { + for (let index = 0; index < count; index++) { result.list.push({ name: `${keyword ?? ''}选项${index}`, id: `${index}`, @@ -20,9 +20,9 @@ export default [ timeout: 1000, method: 'get', response: ({ query }) => { - const { keyword } = query; + const { keyword, count } = query; console.log(keyword); - return resultSuccess(demoList(keyword)); + return resultSuccess(demoList(keyword, count)); }, }, ] as MockMethod[]; diff --git a/mock/demo/table-demo.ts b/mock/demo/table-demo.ts index 2fae797f7..f3a0f16fd 100644 --- a/mock/demo/table-demo.ts +++ b/mock/demo/table-demo.ts @@ -12,7 +12,7 @@ function getRandomPics(count = 10): string[] { const demoList = (() => { const result: any[] = []; - for (let index = 0; index < 60; index++) { + for (let index = 0; index < 200; index++) { result.push({ id: `${index}`, beginTime: '@datetime', diff --git a/mock/sys/user.ts b/mock/sys/user.ts index 8b8989fa4..5b569d4d9 100644 --- a/mock/sys/user.ts +++ b/mock/sys/user.ts @@ -111,4 +111,12 @@ export default [ return resultSuccess(undefined, { message: 'Token has been destroyed' }); }, }, + { + url: '/basic-api/testRetry', + statusCode: 405, + method: 'get', + response: () => { + return resultError('Error!'); + }, + }, ] as MockMethod[]; diff --git a/package.json b/package.json index 1d4bb89d0..81b862d4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vben-admin", - "version": "2.7.2", + "version": "2.8.0", "author": { "name": "vben", "email": "anncwb@126.com", @@ -48,12 +48,12 @@ } }, "scripts": { - "bootstrap": "yarn install", - "dev": "vite", + "bootstrap": "pnpm install", "serve": "npm run dev", + "dev": "vite", "build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts", "build:test": "cross-env vite build --mode test && esno ./build/script/postBuild.ts", - "build:no-cache": "yarn clean:cache && npm run build", + "build:no-cache": "pnpm clean:cache && npm run build", "dev:app": "esno ./build/script/startElectron.ts --env=development --watch", "build:app": "npm run build && esno ./build/script/startElectron.ts --env=production && electron-builder ", "report": "cross-env REPORT=true npm run build", @@ -66,48 +66,53 @@ "lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix", "lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", - "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", - "lint:pretty": "pretty-quick --staged", + "lint:lint-staged": "lint-staged", "test:unit": "jest", - "test:unit-coverage": "jest --coverage", - "test:gzip": "http-server dist --cors --gzip -c-1", - "test:br": "http-server dist --cors --brotli -c-1", - "reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap", + "test:gzip": "npx http-server dist --cors --gzip -c-1", + "test:br": "npx http-server dist --cors --brotli -c-1", + "reinstall": "rimraf pnpm-lock.yaml && rimraf package.lock.json && rimraf node_modules && npm run bootstrap", "prepare": "husky install", "gen:icon": "esno ./build/generate/icon/index.ts" }, "dependencies": { - "@iconify/iconify": "^2.0.4", + "@ant-design/colors": "^6.0.0", + "@ant-design/icons-vue": "^6.1.0", "@logicflow/core": "^0.6.16", "@logicflow/extension": "^0.6.16", + "@iconify/iconify": "^2.2.1", + "@vue/runtime-core": "^3.2.31", + "@vue/shared": "^3.2.31", "@vueuse/core": "^6.3.3", - "@zxcvbn-ts/core": "^1.0.0-beta.0", - "ant-design-vue": "2.2.7", + "@vueuse/shared": "^6.3.3", + "@zxcvbn-ts/core": "^2.0.1", + "ant-design-vue": "3.1.1", "axios": "^0.21.4", "codemirror": "^5.62.3", "cropperjs": "^1.5.12", "electron-is-dev": "^1.2.0", "crypto-js": "^4.1.1", + "dayjs": "^1.11.0", "echarts": "^5.2.0", "intro.js": "^4.2.2", "lodash-es": "^4.17.21", "mockjs": "^1.1.0", "nprogress": "^0.2.0", "path-to-regexp": "^6.2.0", - "pinia": "2.0.0-rc.9", + "pinia": "2.0.12", "print-js": "^1.6.0", "qrcode": "^1.4.4", + "qs": "^6.10.3", "resize-observer-polyfill": "^1.5.1", "showdown": "^1.9.1", "sortablejs": "^1.14.0", "tinymce": "^5.9.2", - "vditor": "^3.8.6", - "vue": "3.2.11", - "vue-i18n": "9.1.7", - "vue-json-pretty": "^2.0.4", - "vue-router": "^4.0.11", - "vue-types": "^4.1.0", - "xlsx": "^0.17.1" + "vditor": "^3.8.13", + "vue": "^3.2.31", + "vue-i18n": "^9.1.9", + "vue-json-pretty": "^2.0.6", + "vue-router": "^4.0.14", + "vue-types": "^4.1.1", + "xlsx": "^0.18.5" }, "devDependencies": { "@commitlint/cli": "^13.1.0", @@ -144,7 +149,7 @@ "conventional-changelog-cli": "^2.1.1", "cross-env": "^7.0.3", "dotenv": "^10.0.0", - "electron": "^11.0.0", + "electron": "^18.0.0", "electron-builder": "^22.8.0", "electron-connect": "^0.6.3", "electron-contextmenu-middleware": "^1.0.3", @@ -163,9 +168,12 @@ "is-ci": "^3.0.0", "jest": "^27.2.0", "less": "^4.1.1", - "lint-staged": "^11.1.2", + "lint-staged": "12.3.7", "npm-run-all": "^4.1.5", + "picocolors": "^1.0.0", "postcss": "^8.3.6", + "postcss-html": "^1.3.0", + "postcss-less": "^6.0.0", "prettier": "^2.4.0", "pretty-quick": "^3.1.1", "rimraf": "^3.0.2", @@ -178,15 +186,16 @@ "ts-jest": "^27.0.5", "ts-node": "^10.2.1", "typescript": "4.4.3", - "vite": "2.5.7", + "vite": "^2.9.1", "vite-plugin-compression": "^0.3.5", - "vite-plugin-html": "^2.1.0", + "vite-plugin-html": "^3.2.0", "vite-plugin-imagemin": "^0.4.5", + "vite-plugin-mkcert": "^1.6.0", "vite-plugin-mock": "^2.9.6", "vite-plugin-purge-icons": "^0.7.0", "vite-plugin-pwa": "^0.11.2", - "vite-plugin-style-import": "^1.2.1", - "vite-plugin-svg-icons": "^1.0.4", + "vite-plugin-style-import": "^2.0.0", + "vite-plugin-svg-icons": "^2.0.1", "vite-plugin-theme": "^0.8.1", "wait-on": "^5.2.1", "vite-plugin-vue-setup-extend": "^0.1.0", @@ -195,9 +204,9 @@ "vue-tsc": "^0.3.0" }, "resolutions": { - "//": "Used to install imagemin dependencies, because imagemin may not be installed in China. If it is abroad, you can delete it", "bin-wrapper": "npm:bin-wrapper-china", - "rollup": "^2.56.3" + "rollup": "^2.56.3", + "gifsicle": "5.2.0" }, "repository": { "type": "git", diff --git a/prettier.config.js b/prettier.config.js index b5958abb5..51f8d01be 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,17 +1,9 @@ module.exports = { printWidth: 100, - tabWidth: 2, - useTabs: false, semi: true, vueIndentScriptAndStyle: true, singleQuote: true, - quoteProps: 'as-needed', - bracketSpacing: true, trailingComma: 'all', - jsxSingleQuote: false, - arrowParens: 'always', - insertPragma: false, - requirePragma: false, proseWrap: 'never', htmlWhitespaceSensitivity: 'strict', endOfLine: 'auto', diff --git a/src/App.vue b/src/App.vue index f8df489e3..f4fab182c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,6 +12,7 @@ import { useTitle } from '/@/hooks/web/useTitle'; import { useLocale } from '/@/locales/useLocale'; + import 'dayjs/locale/zh-cn'; // support Multi-language const { getAntdLocale } = useLocale(); diff --git a/src/api/demo/account.ts b/src/api/demo/account.ts index 53537d14c..2a368138c 100644 --- a/src/api/demo/account.ts +++ b/src/api/demo/account.ts @@ -4,6 +4,7 @@ import { GetAccountInfoModel } from './model/accountModel'; enum Api { ACCOUNT_INFO = '/account/getAccountInfo', SESSION_TIMEOUT = '/user/sessionTimeout', + TOKEN_EXPIRED = '/user/tokenExpired', } // Get personal center-basic settings @@ -11,3 +12,5 @@ enum Api { export const accountInfoApi = () => defHttp.get({ url: Api.ACCOUNT_INFO }); export const sessionTimeoutApi = () => defHttp.post({ url: Api.SESSION_TIMEOUT }); + +export const tokenExpiredApi = () => defHttp.post({ url: Api.TOKEN_EXPIRED }); diff --git a/src/api/demo/cascader.ts b/src/api/demo/cascader.ts new file mode 100644 index 000000000..83dcab07c --- /dev/null +++ b/src/api/demo/cascader.ts @@ -0,0 +1,9 @@ +import { defHttp } from '/@/utils/http/axios'; +import { AreaModel, AreaParams } from '/@/api/demo/model/areaModel'; + +enum Api { + AREA_RECORD = '/cascader/getAreaRecord', +} + +export const areaRecord = (data: AreaParams) => + defHttp.post({ url: Api.AREA_RECORD, data }); diff --git a/src/api/demo/model/areaModel.ts b/src/api/demo/model/areaModel.ts new file mode 100644 index 000000000..dfaa481bf --- /dev/null +++ b/src/api/demo/model/areaModel.ts @@ -0,0 +1,12 @@ +export interface AreaModel { + id: string; + code: string; + parentCode: string; + name: string; + levelType: number; + [key: string]: string | number; +} + +export interface AreaParams { + parentCode: string; +} diff --git a/src/api/demo/table.ts b/src/api/demo/table.ts index 6a5dcee7b..b9b60df64 100644 --- a/src/api/demo/table.ts +++ b/src/api/demo/table.ts @@ -14,6 +14,7 @@ export const demoListApi = (params: DemoParams) => url: Api.DEMO_LIST, params, headers: { + // @ts-ignore ignoreCancelToken: true, }, }); diff --git a/src/api/model/baseModel.ts b/src/api/model/baseModel.ts index 913f2ec84..1a3651182 100644 --- a/src/api/model/baseModel.ts +++ b/src/api/model/baseModel.ts @@ -3,7 +3,7 @@ export interface BasicPageParams { pageSize: number; } -export interface BasicFetchResult { +export interface BasicFetchResult { items: T[]; total: number; } diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts index 1e883b6dd..f30d14f08 100644 --- a/src/api/sys/user.ts +++ b/src/api/sys/user.ts @@ -8,6 +8,7 @@ enum Api { Logout = '/logout', GetUserInfo = '/getUserInfo', GetPermCode = '/getPermCode', + TestRetry = '/testRetry', } /** @@ -39,3 +40,16 @@ export function getPermCode() { export function doLogout() { return defHttp.get({ url: Api.Logout }); } + +export function testRetry() { + return defHttp.get( + { url: Api.TestRetry }, + { + retryRequest: { + isOpenRetry: true, + count: 5, + waitTime: 1000, + }, + }, + ); +} diff --git a/src/components/Application/src/AppDarkModeToggle.vue b/src/components/Application/src/AppDarkModeToggle.vue index 6df9c499d..19ba3b151 100644 --- a/src/components/Application/src/AppDarkModeToggle.vue +++ b/src/components/Application/src/AppDarkModeToggle.vue @@ -39,7 +39,7 @@ html[data-theme='dark'] { .@{prefix-cls} { - border: 1px solid rgb(196, 188, 188); + border: 1px solid rgb(196 188 188); } } diff --git a/src/components/Application/src/AppLocalePicker.vue b/src/components/Application/src/AppLocalePicker.vue index 3d40a53b7..f71b81280 100644 --- a/src/components/Application/src/AppLocalePicker.vue +++ b/src/components/Application/src/AppLocalePicker.vue @@ -4,11 +4,11 @@ -->