diff --git a/.stylelintignore b/.stylelintignore deleted file mode 100644 index 2da3b89..0000000 --- a/.stylelintignore +++ /dev/null @@ -1,5 +0,0 @@ -.vscode -.idea -dist -public -node_modules diff --git a/.stylelintrc.js b/.stylelintrc.js deleted file mode 100644 index a3f3b63..0000000 --- a/.stylelintrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@config/lint/stylelint') diff --git a/configs/lint/package.json b/configs/lint/package.json index 6944d56..7ce4401 100644 --- a/configs/lint/package.json +++ b/configs/lint/package.json @@ -42,12 +42,6 @@ "postcss-less": "^6.0.0", "prettier": "^3.2.5", "pretty-quick": "^4.0.0", - "stylelint": "^16.2.1", - "stylelint-config-prettier": "^9.0.3", - "stylelint-config-recommended": "^14.0.0", - "stylelint-config-recommended-vue": "^1.5.0", - "stylelint-config-standard": "^36.0.0", - "stylelint-order": "^6.0.4", "vue-eslint-parser": "^9.4.2" } } diff --git a/package.json b/package.json index 19d32b0..48c6e45 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "preinstall": "npx only-allow pnpm", "lint:eslint": "turbo lint:eslint", "lint:prettier": "turbo lint:prettier", - "lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\"", "lint:lint-staged": "turbo lint:eslint lint:prettier & pnpm run lint:prettier", "prepare": "husky install" }, diff --git a/packages/apps/admin/package.json b/packages/apps/admin/package.json index 9109691..cd9fc5a 100644 --- a/packages/apps/admin/package.json +++ b/packages/apps/admin/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "dependencies": { diff --git a/packages/apps/admin/src/store/modules/tabs.ts b/packages/apps/admin/src/store/modules/tabs.ts index 330b5c8..fdf43c1 100644 --- a/packages/apps/admin/src/store/modules/tabs.ts +++ b/packages/apps/admin/src/store/modules/tabs.ts @@ -31,8 +31,8 @@ export const useTabsStore = defineStore({ this.tabsList = tabsList }, addTab(route: RouteItem): boolean { - const { path, fullPath, params, query, meta } = route - if (whiteList.includes(route.name)) return false + const { path, fullPath, query, meta } = route + if (whiteList.includes(route.name || '')) return false let updateIndex = -1 // 如果该选项卡已经存在,则执行更新操作 const tabHasExits = this.tabsList.some((tab, index) => { @@ -46,7 +46,6 @@ export const useTabsStore = defineStore({ if (!curTab) { return false } - curTab.params = params || curTab.params curTab.query = query || curTab.query curTab.fullPath = fullPath || curTab.fullPath this.tabsList.splice(updateIndex, 1, curTab) @@ -64,7 +63,7 @@ export const useTabsStore = defineStore({ this.tabsList.filter((e) => e.meta?.realPath ?? '' === realPath).length >= dynamicLevel ) { // 关闭第一个 - const index = this.tabsList.findIndex((item) => item.meta.realPath === realPath) + const index = this.tabsList.findIndex((item) => item?.meta?.realPath === realPath) index !== -1 && this.tabsList.splice(index, 1) } } diff --git a/packages/apps/admin/src/views/layouts/default/header/breadcrumb/index.vue b/packages/apps/admin/src/views/layouts/default/header/breadcrumb/index.vue index 30e2468..6c9de81 100644 --- a/packages/apps/admin/src/views/layouts/default/header/breadcrumb/index.vue +++ b/packages/apps/admin/src/views/layouts/default/header/breadcrumb/index.vue @@ -55,7 +55,7 @@ if (menu.children && menu.children.length > 0) { menuItem = menu.children[0] } - setUrl({ path: menuItem.path, name: menuItem?.module }) + setUrl({ path: menuItem.path, name: menuItem?.meta?.module }) } diff --git a/packages/apps/micro-docs/package.json b/packages/apps/micro-docs/package.json index b53b234..7c41f27 100644 --- a/packages/apps/micro-docs/package.json +++ b/packages/apps/micro-docs/package.json @@ -7,7 +7,7 @@ "dev": "vite --port 8681", "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "dependencies": { diff --git a/packages/apps/micro-react/package.json b/packages/apps/micro-react/package.json index 02ddba7..f22a061 100644 --- a/packages/apps/micro-react/package.json +++ b/packages/apps/micro-react/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "rspack serve", "build": "rspack build", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "dependencies": { diff --git a/packages/cli/create/package.json b/packages/cli/create/package.json index 98ec454..41ad1c3 100644 --- a/packages/cli/create/package.json +++ b/packages/cli/create/package.json @@ -22,7 +22,7 @@ "start": "node ./bin/index.mjs", "build": "unbuild", "test": "vitest", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "license": "ISC", diff --git a/packages/cli/template/package.json b/packages/cli/template/package.json index 961d7c4..5cc6c7c 100644 --- a/packages/cli/template/package.json +++ b/packages/cli/template/package.json @@ -2,7 +2,7 @@ "name": "@tingcli/template", "version": "0.0.2", "scripts": { - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "publishConfig": { diff --git a/packages/cli/utils/package.json b/packages/cli/utils/package.json index 0a18da0..b59c2c5 100644 --- a/packages/cli/utils/package.json +++ b/packages/cli/utils/package.json @@ -15,7 +15,7 @@ "scripts": { "build": "unbuild", "up": "npm publish", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "keywords": [], diff --git a/packages/lib/request/package.json b/packages/lib/request/package.json index a0c12f7..dcf7478 100644 --- a/packages/lib/request/package.json +++ b/packages/lib/request/package.json @@ -5,7 +5,7 @@ "main": "index.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "keywords": [], diff --git a/packages/lib/system/package.json b/packages/lib/system/package.json index 7b014ff..7b341df 100644 --- a/packages/lib/system/package.json +++ b/packages/lib/system/package.json @@ -41,7 +41,7 @@ "build": "unbuild", "dev": "unbuild", "up": "npm publish", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "keywords": [], diff --git a/packages/lib/system/src/api/apiSystem.ts b/packages/lib/system/src/api/apiSystem.ts index ae6032e..65c0a04 100644 --- a/packages/lib/system/src/api/apiSystem.ts +++ b/packages/lib/system/src/api/apiSystem.ts @@ -7,6 +7,8 @@ export interface IMeta { affix?: boolean icon?: string module?: string + dynamicLevel?: number + realPath?: string } export interface IMenu { diff --git a/packages/lib/utils/package.json b/packages/lib/utils/package.json index 6345213..8e8f7cd 100644 --- a/packages/lib/utils/package.json +++ b/packages/lib/utils/package.json @@ -16,7 +16,7 @@ "build": "unbuild", "dev": "unbuild", "up": "npm publish", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "keywords": [], diff --git a/packages/lib/utils/src/log.ts b/packages/lib/utils/src/log.ts index 9bb06b4..4abd416 100644 --- a/packages/lib/utils/src/log.ts +++ b/packages/lib/utils/src/log.ts @@ -3,158 +3,159 @@ type ColorHex = `#${string}` type Color = ColorPreset | ColorHex interface TableOptions { - headerBackground?: Color - headerColor?: Color - rowEvenBackground?: Color - rowOddBackground?: Color - textColor?: Color + headerBackground?: Color + headerColor?: Color + rowEvenBackground?: Color + rowOddBackground?: Color + textColor?: Color } interface PrettierLog { - log: (title: string, content?: string, color?: Color) => void - info: (textOrTitle: string, content?: string) => void - success: (textOrTitle: string, content?: string) => void - warning: (textOrTitle: string, content?: string) => void - error: (textOrTitle: string, content?: string) => void - table: >(data: T[], options?: TableOptions) => void - picture: (url: string, scale?: number) => Promise + log: (title: string, content?: string, color?: Color) => void + info: (textOrTitle: string, content?: string) => void + success: (textOrTitle: string, content?: string) => void + warning: (textOrTitle: string, content?: string) => void + error: (textOrTitle: string, content?: string) => void + table: >(data: T[], options?: TableOptions) => void + picture: (url: string, scale?: number) => Promise } export const warn = (message: string) => { - console.warn(`[admin warn]:${message}`) + console.warn(`[admin warn]:${message}`) } export const error = (message: string): never => { - throw new Error(`[admin error]:${message}`) + throw new Error(`[admin error]:${message}`) } const createPrettierLog = (): PrettierLog => { - - const colorMap: Record = { - info: '#909399', - success: '#67C23A', - warning: '#E6A23C', - error: '#F56C6C' - } - - const isEmpty = (value: unknown): boolean => value === null || value === undefined || value === '' - - const prettyPrint = (title: string, content: string, color: Color) => { - const hexColor = colorMap[color as ColorPreset] || color - console.log( - `%c ${title} %c ${content} %c`, - `background:${hexColor};border:1px solid ${hexColor}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`, - `border:1px solid ${hexColor}; padding: 1px; border-radius: 0 2px 2px 0; color: ${hexColor};`, - 'background:transparent' - ) - } - - const createLogFunction = (defaultTitle: string, defaultColor: Color) => - (textOrTitle: string, content = '', color: Color = defaultColor) => { - const title = isEmpty(content) ? defaultTitle : textOrTitle - const text = isEmpty(content) ? textOrTitle : content - prettyPrint(title, text, color) - } - - const log = (title: string, content = '', color: Color = 'info') => { - prettyPrint(title, content, color) + const colorMap: Record = { + info: '#909399', + success: '#67C23A', + warning: '#E6A23C', + error: '#F56C6C' + } + + const isEmpty = (value: unknown): boolean => value === null || value === undefined || value === '' + + const prettyPrint = (title: string, content: string, color: Color) => { + const hexColor = colorMap[color as ColorPreset] || color + console.log( + `%c ${title} %c ${content} %c`, + `background:${hexColor};border:1px solid ${hexColor}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`, + `border:1px solid ${hexColor}; padding: 1px; border-radius: 0 2px 2px 0; color: ${hexColor};`, + 'background:transparent' + ) + } + + const createLogFunction = + (defaultTitle: string, defaultColor: Color) => + (textOrTitle: string, content = '', color: Color = defaultColor) => { + const title = isEmpty(content) ? defaultTitle : textOrTitle + const text = isEmpty(content) ? textOrTitle : content + prettyPrint(title, text, color) } - const info = createLogFunction('Info', 'info') + const log = (title: string, content = '', color: Color = 'info') => { + prettyPrint(title, content, color) + } - const success = createLogFunction('Success', 'success') + const info = createLogFunction('Info', 'info') - const warning = createLogFunction('Warning', 'warning') + const success = createLogFunction('Success', 'success') - const error = createLogFunction('Error', 'error') + const warning = createLogFunction('Warning', 'warning') + const error = createLogFunction('Error', 'error') - const table = >(data: T[], options: Partial = {}) => { - if (!Array.isArray(data) || data.length === 0) { - console.log('No data available') - return - } - - const { - headerBackground = '#555555', - headerColor = '#ffffff', - rowEvenBackground = '#f2f2f2', - rowOddBackground = '#ffffff', - textColor = '#000000' - } = options - - const headers = Object.keys(data[0]) - const colWidths = headers.map((header) => - Math.max(header.length, ...data.map((row) => String(row[header]).length)) - ) - const headerStyle = `background: ${headerBackground}; color: ${headerColor}; font-weight: bold; padding: 5px;` - const rowStyles = data.map( - (_, index) => - `background: ${index % 2 === 0 ? rowEvenBackground : rowOddBackground}; color: ${textColor}; padding: 5px;` - ) - - const formatRow = (row: string[], style: string) => - console.log( - row.map((cell, i) => `%c${cell.padEnd(colWidths[i])}`).join(' | '), - ...row.map(() => style) - ) - - formatRow(headers, headerStyle) - - data.forEach((row, index) => { - formatRow( - headers.map((header) => String(row[header])), - rowStyles[index] - ) - }) + const table = >( + data: T[], + options: Partial = {} + ) => { + if (!Array.isArray(data) || data.length === 0) { + console.log('No data available') + return } - - const picture = (url: string, scale: number = 1): Promise => { - return new Promise((resolve, reject) => { - const image = new Image() - image.crossOrigin = 'anonymous'; - image.onload = () => { - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - if (ctx) { - canvas.width = image.width; - canvas.height = image.height; - ctx.drawImage(image, 0, 0); - const dataUri = canvas.toDataURL('image/png'); - - console.log( - '%c ', - ` + const { + headerBackground = '#555555', + headerColor = '#ffffff', + rowEvenBackground = '#f2f2f2', + rowOddBackground = '#ffffff', + textColor = '#000000' + } = options + + const headers = Object.keys(data[0]) + const colWidths = headers.map((header) => + Math.max(header.length, ...data.map((row) => String(row[header]).length)) + ) + const headerStyle = `background: ${headerBackground}; color: ${headerColor}; font-weight: bold; padding: 5px;` + const rowStyles = data.map( + (_, index) => + `background: ${index % 2 === 0 ? rowEvenBackground : rowOddBackground}; color: ${textColor}; padding: 5px;` + ) + + const formatRow = (row: string[], style: string) => + console.log( + row.map((cell, i) => `%c${cell.padEnd(colWidths[i])}`).join(' | '), + ...row.map(() => style) + ) + + formatRow(headers, headerStyle) + + data.forEach((row, index) => { + formatRow( + headers.map((header) => String(row[header])), + rowStyles[index] + ) + }) + } + + const picture = (url: string, scale: number = 1): Promise => { + return new Promise((resolve, reject) => { + const image = new Image() + image.crossOrigin = 'anonymous' + image.onload = () => { + const canvas = document.createElement('canvas') + const ctx = canvas.getContext('2d') + if (ctx) { + canvas.width = image.width + canvas.height = image.height + ctx.drawImage(image, 0, 0) + const dataUri = canvas.toDataURL('image/png') + + console.log( + '%c ', + ` font-size: 1px; padding: ${Math.floor((image.height * scale) / 2)}px ${Math.floor( - (image.width * scale) / 2 - )}px; + (image.width * scale) / 2 + )}px; background-image: url(${dataUri}); background-size: ${image.width * scale}px ${image.height * scale}px; background-repeat: no-repeat; color: transparent; ` - ) - resolve() - } else { - reject(new Error('Failed to get canvas context')) - } - } - image.onerror = () => reject(new Error('Failed to load image')) - image.src = url - }) - } - - return { - log, - info, - success, - warning, - error, - table, - picture, - } + ) + resolve() + } else { + reject(new Error('Failed to get canvas context')) + } + } + image.onerror = () => reject(new Error('Failed to load image')) + image.src = url + }) + } + + return { + log, + info, + success, + warning, + error, + table, + picture + } } -export default createPrettierLog \ No newline at end of file +export default createPrettierLog diff --git a/packages/lib/vue/package.json b/packages/lib/vue/package.json index 890f4e1..7b193d2 100644 --- a/packages/lib/vue/package.json +++ b/packages/lib/vue/package.json @@ -8,7 +8,7 @@ "scripts": { "build": "vite build", "dev": "vite build", - "lint:eslint": "eslint . --cache --max-warnings 0 --fix", + "lint:eslint": "eslint . --cache --max-warnings 0 --fix --ignore-path=../../../.eslintignore", "lint:prettier": "prettier --write --cache --ignore-unknown --ignore-path=../../../.prettierignore ." }, "files": [