diff --git a/apps/antd-view/src/router/index.ts b/apps/antd-view/src/router/index.ts index dd9fd63f..7f309daf 100644 --- a/apps/antd-view/src/router/index.ts +++ b/apps/antd-view/src/router/index.ts @@ -36,7 +36,7 @@ function resetRoutes() { // 这些路由需要指定 name,防止在路由重置时,不能删除没有指定 name 的路由 if (import.meta.env.DEV && !route.name) { console.warn( - `The route with the path ${route.path} needs to specify the field name.`, + `The route with the path ${route.path} needs to have the field name specified.`, ); } return route.name; diff --git a/internal/node-utils/src/index.ts b/internal/node-utils/src/index.ts index 55b05c11..dad62297 100644 --- a/internal/node-utils/src/index.ts +++ b/internal/node-utils/src/index.ts @@ -9,6 +9,7 @@ export { getPackages, getPackagesSync, } from './monorepo'; +export { toPosixPath } from './path'; export { prettierFormat } from './prettier'; export type { Package } from '@manypkg/get-packages'; export { consola } from 'consola'; diff --git a/internal/node-utils/src/path.test.ts b/internal/node-utils/src/path.test.ts new file mode 100644 index 00000000..4b550b4f --- /dev/null +++ b/internal/node-utils/src/path.test.ts @@ -0,0 +1,67 @@ +// pathUtils.test.ts + +import { describe, expect, it } from 'vitest'; + +import { toPosixPath } from './path'; + +describe('toPosixPath', () => { + // 测试 Windows 风格路径到 POSIX 风格路径的转换 + it('converts Windows-style paths to POSIX paths', () => { + const windowsPath = String.raw`C:\Users\Example\file.txt`; + const expectedPosixPath = 'C:/Users/Example/file.txt'; + expect(toPosixPath(windowsPath)).toBe(expectedPosixPath); + }); + + // 确认 POSIX 风格路径不会被改变 + it('leaves POSIX-style paths unchanged', () => { + const posixPath = '/home/user/file.txt'; + expect(toPosixPath(posixPath)).toBe(posixPath); + }); + + // 测试带有多个分隔符的路径 + it('converts paths with mixed separators', () => { + const mixedPath = String.raw`C:/Users\Example\file.txt`; + const expectedPosixPath = 'C:/Users/Example/file.txt'; + expect(toPosixPath(mixedPath)).toBe(expectedPosixPath); + }); + + // 测试空字符串 + it('handles empty strings', () => { + const emptyPath = ''; + expect(toPosixPath(emptyPath)).toBe(''); + }); + + // 测试仅包含分隔符的路径 + it('handles path with only separators', () => { + const separatorsPath = '\\\\\\'; + const expectedPosixPath = '///'; + expect(toPosixPath(separatorsPath)).toBe(expectedPosixPath); + }); + + // 测试不包含任何分隔符的路径 + it('handles path without separators', () => { + const noSeparatorPath = 'file.txt'; + expect(toPosixPath(noSeparatorPath)).toBe('file.txt'); + }); + + // 测试以分隔符结尾的路径 + it('handles path ending with a separator', () => { + const endingSeparatorPath = 'C:\\Users\\Example\\'; + const expectedPosixPath = 'C:/Users/Example/'; + expect(toPosixPath(endingSeparatorPath)).toBe(expectedPosixPath); + }); + + // 测试以分隔符开头的路径 + it('handles path starting with a separator', () => { + const startingSeparatorPath = String.raw`\Users\Example`; + const expectedPosixPath = '/Users/Example'; + expect(toPosixPath(startingSeparatorPath)).toBe(expectedPosixPath); + }); + + // 测试包含非法字符的路径 + it('handles path with invalid characters', () => { + const invalidCharsPath = String.raw`C:\Us*?ers\Ex|file.txt`; + const expectedPosixPath = 'C:/Us*?ers/Ex|file.txt'; + expect(toPosixPath(invalidCharsPath)).toBe(expectedPosixPath); + }); +}); diff --git a/internal/node-utils/src/path.ts b/internal/node-utils/src/path.ts new file mode 100644 index 00000000..e625fd2f --- /dev/null +++ b/internal/node-utils/src/path.ts @@ -0,0 +1,11 @@ +import { posix } from 'node:path'; + +/** + * 将给定的文件路径转换为 POSIX 风格。 + * @param {string} pathname - 原始文件路径。 + */ +function toPosixPath(pathname: string) { + return pathname.split(`\\`).join(posix.sep); +} + +export { toPosixPath }; diff --git a/internal/vite-config/src/plugins/importmap.ts b/internal/vite-config/src/plugins/importmap.ts index 1e3403e4..2fbf9d42 100644 --- a/internal/vite-config/src/plugins/importmap.ts +++ b/internal/vite-config/src/plugins/importmap.ts @@ -140,7 +140,7 @@ async function viteImportMapPlugin( // 未生成importmap时,抛出错误,防止被turbo缓存 if (!installed && !isSSR) { installError && console.error(installError); - throw new Error('importmap install failed.'); + throw new Error('Importmap installation failed.'); } }, enforce: 'post', diff --git a/internal/vite-config/src/utils/env.ts b/internal/vite-config/src/utils/env.ts index de9e9d81..c08c3cfc 100644 --- a/internal/vite-config/src/utils/env.ts +++ b/internal/vite-config/src/utils/env.ts @@ -36,7 +36,7 @@ export async function getEnvConfig( const env = dotenv.parse(envPath); envConfig = { ...envConfig, ...env }; } catch (error) { - console.error(`Error in parsing ${confFile}`, error); + console.error(`Error while parsing ${confFile}`, error); } } const reg = new RegExp(`^(${match})`); diff --git a/packages/@vben-core/forward/stores/src/modules/tabs.ts b/packages/@vben-core/forward/stores/src/modules/tabs.ts index 2c0d710d..01ad1884 100644 --- a/packages/@vben-core/forward/stores/src/modules/tabs.ts +++ b/packages/@vben-core/forward/stores/src/modules/tabs.ts @@ -251,7 +251,7 @@ const useTabsStore = defineStore('tabs', { this._close(currentRoute.value); await this._goToTab(before, router); } else { - console.error('关闭标签页失败,当前只剩一个标签页。'); + console.error('Failed to close the tab; only one tab remains open.'); } }, /** diff --git a/packages/locales/src/langs/zh-CN.yaml b/packages/locales/src/langs/zh-CN.yaml index 137a2a47..bd421a11 100644 --- a/packages/locales/src/langs/zh-CN.yaml +++ b/packages/locales/src/langs/zh-CN.yaml @@ -47,7 +47,7 @@ authentication: username: 账号 password: 密码 username-tip: 请输入用户名 - password-tip: 请输入用户名 + password-tip: 请输入密码 remember-me: 记住账号 create-an-account: 创建一个账号 create-account: 创建账号 diff --git a/scripts/update-dependencies b/scripts/update-dependencies old mode 100755 new mode 100644 diff --git a/scripts/vsh/src/code-workspace/index.ts b/scripts/vsh/src/code-workspace/index.ts index cd3a8d59..d89de092 100644 --- a/scripts/vsh/src/code-workspace/index.ts +++ b/scripts/vsh/src/code-workspace/index.ts @@ -10,6 +10,7 @@ import { getPackages, gitAdd, prettierFormat, + toPosixPath, } from '@vben/node-utils'; const CODE_WORKSPACE_FILE = join('vben-admin.code-workspace'); @@ -29,7 +30,7 @@ async function createCodeWorkspace({ const { dir, packageJson } = pkg; return { name: packageJson.name, - path: relative(rootDir, dir), + path: toPosixPath(relative(rootDir, dir)), }; });