diff --git a/.eslintrc.js b/.eslintrc.js index 9aa3e10c..0c11dd05 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -73,4 +73,4 @@ module.exports = { ], 'vue/multi-word-component-names': 'off', }, -}; +} diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100644 index 6dd9be63..00000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# shellcheck source=./_/husky.sh -. "$(dirname "$0")/_/husky.sh" - -# npx --no-install commitlint --edit "$1" diff --git a/.husky/common.sh b/.husky/common.sh deleted file mode 100644 index 9d5129bd..00000000 --- a/.husky/common.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -command_exists () { - command -v "$1" >/dev/null 2>&1 -} - -# Workaround for Windows 10, Git Bash and Yarn -if command_exists winpty && test -t 1; then - exec < /dev/tty -fi diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 35f92427..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" -. "$(dirname "$0")/common.sh" - -[ -n "$CI" ] && exit 0 - -# Format and submit code according to lintstagedrc.js configuration -npm run lint:lint-staged diff --git a/build/config/themeConfig.ts b/build/config/themeConfig.ts index c816b6de..1778905b 100644 --- a/build/config/themeConfig.ts +++ b/build/config/themeConfig.ts @@ -1,33 +1,33 @@ -import { generate } from '@ant-design/colors'; +import { generate } from '@ant-design/colors' -export const primaryColor = '#0960bd'; +export const primaryColor = '#0960bd' -export const darkMode = 'light'; +export const darkMode = 'light' -type Fn = (...arg: any) => any; +type Fn = (...arg: any) => any -type GenerateTheme = 'default' | 'dark'; +type GenerateTheme = 'default' | 'dark' export interface GenerateColorsParams { - mixLighten: Fn; - mixDarken: Fn; - tinycolor: any; - color?: string; + mixLighten: Fn + mixDarken: Fn + tinycolor: any + color?: string } export function generateAntColors(color: string, theme: GenerateTheme = 'default') { return generate(color, { theme, - }); + }) } export function getThemeColors(color?: string) { - const tc = color || primaryColor; - const lightColors = generateAntColors(tc); - const primary = lightColors[5]; - const modeColors = generateAntColors(primary, 'dark'); + const tc = color || primaryColor + const lightColors = generateAntColors(tc) + const primary = lightColors[5] + const modeColors = generateAntColors(primary, 'dark') - return [...lightColors, ...modeColors]; + return [...lightColors, ...modeColors] } export function generateColors({ @@ -36,38 +36,38 @@ export function generateColors({ mixDarken, tinycolor, }: GenerateColorsParams) { - const arr = new Array(19).fill(0); + const arr = new Array(19).fill(0) const lightens = arr.map((_t, i) => { - return mixLighten(color, i / 5); - }); + return mixLighten(color, i / 5) + }) const darkens = arr.map((_t, i) => { - return mixDarken(color, i / 5); - }); + return mixDarken(color, i / 5) + }) const alphaColors = arr.map((_t, i) => { return tinycolor(color) .setAlpha(i / 20) - .toRgbString(); - }); + .toRgbString() + }) - const shortAlphaColors = alphaColors.map((item) => item.replace(/\s/g, '').replace(/0\./g, '.')); + const shortAlphaColors = alphaColors.map((item) => item.replace(/\s/g, '').replace(/0\./g, '.')) const tinycolorLightens = arr .map((_t, i) => { return tinycolor(color) .lighten(i * 5) - .toHexString(); + .toHexString() }) - .filter((item) => item !== '#ffffff'); + .filter((item) => item !== '#ffffff') const tinycolorDarkens = arr .map((_t, i) => { return tinycolor(color) .darken(i * 5) - .toHexString(); + .toHexString() }) - .filter((item) => item !== '#000000'); + .filter((item) => item !== '#000000') return [ ...lightens, ...darkens, @@ -75,5 +75,5 @@ export function generateColors({ ...shortAlphaColors, ...tinycolorDarkens, ...tinycolorLightens, - ].filter((item) => !item.includes('-')); + ].filter((item) => !item.includes('-')) } diff --git a/build/generate/icon/index.ts b/build/generate/icon/index.ts index b01fec4c..511ac70d 100644 --- a/build/generate/icon/index.ts +++ b/build/generate/icon/index.ts @@ -1,20 +1,20 @@ -import path from 'path'; -import fs from 'fs-extra'; -import inquirer from 'inquirer'; -import colors from 'picocolors'; -import pkg from '../../../package.json'; +import path from 'path' +import fs from 'fs-extra' +import inquirer from 'inquirer' +import colors from 'picocolors' +import pkg from '../../../package.json' async function generateIcon() { - const dir = path.resolve(process.cwd(), 'node_modules/@iconify/json'); + const dir = path.resolve(process.cwd(), 'node_modules/@iconify/json') - const raw = await fs.readJSON(path.join(dir, 'collections.json')); + const raw = await fs.readJSON(path.join(dir, 'collections.json')) const collections = Object.entries(raw).map(([id, v]) => ({ ...(v as any), id, - })); + })) - const choices = collections.map((item) => ({ key: item.id, value: item.id, name: item.name })); + const choices = collections.map((item) => ({ key: item.id, value: item.id, name: item.name })) inquirer .prompt([ @@ -41,32 +41,32 @@ async function generateIcon() { }, ]) .then(async (answers) => { - const { iconSet, output, useType } = answers; - const outputDir = path.resolve(process.cwd(), output); - fs.ensureDir(outputDir); - const genCollections = collections.filter((item) => [iconSet].includes(item.id)); - const prefixSet: string[] = []; + const { iconSet, output, useType } = answers + const outputDir = path.resolve(process.cwd(), output) + fs.ensureDir(outputDir) + const genCollections = collections.filter((item) => [iconSet].includes(item.id)) + const prefixSet: string[] = [] for (const info of genCollections) { - const data = await fs.readJSON(path.join(dir, 'json', `${info.id}.json`)); + const data = await fs.readJSON(path.join(dir, 'json', `${info.id}.json`)) if (data) { - const { prefix } = data; - const isLocal = useType === 'local'; + const { prefix } = data + const isLocal = useType === 'local' const icons = Object.keys(data.icons).map( (item) => `${isLocal ? prefix + ':' : ''}${item}`, - ); + ) await fs.writeFileSync( path.join(output, `icons.data.ts`), `export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`, - ); - prefixSet.push(prefix); + ) + prefixSet.push(prefix) } } - fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite')); + fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite')) console.log( `✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`, - ); - }); + ) + }) } -generateIcon(); +generateIcon() diff --git a/build/script/buildConf.ts b/build/script/buildConf.ts index 0c8089cc..73df033b 100644 --- a/build/script/buildConf.ts +++ b/build/script/buildConf.ts @@ -1,47 +1,47 @@ /** * Generate additional configuration files when used for packaging. The file can be configured with some global variables, so that it can be changed directly externally without repackaging */ -import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant'; -import fs, { writeFileSync } from 'fs-extra'; -import colors from 'picocolors'; +import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant' +import fs, { writeFileSync } from 'fs-extra' +import colors from 'picocolors' -import { getEnvConfig, getRootPath } from '../utils'; -import { getConfigFileName } from '../getConfigFileName'; +import { getEnvConfig, getRootPath } from '../utils' +import { getConfigFileName } from '../getConfigFileName' -import pkg from '../../package.json'; +import pkg from '../../package.json' interface CreateConfigParams { - configName: string; - config: any; - configFileName?: string; + configName: string + config: any + configFileName?: string } function createConfig(params: CreateConfigParams) { - const { configName, config, configFileName } = params; + const { configName, config, configFileName } = params try { - const windowConf = `window.${configName}`; + const windowConf = `window.${configName}` // Ensure that the variable will not be modified - let configStr = `${windowConf}=${JSON.stringify(config)};`; + let configStr = `${windowConf}=${JSON.stringify(config)};` configStr += ` Object.freeze(${windowConf}); Object.defineProperty(window, "${configName}", { configurable: false, writable: false, }); - `.replace(/\s/g, ''); + `.replace(/\s/g, '') - fs.mkdirp(getRootPath(OUTPUT_DIR)); - writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr); + fs.mkdirp(getRootPath(OUTPUT_DIR)) + writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr) - console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`); - console.log(colors.gray(OUTPUT_DIR + '/' + colors.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(colors.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, configFileName: GLOB_CONFIG_FILE_NAME }); + const config = getEnvConfig() + const configFileName = getConfigFileName(config) + createConfig({ config, configName: configFileName, configFileName: GLOB_CONFIG_FILE_NAME }) } diff --git a/build/script/postBuild.ts b/build/script/postBuild.ts index 42635d88..bbe05ed1 100644 --- a/build/script/postBuild.ts +++ b/build/script/postBuild.ts @@ -1,23 +1,23 @@ // #!/usr/bin/env node -import { runBuildConfig } from './buildConf'; -import colors from 'picocolors'; +import { runBuildConfig } from './buildConf' +import colors from 'picocolors' -import pkg from '../../package.json'; +import pkg from '../../package.json' export const runBuild = async () => { try { - const argvList = process.argv.splice(2); + const argvList = process.argv.splice(2) // Generate configuration file if (!argvList.includes('disabled-config')) { - runBuildConfig(); + runBuildConfig() } - console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!'); + console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!') } catch (error) { - console.log(colors.red('vite build error:\n' + error)); - process.exit(1); + console.log(colors.red('vite build error:\n' + error)) + process.exit(1) } -}; -runBuild(); +} +runBuild() diff --git a/build/vite/plugin/compress.ts b/build/vite/plugin/compress.ts index ff4f6311..c04fa343 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 { PluginOption } from 'vite'; -import compressPlugin from 'vite-plugin-compression'; +import type { PluginOption } from 'vite' +import compressPlugin from 'vite-plugin-compression' export function configCompressPlugin( compress: 'gzip' | 'brotli' | 'none', deleteOriginFile = false, ): PluginOption | PluginOption[] { - const compressList = compress.split(','); + const compressList = compress.split(',') - const plugins: PluginOption[] = []; + const plugins: PluginOption[] = [] if (compressList.includes('gzip')) { plugins.push( @@ -19,7 +19,7 @@ export function configCompressPlugin( ext: '.gz', deleteOriginFile, }), - ); + ) } if (compressList.includes('brotli')) { @@ -29,7 +29,7 @@ export function configCompressPlugin( algorithm: 'brotliCompress', deleteOriginFile, }), - ); + ) } - return plugins; + return plugins } diff --git a/build/vite/plugin/html.ts b/build/vite/plugin/html.ts index 6af034ac..4f2bb89d 100644 --- a/build/vite/plugin/html.ts +++ b/build/vite/plugin/html.ts @@ -2,19 +2,19 @@ * Plugin to minimize and use ejs template syntax in index.html. * https://github.com/anncwb/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'; +import type { PluginOption } from 'vite' +import { createHtmlPlugin } from 'vite-plugin-html' +import pkg from '../../../package.json' +import { GLOB_CONFIG_FILE_NAME } from '../../constant' export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { - const { VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH } = env; + const { VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH } = env - const path = VITE_PUBLIC_PATH.endsWith('/') ? VITE_PUBLIC_PATH : `${VITE_PUBLIC_PATH}/`; + const path = VITE_PUBLIC_PATH.endsWith('/') ? VITE_PUBLIC_PATH : `${VITE_PUBLIC_PATH}/` const getAppConfigSrc = () => { - return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`; - }; + return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}` + } const htmlPlugin: PluginOption[] = createHtmlPlugin({ minify: isBuild, @@ -35,6 +35,6 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { ] : [], }, - }); - return htmlPlugin; + }) + return htmlPlugin } diff --git a/build/vite/plugin/svgSprite.ts b/build/vite/plugin/svgSprite.ts index 61f637f4..64453a42 100644 --- a/build/vite/plugin/svgSprite.ts +++ b/build/vite/plugin/svgSprite.ts @@ -3,8 +3,8 @@ * https://github.com/anncwb/vite-plugin-svg-icons */ -import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; -import path from 'path'; +import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' +import path from 'path' export function configSvgIconsPlugin(isBuild: boolean) { const svgIconsPlugin = createSvgIconsPlugin({ @@ -12,6 +12,6 @@ export function configSvgIconsPlugin(isBuild: boolean) { svgoOptions: isBuild, // default symbolId: 'icon-[dir]-[name]', - }); - return svgIconsPlugin; + }) + return svgIconsPlugin } diff --git a/build/vite/plugin/theme.ts b/build/vite/plugin/theme.ts index 118983f7..187ff9b3 100644 --- a/build/vite/plugin/theme.ts +++ b/build/vite/plugin/theme.ts @@ -2,46 +2,46 @@ * Vite plugin for website theme color switching * https://github.com/anncwb/vite-plugin-theme */ -import type { PluginOption } from 'vite'; -import path from 'path'; +import type { PluginOption } from 'vite' +import path from 'path' import { viteThemePlugin, antdDarkThemePlugin, mixLighten, mixDarken, tinycolor, -} from 'vite-plugin-theme'; -import { getThemeColors, generateColors } from '../../config/themeConfig'; -import { generateModifyVars } from '../../generate/generateModifyVars'; +} from 'vite-plugin-theme' +import { getThemeColors, generateColors } from '../../config/themeConfig' +import { generateModifyVars } from '../../generate/generateModifyVars' export function configThemePlugin(isBuild: boolean): PluginOption[] { const colors = generateColors({ mixDarken, mixLighten, tinycolor, - }); + }) const plugin = [ viteThemePlugin({ resolveSelector: (s) => { - s = s.trim(); + s = s.trim() switch (s) { case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon': - return '.ant-steps-item-icon > .ant-steps-icon'; + return '.ant-steps-item-icon > .ant-steps-icon' case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled)': case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover': case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):active': - return s; + return s case '.ant-steps-item-icon > .ant-steps-icon': - return s; + return s case '.ant-select-item-option-selected:not(.ant-select-item-option-disabled)': - return s; + return s default: if (s.indexOf('.ant-btn') >= -1) { // 按钮被重新定制过,需要过滤掉class防止覆盖 - return s; + return s } } - return s.startsWith('[data-theme') ? s : `[data-theme] ${s}`; + return s.startsWith('[data-theme') ? s : `[data-theme] ${s}` }, colorVariables: [...getThemeColors(), ...colors], }), @@ -83,7 +83,7 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] { 'alert-error-icon-color': '#a61d24', }, }), - ]; + ] - return plugin as unknown as PluginOption[]; + return plugin as unknown as PluginOption[] } diff --git a/src/components/Application/src/AppLocalePicker.vue b/src/components/Application/src/AppLocalePicker.vue index f71b8128..9204d634 100644 --- a/src/components/Application/src/AppLocalePicker.vue +++ b/src/components/Application/src/AppLocalePicker.vue @@ -18,13 +18,13 @@ diff --git a/src/components/Container/src/collapse/CollapseContainer.vue b/src/components/Container/src/collapse/CollapseContainer.vue index d60d5193..754f3c54 100644 --- a/src/components/Container/src/collapse/CollapseContainer.vue +++ b/src/components/Container/src/collapse/CollapseContainer.vue @@ -23,17 +23,17 @@