From 679c204b0f5898450e9ab12bf05b47b7d159372e Mon Sep 17 00:00:00 2001 From: Aisen60 Date: Tue, 14 May 2024 19:20:21 +0800 Subject: [PATCH] feat: 0.2.3 --- package.json | 7 ++- pnpm-lock.yaml | 21 ++++--- src/icons/build/multiple-config.cjs | 11 ++++ src/icons/build/multiple.js | 3 + .../{svgo.cjs => build/single-config.cjs} | 0 src/icons/build/single.js | 3 + src/icons/build/utils.js | 51 +++++++++++++++++ src/icons/draft/multiple/.gitkeep | 0 src/icons/draft/single/.gitkeep | 0 src/icons/svg/nav-auto.svg | 1 + src/icons/svg/nav-dark.svg | 2 +- src/icons/svg/nav-light.svg | 2 +- src/layout/index.vue | 8 ++- src/stores/modules/app.ts | 17 ++++-- src/types/app.ts | 4 +- src/utils/request.ts | 2 +- src/views/info.vue | 2 +- src/views/theme.vue | 55 ++++++++++++++----- types/components.d.ts | 3 + 19 files changed, 151 insertions(+), 41 deletions(-) create mode 100644 src/icons/build/multiple-config.cjs create mode 100644 src/icons/build/multiple.js rename src/icons/{svgo.cjs => build/single-config.cjs} (100%) create mode 100644 src/icons/build/single.js create mode 100644 src/icons/build/utils.js create mode 100644 src/icons/draft/multiple/.gitkeep create mode 100644 src/icons/draft/single/.gitkeep create mode 100644 src/icons/svg/nav-auto.svg diff --git a/package.json b/package.json index cc3b9c3..9a1197d 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "lint:eslint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "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/", - "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.cjs", - "svgo-color": "svgo -f src/icons/svg", + "svgo:single": "node src/icons/build/single.js", + "svgo:multiple": "node src/icons/build/multiple.js", "lint:lint-staged": "lint-staged", "prepare": "husky" }, @@ -50,7 +50,7 @@ "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.1", "umi-request": "^1.4.0", - "vant": "^4.8.7", + "vant": "^4.9.0", "vconsole": "^3.15.1", "vue": "^3.4.21", "vue-router": "^4.3.0" @@ -68,6 +68,7 @@ "autoprefixer": "^10.4.19", "eslint": "^8.49.0", "eslint-plugin-vue": "^9.17.0", + "fs-extra": "^11.2.0", "husky": "^9.0.11", "lint-staged": "^15.2.2", "npm-run-all2": "^6.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75073b2..b7c12b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,8 +30,8 @@ dependencies: specifier: ^1.4.0 version: 1.4.0 vant: - specifier: ^4.8.7 - version: 4.8.7(vue@3.4.21) + specifier: ^4.9.0 + version: 4.9.0(vue@3.4.21) vconsole: specifier: ^3.15.1 version: 3.15.1 @@ -79,6 +79,9 @@ devDependencies: eslint-plugin-vue: specifier: ^9.17.0 version: 9.23.0(eslint@8.57.0) + fs-extra: + specifier: ^11.2.0 + version: 11.2.0 husky: specifier: ^9.0.11 version: 9.0.11 @@ -1543,13 +1546,13 @@ packages: '@vue/shared': 3.4.21 vue: 3.4.21(typescript@5.4.3) - /@vue/shared@3.2.40: - resolution: {integrity: sha512-0PLQ6RUtZM0vO3teRfzGi4ltLUO5aO+kLgwh4Um3THSR03rpQWLTuRCkuO5A41ITzwdWeKdPHtSARuPkoo5pCQ==} - dev: false - /@vue/shared@3.4.21: resolution: {integrity: sha512-PuJe7vDIi6VYSinuEbUIQgMIRZGgM8e4R+G+/dQTk0X1NEdvgvvgv7m+rfmDH1gZzyA1OjjoWskvHlfRNfQf3g==} + /@vue/shared@3.4.27: + resolution: {integrity: sha512-DL3NmY2OFlqmYYrzp39yi3LDkKxa5vZVwxWdQ3rG0ekuWscHraeIbnI8t+aZK7qhYqEqWKTUdijadunb9pnrgA==} + dev: false + /@vue/tsconfig@0.5.1: resolution: {integrity: sha512-VcZK7MvpjuTPx2w6blwnwZAu5/LgBUtejFOi3pPGQFXQN5Ela03FUtd2Qtg4yWGGissVL0dr6Ro1LfOFh+PCuQ==} dev: true @@ -5694,14 +5697,14 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /vant@4.8.7(vue@3.4.21): - resolution: {integrity: sha512-puBsqVzC94niN2fFLbkpZGInE8fYK+jjoOAhQ7XAreFCn8xkxnjGpcLNoLvQSP2hUYKN7+kES1bbz/h7RHF7vQ==} + /vant@4.9.0(vue@3.4.21): + resolution: {integrity: sha512-VlT7U8KvPaHwoXxHoxCdHcz4+O2yz1Eo3kAZ2EJl6uFClTVzldfZ3nGp+tP2azVrhMetyg+CGfAH667K3Jp+6g==} peerDependencies: vue: ^3.0.0 dependencies: '@vant/popperjs': 1.3.0 '@vant/use': 1.6.0(vue@3.4.21) - '@vue/shared': 3.2.40 + '@vue/shared': 3.4.27 vue: 3.4.21(typescript@5.4.3) dev: false diff --git a/src/icons/build/multiple-config.cjs b/src/icons/build/multiple-config.cjs new file mode 100644 index 0000000..a4f1976 --- /dev/null +++ b/src/icons/build/multiple-config.cjs @@ -0,0 +1,11 @@ +// svg 压缩配置文件 +module.exports = { + plugins: [ + { + name: 'removeAttrs', + params: { + attrs: '(id|class|t|p-id|width|height)' + } + } + ] +}; diff --git a/src/icons/build/multiple.js b/src/icons/build/multiple.js new file mode 100644 index 0000000..cacfa93 --- /dev/null +++ b/src/icons/build/multiple.js @@ -0,0 +1,3 @@ +import { runMultiple } from './utils.js'; + +runMultiple(); diff --git a/src/icons/svgo.cjs b/src/icons/build/single-config.cjs similarity index 100% rename from src/icons/svgo.cjs rename to src/icons/build/single-config.cjs diff --git a/src/icons/build/single.js b/src/icons/build/single.js new file mode 100644 index 0000000..6ba8bfd --- /dev/null +++ b/src/icons/build/single.js @@ -0,0 +1,3 @@ +import { runSingle } from './utils.js'; + +runSingle(); diff --git a/src/icons/build/utils.js b/src/icons/build/utils.js new file mode 100644 index 0000000..991c554 --- /dev/null +++ b/src/icons/build/utils.js @@ -0,0 +1,51 @@ +import path from 'path'; +import { spawn } from 'child_process'; +import fs from 'fs-extra'; + +const SVG_OUTPUT = 'src/icons/svg'; + +const SINGLE_DIR = 'src/icons/draft/single'; + +const SINGLE_CONFIG = 'src/icons/build/single-config.cjs'; + +const MULTIPLE_DIR = 'src/icons/draft/multiple'; + +const MULTIPLE_CONFIG = 'src/icons/build/multiple-config.cjs'; + +const clear = (dir) => { + fs.readdir(dir) + .then((files) => { + const deletePromises = files.map((file) => { + if (file === '.gitkeep') return; + return fs.unlink(path.join(dir, file)); + }); + return Promise.all(deletePromises); + }) + .catch((err) => console.error(err)); +}; + +export const runSingle = () => { + const cmd = spawn('npx', [`svgo -f ${SINGLE_DIR} -o ${SVG_OUTPUT} --config=${SINGLE_CONFIG}`], { + stdio: 'inherit', + shell: true + }); + + cmd.on('close', () => { + clear(SINGLE_DIR); + }); +}; + +export const runMultiple = () => { + const cmd = spawn( + 'npx', + [`svgo -f ${MULTIPLE_DIR} -o ${SVG_OUTPUT} --config=${MULTIPLE_CONFIG}`], + { + stdio: 'inherit', + shell: true + } + ); + + cmd.on('close', () => { + clear(MULTIPLE_DIR); + }); +}; diff --git a/src/icons/draft/multiple/.gitkeep b/src/icons/draft/multiple/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/icons/draft/single/.gitkeep b/src/icons/draft/single/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/icons/svg/nav-auto.svg b/src/icons/svg/nav-auto.svg new file mode 100644 index 0000000..64a3c24 --- /dev/null +++ b/src/icons/svg/nav-auto.svg @@ -0,0 +1 @@ + diff --git a/src/icons/svg/nav-dark.svg b/src/icons/svg/nav-dark.svg index 273cf84..ce2987e 100644 --- a/src/icons/svg/nav-dark.svg +++ b/src/icons/svg/nav-dark.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/src/icons/svg/nav-light.svg b/src/icons/svg/nav-light.svg index 2725bd8..36f600a 100644 --- a/src/icons/svg/nav-light.svg +++ b/src/icons/svg/nav-light.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/src/layout/index.vue b/src/layout/index.vue index 9aa8fe0..fe9481b 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -30,7 +30,7 @@