diff --git a/CHANGELOG.md b/CHANGELOG.md index a9bbb96d..e2544fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,44 @@ # Changelog +## [v1.3.0](https://github.com/soybeanjs/soybean-admin/compare/v1.2.8...v1.3.0) (2024-07-22) + +###    🚨 Breaking Changes + +- **projects**: refactor global menu & support `reversed-horizontal-mix-menu`. close #365  -  by @honghuangdc in https://github.com/soybeanjs/soybean-admin/issues/365 [(087e5)](https://github.com/soybeanjs/soybean-admin/commit/087e532) + +###    🚀 Features + +- **packages**: + - `@sa/scripts`: command `gitCommit` support chinese  -  by @mmdapl in https://github.com/soybeanjs/soybean-admin/issues/548 [(06971)](https://github.com/soybeanjs/soybean-admin/commit/06971f3) + - @sa/axios: replace CancelTokenSource by AbortController. close #530, close #532  -  by @honghuangdc in https://github.com/soybeanjs/soybean-admin/issues/530 and https://github.com/soybeanjs/soybean-admin/issues/532 [(527fd)](https://github.com/soybeanjs/soybean-admin/commit/527fd79) + - @sa/scripts: add ignore pattern list for command `gitCommitVerify`. close #504  -  by @honghuangdc in https://github.com/soybeanjs/soybean-admin/issues/504 [(958d0)](https://github.com/soybeanjs/soybean-admin/commit/958d0ba) +- **projects**: + - make branch `main` tiny & modify request retry times to 0  -  by @Azir-11 [(793b1)](https://github.com/soybeanjs/soybean-admin/commit/793b16e) + +###    🐞 Bug Fixes + +- **hooks**: prevent program freezing when pagesize returns 0  -  by @Azir-11 in https://github.com/soybeanjs/soybean-admin/issues/545 [(f4eeb)](https://github.com/soybeanjs/soybean-admin/commit/f4eeb2e) + +###    💅 Refactors + +- **projects**: + - combine `theme tokens` and `theme settings`. close #379  -  by @honghuangdc in https://github.com/soybeanjs/soybean-admin/issues/379 [(1d1b1)](https://github.com/soybeanjs/soybean-admin/commit/1d1b148) + - change css vars mount to root  -  by @honghuangdc [(00f41)](https://github.com/soybeanjs/soybean-admin/commit/00f41dd) + +###    📖 Documentation + +- **projects**: update CHANGELOG  -  by @honghuangdc [(a0b76)](https://github.com/soybeanjs/soybean-admin/commit/a0b76da) + +###    🏡 Chore + +- **deps**: update deps  -  by @honghuangdc [(f6bd6)](https://github.com/soybeanjs/soybean-admin/commit/f6bd6b8) +- **projects**: add script `czh`  -  by @honghuangdc [(02069)](https://github.com/soybeanjs/soybean-admin/commit/0206969) + +###    ❤️ Contributors + +[![honghuangdc](https://github.com/honghuangdc.png?size=48)](https://github.com/honghuangdc)  [![mmdapl](https://github.com/mmdapl.png?size=48)](https://github.com/mmdapl)  [![Azir-11](https://github.com/Azir-11.png?size=48)](https://github.com/Azir-11)   + ## [v1.2.8](https://github.com/soybeanjs/soybean-admin/compare/v1.2.7...v1.2.8) (2024-07-20) ###    🐞 Bug Fixes diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 0c669085..4d141b4a 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -1,6 +1,73 @@ # 更新日志 +## [v1.3.0](https://github.com/soybeanjs/soybean-admin/compare/v1.2.8...v1.3.0) (2024-07-22) + +###    🚨 破坏性变更 + +- **项目**: 重构全局菜单 & 支持 `reversed-horizontal-mix-menu`。关闭 #365  -  由 @honghuangdc 在 https://github.com/soybeanjs/soybean-admin/issues/365 提出 [(087e5)](https://github.com/soybeanjs/soybean-admin/commit/087e532) + +###    🚀 功能 + +- **包**: + - `@sa/scripts`: 命令 `gitCommit` 支持中文  -  由 @mmdapl 在 https://github.com/soybeanjs/soybean-admin/issues/548 提出 [(06971)](https://github.com/soybeanjs/soybean-admin/commit/06971f3) + - @sa/axios: 用 AbortController 替换 CancelTokenSource。关闭 #530, 关闭 #532  -  由 @honghuangdc 在 https://github.com/soybeanjs/soybean-admin/issues/530 和 https://github.com/soybeanjs/soybean-admin/issues/532 提出 [(527fd)](https://github.com/soybeanjs/soybean-admin/commit/527fd79) + - @sa/scripts: 为命令 `gitCommitVerify` 添加忽略模式列表。关闭 #504  -  由 @honghuangdc 在 https://github.com/soybeanjs/soybean-admin/issues/504 提出 [(958d0)](https://github.com/soybeanjs/soybean-admin/commit/958d0ba) +- **项目**: + - 使分支 `main` 更精简 & 修改请求重试次数为 0  -  由 @Azir-11 提出 [(793b1)](https://github.com/soybeanjs/soybean-admin/commit/793b16e) + +###    🐞 修复 + +- **钩子**: 当 pagesize 返回 0 时防止程序冻结  -  由 @Azir-11 在 https://github.com/soybeanjs/soybean-admin/issues/545 提出 [(f4eeb)](https://github.com/soybeanjs/soybean-admin/commit/f4eeb2e) + +###    💅 重构 + +- **项目**: + - 合并 `theme tokens` 和 `theme settings`。关闭 #379  -  由 @honghuangdc 在 https://github.com/soybeanjs/soybean-admin/issues/379 提出 [(1d1b1)](https://github.com/soybeanjs/soybean-admin/commit/1d1b148) + - 将 css 变量挂载到 root  -  由 @honghuangdc 提出 [(00f41)](https://github.com/soybeanjs/soybean-admin/commit/00f41dd) + +###    📖 文档 + +- **项目**: 更新更新日志  -  由 @honghuangdc 提出 [(a0b76)](https://github.com/soybeanjs/soybean-admin/commit/a0b76da) + +###    🏡 杂务 + +- **依赖**: 更新依赖  -  由 @honghuangdc 提出 [(f6bd6)](https://github.com/soybeanjs/soybean-admin/commit/f6bd6b8) +- **项目**: 添加脚本 `czh`  -  由 @honghuangdc 提出 [(02069)](https://github.com/soybeanjs/soybean-admin/commit/0206969) + +###    ❤️ 贡献者 + +[![honghuangdc](https://github.com/honghuangdc.png?size=48)](https://github.com/honghuangdc)  [![mmdapl](https://github.com/mmdapl.png?size=48)](https://github.com/mmdapl)  [![Azir-11](https://github.com/Azir-11.png?size=48)](https://github.com/Azir-11)   + + +## [v1.2.8](https://github.com/soybeanjs/soybean-admin/compare/v1.2.7...v1.2.8) (2024-07-20) + +###    🐞 修复 + +- **包**: + - @sa/hooks: 修复 useHookTable 的 searchParams。修复了 #552  -  由 @honghuangdc 在 https://github.com/soybeanjs/soybean-admin/issues/552 提出 [(96c10)](https://github.com/soybeanjs/soybean-admin/commit/96c1044) +- **类型**: + - 修复了引用类型错误  -  由 **dodu2014** 在 https://github.com/soybeanjs/soybean-admin/issues/551 提出 [(3e2a9)](https://github.com/soybeanjs/soybean-admin/commit/3e2a993) + - 修复 useHookTable 的数据类型  -  由 @honghuangdc 提出 [(276ea)](https://github.com/soybeanjs/soybean-admin/commit/276ea7f) + +###    💅 重构 + +- **项目**: 用 `klona` 替换 `lodash-es` 的 `cloneDeep`  -  由 @honghuangdc 提出 [(a9133)](https://github.com/soybeanjs/soybean-admin/commit/a91335d) + +###    📖 文档 + +- **项目**: 更新更新日志  -  由 @honghuangdc 提出 [(58fc0)](https://github.com/soybeanjs/soybean-admin/commit/58fc096) + +###    🏡 杂务 + +- **依赖**: 更新依赖  -  由 @honghuangdc 提出 [(cf019)](https://github.com/soybeanjs/soybean-admin/commit/cf0192a) + +###    ❤️ 贡献者 + +[![honghuangdc](https://github.com/honghuangdc.png?size=48)](https://github.com/honghuangdc)   +[dodu2014](mailto:dodu@live.cn) + + ## [v1.2.7](https://github.com/honghuangdc/soybean-admin/compare/v1.2.6...v1.2.7) (2024-07-12) ###    🛠 优化 diff --git a/package.json b/package.json index 18a6dacf..4d0707a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "soybean-admin", "type": "module", - "version": "1.2.8", + "version": "1.3.0", "description": "A fresh and elegant admin template, based on Vue3、Vite3、TypeScript、NaiveUI and UnoCSS. 一个基于Vue3、Vite3、TypeScript、NaiveUI and UnoCSS的清新优雅的中后台模版。", "author": { "name": "Soybean", @@ -35,6 +35,7 @@ "build:test": "vite build --mode test", "cleanup": "sa cleanup", "commit": "sa git-commit", + "czh": "sa git-commit -l=zh-cn", "dev": "vite --mode test", "dev:prod": "vite --mode prod", "gen-route": "sa gen-route", diff --git a/packages/axios/package.json b/packages/axios/package.json index 2d38a342..ccc1bbd6 100644 --- a/packages/axios/package.json +++ b/packages/axios/package.json @@ -1,6 +1,6 @@ { "name": "@sa/axios", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/axios/src/index.ts b/packages/axios/src/index.ts index 08846c24..0415bc3b 100644 --- a/packages/axios/src/index.ts +++ b/packages/axios/src/index.ts @@ -1,5 +1,5 @@ import axios, { AxiosError } from 'axios'; -import type { AxiosResponse, CancelTokenSource, CreateAxiosDefaults, InternalAxiosRequestConfig } from 'axios'; +import type { AxiosResponse, CreateAxiosDefaults, InternalAxiosRequestConfig } from 'axios'; import axiosRetry from 'axios-retry'; import { nanoid } from '@sa/utils'; import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options'; @@ -22,7 +22,7 @@ function createCommonRequest( const axiosConf = createAxiosConfig(axiosConfig); const instance = axios.create(axiosConf); - const cancelTokenSourceMap = new Map(); + const abortControllerMap = new Map(); // config axios retry const retryOptions = createRetryOptions(axiosConf); @@ -35,10 +35,12 @@ function createCommonRequest( const requestId = nanoid(); config.headers.set(REQUEST_ID_KEY, requestId); - // config cancel token - const cancelTokenSource = axios.CancelToken.source(); - config.cancelToken = cancelTokenSource.token; - cancelTokenSourceMap.set(requestId, cancelTokenSource); + // config abort controller + if (!config.signal) { + const abortController = new AbortController(); + config.signal = abortController.signal; + abortControllerMap.set(requestId, abortController); + } // handle config by hook const handledConfig = opts.onRequest?.(config) || config; @@ -79,18 +81,18 @@ function createCommonRequest( ); function cancelRequest(requestId: string) { - const cancelTokenSource = cancelTokenSourceMap.get(requestId); - if (cancelTokenSource) { - cancelTokenSource.cancel(); - cancelTokenSourceMap.delete(requestId); + const abortController = abortControllerMap.get(requestId); + if (abortController) { + abortController.abort(); + abortControllerMap.delete(requestId); } } function cancelAllRequest() { - cancelTokenSourceMap.forEach(cancelTokenSource => { - cancelTokenSource.cancel(); + abortControllerMap.forEach(abortController => { + abortController.abort(); }); - cancelTokenSourceMap.clear(); + abortControllerMap.clear(); } return { diff --git a/packages/axios/src/options.ts b/packages/axios/src/options.ts index ff59fa77..8b2b116a 100644 --- a/packages/axios/src/options.ts +++ b/packages/axios/src/options.ts @@ -20,7 +20,7 @@ export function createDefaultOptions(options?: Partial) { const retryConfig: IAxiosRetryConfig = { - retries: 3 + retries: 0 }; Object.assign(retryConfig, config); diff --git a/packages/axios/src/type.ts b/packages/axios/src/type.ts index 0ecbacbb..e65e9849 100644 --- a/packages/axios/src/type.ts +++ b/packages/axios/src/type.ts @@ -69,7 +69,19 @@ export type CustomAxiosRequestConfig = Omit { + /** + * cancel the request by request id + * + * if the request provide abort controller sign from config, it will not collect in the abort controller map + * + * @param requestId + */ cancelRequest: (requestId: string) => void; + /** + * cancel all request + * + * if the request provide abort controller sign from config, it will not collect in the abort controller map + */ cancelAllRequest: () => void; /** you can set custom state in the request instance */ state: T; diff --git a/packages/color/package.json b/packages/color/package.json index e2c3a3b2..77c28c4a 100644 --- a/packages/color/package.json +++ b/packages/color/package.json @@ -1,6 +1,6 @@ { "name": "@sa/color", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 5f7d0aa1..ec68a9cd 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -1,6 +1,6 @@ { "name": "@sa/hooks", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/materials/package.json b/packages/materials/package.json index 22836bc2..2bb83d37 100644 --- a/packages/materials/package.json +++ b/packages/materials/package.json @@ -1,6 +1,6 @@ { "name": "@sa/materials", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/ofetch/package.json b/packages/ofetch/package.json index 5ac29d50..59dda211 100644 --- a/packages/ofetch/package.json +++ b/packages/ofetch/package.json @@ -1,6 +1,6 @@ { "name": "@sa/fetch", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/scripts/package.json b/packages/scripts/package.json index f73b467c..a1a8c87c 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@sa/scripts", - "version": "1.2.8", + "version": "1.3.0", "bin": { "sa": "./bin.ts" }, diff --git a/packages/scripts/src/commands/git-commit.ts b/packages/scripts/src/commands/git-commit.ts index 875ea969..35c0df56 100644 --- a/packages/scripts/src/commands/git-commit.ts +++ b/packages/scripts/src/commands/git-commit.ts @@ -1,9 +1,9 @@ import path from 'node:path'; import { readFileSync } from 'node:fs'; import { prompt } from 'enquirer'; -import { bgRed, green, red, yellow } from 'kolorist'; import { execCommand } from '../shared'; -import type { CliOption } from '../types'; +import { locales } from '../locales'; +import type { Lang } from '../locales'; interface PromptObject { types: string; @@ -14,13 +14,11 @@ interface PromptObject { /** * Git commit with Conventional Commits standard * - * @param gitCommitTypes - * @param gitCommitScopes + * @param lang */ -export async function gitCommit( - gitCommitTypes: CliOption['gitCommitTypes'], - gitCommitScopes: CliOption['gitCommitScopes'] -) { +export async function gitCommit(lang: Lang = 'en-us') { + const { gitCommitMessages, gitCommitTypes, gitCommitScopes } = locales[lang]; + const typesChoices = gitCommitTypes.map(([value, msg]) => { const nameWithSuffix = `${value}:`; @@ -41,19 +39,19 @@ export async function gitCommit( { name: 'types', type: 'select', - message: 'Please select a type', + message: gitCommitMessages.types, choices: typesChoices }, { name: 'scopes', type: 'select', - message: 'Please select a scope', + message: gitCommitMessages.scopes, choices: scopesChoices }, { name: 'description', type: 'text', - message: `Please enter a description (add prefix ${yellow('!')} to indicate breaking change)` + message: gitCommitMessages.description } ]); @@ -67,20 +65,20 @@ export async function gitCommit( } /** Git commit message verify */ -export async function gitCommitVerify() { +export async function gitCommitVerify(lang: Lang = 'en-us', ignores: RegExp[] = []) { const gitPath = await execCommand('git', ['rev-parse', '--show-toplevel']); const gitMsgPath = path.join(gitPath, '.git', 'COMMIT_EDITMSG'); const commitMsg = readFileSync(gitMsgPath, 'utf8').trim(); + if (ignores.some(regExp => regExp.test(commitMsg))) return; + const REG_EXP = /(?[a-z]+)(?:\((?.+)\))?(?!)?: (?.+)/i; if (!REG_EXP.test(commitMsg)) { - throw new Error( - `${bgRed(' ERROR ')} ${red('git commit message must match the Conventional Commits standard!')}\n\n${green( - 'Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org' - )}` - ); + const errorMsg = locales[lang].gitCommitVerify; + + throw new Error(errorMsg); } } diff --git a/packages/scripts/src/config/index.ts b/packages/scripts/src/config/index.ts index 4f84e3d2..0fd9fbe7 100644 --- a/packages/scripts/src/config/index.ts +++ b/packages/scripts/src/config/index.ts @@ -12,34 +12,18 @@ const defaultOptions: CliOption = { '**/node_modules', '!node_modules/**' ], - gitCommitTypes: [ - ['feat', 'A new feature'], - ['fix', 'A bug fix'], - ['docs', 'Documentation only changes'], - ['style', 'Changes that do not affect the meaning of the code'], - ['refactor', 'A code change that neither fixes a bug nor adds a feature'], - ['perf', 'A code change that improves performance'], - ['optimize', 'A code change that optimizes code quality'], - ['test', 'Adding missing tests or correcting existing tests'], - ['build', 'Changes that affect the build system or external dependencies'], - ['ci', 'Changes to our CI configuration files and scripts'], - ['chore', "Other changes that don't modify src or test files"], - ['revert', 'Reverts a previous commit'] - ], - gitCommitScopes: [ - ['projects', 'project'], - ['packages', 'packages'], - ['components', 'components'], - ['hooks', 'hook functions'], - ['utils', 'utils functions'], - ['types', 'TS declaration'], - ['styles', 'style'], - ['deps', 'project dependencies'], - ['release', 'release project'], - ['other', 'other changes'] - ], ncuCommandArgs: ['--deep', '-u'], - changelogOptions: {} + changelogOptions: {}, + gitCommitVerifyIgnores: [ + /^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m, + /^(Merge tag (.*?))(?:\r?\n)*$/m, + /^(R|r)evert (.*)/, + /^(amend|fixup|squash)!/, + /^(Merged (.*?)(in|into) (.*)|Merged PR (.*): (.*))/, + /^Merge remote-tracking branch(\s*)(.*)/, + /^Automatic merge(.*)/, + /^Auto-merged (.*?) into (.*)/ + ] }; export async function loadCliOptions(overrides?: Partial, cwd = process.cwd()) { diff --git a/packages/scripts/src/index.ts b/packages/scripts/src/index.ts index 909dda3d..34367d79 100755 --- a/packages/scripts/src/index.ts +++ b/packages/scripts/src/index.ts @@ -3,6 +3,7 @@ import { blue, lightGreen } from 'kolorist'; import { version } from '../package.json'; import { cleanup, genChangelog, generateRoute, gitCommit, gitCommitVerify, release, updatePkg } from './commands'; import { loadCliOptions } from './config'; +import type { Lang } from './locales'; type Command = 'cleanup' | 'update-pkg' | 'git-commit' | 'git-commit-verify' | 'changelog' | 'release' | 'gen-route'; @@ -18,13 +19,19 @@ interface CommandArg { /** Generate changelog by total tags */ total?: boolean; /** - * The glob pattern of dirs to cleanup + * The glob pattern of dirs to clean up * * If not set, it will use the default value * * Multiple values use "," to separate them */ cleanupDir?: string; + /** + * display lang of cli + * + * @default 'en-us' + */ + lang?: Lang; } export async function setupCli() { @@ -44,6 +51,7 @@ export async function setupCli() { '-c, --cleanupDir ', 'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them' ) + .option('-l, --lang ', 'display lang of cli', { default: 'en-us', type: [String] }) .help(); const commands: CommandWithAction = { @@ -61,14 +69,14 @@ export async function setupCli() { }, 'git-commit': { desc: 'git commit, generate commit message which match Conventional Commits standard', - action: async () => { - await gitCommit(cliOptions.gitCommitTypes, cliOptions.gitCommitScopes); + action: async args => { + await gitCommit(args?.lang); } }, 'git-commit-verify': { desc: 'verify git commit message, make sure it match Conventional Commits standard', - action: async () => { - await gitCommitVerify(); + action: async args => { + await gitCommitVerify(args?.lang, cliOptions.gitCommitVerifyIgnores); } }, changelog: { diff --git a/packages/scripts/src/locales/index.ts b/packages/scripts/src/locales/index.ts new file mode 100644 index 00000000..8d28dd54 --- /dev/null +++ b/packages/scripts/src/locales/index.ts @@ -0,0 +1,78 @@ +import { bgRed, green, red, yellow } from 'kolorist'; + +export type Lang = 'zh-cn' | 'en-us'; + +export const locales = { + 'zh-cn': { + gitCommitMessages: { + types: '请选择提交类型', + scopes: '请选择提交范围', + description: `请输入描述信息(${yellow('!')}开头表示破坏性改动` + }, + gitCommitTypes: [ + ['feat', '新功能'], + ['fix', '修复Bug'], + ['docs', '只更新文档'], + ['style', '修改代码风格,不影响代码含义的变更'], + ['refactor', '代码重构,既不修复 bug 也不添加功能的代码变更'], + ['perf', '可提高性能的代码更改'], + ['optimize', '优化代码质量的代码更改'], + ['test', '添加缺失的测试或更正现有测'], + ['build', '影响构建系统或外部依赖项的更改'], + ['ci', '对 CI 配置文件和脚本的更改'], + ['chore', '没有修改src或测试文件的其他变更'], + ['revert', '还原先前的提交'] + ] as [string, string][], + gitCommitScopes: [ + ['projects', '项目'], + ['packages', '包'], + ['components', '组件'], + ['hooks', '钩子函数'], + ['utils', '工具函数'], + ['types', 'TS类型声明'], + ['styles', '代码风格'], + ['deps', '项目依赖'], + ['release', '发布项目新版本'], + ['other', '其他的变更'] + ] as [string, string][], + gitCommitVerify: `${bgRed(' 错误 ')} ${red('git 提交信息必须符合 Conventional Commits 标准!')}\n\n${green( + '推荐使用命令 `pnpm commit` 生成符合 Conventional Commits 标准的提交信息。\n获取有关 Conventional Commits 的更多信息,请访问此链接: https://conventionalcommits.org' + )}` + }, + 'en-us': { + gitCommitMessages: { + types: 'Please select a type', + scopes: 'Please select a scope', + description: `Please enter a description (add prefix ${yellow('!')} to indicate breaking change)` + }, + gitCommitTypes: [ + ['feat', 'A new feature'], + ['fix', 'A bug fix'], + ['docs', 'Documentation only changes'], + ['style', 'Changes that do not affect the meaning of the code'], + ['refactor', 'A code change that neither fixes a bug nor adds a feature'], + ['perf', 'A code change that improves performance'], + ['optimize', 'A code change that optimizes code quality'], + ['test', 'Adding missing tests or correcting existing tests'], + ['build', 'Changes that affect the build system or external dependencies'], + ['ci', 'Changes to our CI configuration files and scripts'], + ['chore', "Other changes that don't modify src or test files"], + ['revert', 'Reverts a previous commit'] + ] as [string, string][], + gitCommitScopes: [ + ['projects', 'project'], + ['packages', 'packages'], + ['components', 'components'], + ['hooks', 'hook functions'], + ['utils', 'utils functions'], + ['types', 'TS declaration'], + ['styles', 'style'], + ['deps', 'project dependencies'], + ['release', 'release project'], + ['other', 'other changes'] + ] as [string, string][], + gitCommitVerify: `${bgRed(' ERROR ')} ${red('git commit message must match the Conventional Commits standard!')}\n\n${green( + 'Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org' + )}` + } +} satisfies Record>; diff --git a/packages/scripts/src/types/index.ts b/packages/scripts/src/types/index.ts index 598760ef..32bc0917 100644 --- a/packages/scripts/src/types/index.ts +++ b/packages/scripts/src/types/index.ts @@ -14,10 +14,6 @@ export interface CliOption { * ``` */ cleanupDirs: string[]; - /** Git commit types */ - gitCommitTypes: [string, string][]; - /** Git commit scopes */ - gitCommitScopes: [string, string][]; /** * Npm-check-updates command args * @@ -30,4 +26,6 @@ export interface CliOption { * @link https://github.com/soybeanjs/changelog */ changelogOptions: Partial; + /** The ignore pattern list of git commit verify */ + gitCommitVerifyIgnores: RegExp[]; } diff --git a/packages/uno-preset/package.json b/packages/uno-preset/package.json index 6a184e1b..ee6ffbed 100644 --- a/packages/uno-preset/package.json +++ b/packages/uno-preset/package.json @@ -1,6 +1,6 @@ { "name": "@sa/uno-preset", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index 6a4f4fca..86b241d6 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@sa/utils", - "version": "1.2.8", + "version": "1.3.0", "exports": { ".": "./src/index.ts" }, diff --git a/src/components/common/dark-mode-container.vue b/src/components/common/dark-mode-container.vue index 70f452ff..71f27332 100644 --- a/src/components/common/dark-mode-container.vue +++ b/src/components/common/dark-mode-container.vue @@ -9,7 +9,7 @@ defineProps(); diff --git a/src/constants/app.ts b/src/constants/app.ts index ca4f9276..4948a157 100644 --- a/src/constants/app.ts +++ b/src/constants/app.ts @@ -1,5 +1,9 @@ import { transformRecordToOption } from '@/utils/common'; +export const GLOBAL_HEADER_MENU_ID = '__GLOBAL_HEADER_MENU__'; + +export const GLOBAL_SIDER_MENU_ID = '__GLOBAL_SIDER_MENU__'; + export const themeSchemaRecord: Record = { light: 'theme.themeSchema.light', dark: 'theme.themeSchema.dark', diff --git a/src/hooks/common/router.ts b/src/hooks/common/router.ts index 89374b7f..f95a25a5 100644 --- a/src/hooks/common/router.ts +++ b/src/hooks/common/router.ts @@ -30,17 +30,30 @@ export function useRouterPush(inSetup = true) { name: key }; - if (query) { + if (Object.keys(query || {}).length) { routeLocation.query = query; } - if (params) { + if (Object.keys(params || {}).length) { routeLocation.params = params; } return routerPush(routeLocation); } + function routerPushByKeyWithMetaQuery(key: RouteKey) { + const allRoutes = router.getRoutes(); + const meta = allRoutes.find(item => item.name === key)?.meta || null; + + const query: Record = {}; + + meta?.query?.forEach(item => { + query[item.key] = item.value; + }); + + return routerPushByKey(key, { query }); + } + async function toHome() { return routerPushByKey('root'); } @@ -95,6 +108,7 @@ export function useRouterPush(inSetup = true) { routerPush, routerBack, routerPushByKey, + routerPushByKeyWithMetaQuery, toLogin, toggleLoginModule, redirectFromLogin diff --git a/src/hooks/common/table.ts b/src/hooks/common/table.ts index d189060b..6619f8b3 100644 --- a/src/hooks/common/table.ts +++ b/src/hooks/common/table.ts @@ -40,17 +40,20 @@ export function useTable(config: NaiveUI.NaiveTabl transformer: res => { const { records = [], current = 1, size = 10, total = 0 } = res.data || {}; + // Ensure that the size is greater than 0, If it is less than 0, it will cause paging calculation errors. + const pageSize = size <= 0 ? 10 : size; + const recordsWithIndex = records.map((item, index) => { return { ...item, - index: (current - 1) * size + index + 1 + index: (current - 1) * pageSize + index + 1 }; }); return { data: recordsWithIndex, pageNum: current, - pageSize: size, + pageSize, total }; }, diff --git a/src/layouts/base-layout/index.vue b/src/layouts/base-layout/index.vue index 948638b0..7d00da22 100644 --- a/src/layouts/base-layout/index.vue +++ b/src/layouts/base-layout/index.vue @@ -1,5 +1,5 @@