diff --git a/commitlint.config.js b/commitlint.config.js index 405e185..20116c9 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,2 +1,11 @@ // commit-lint config -module.exports = { extends: ['@commitlint/config-conventional'] }; +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'type-enum': [ + 2, + 'always', + ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test', 'types'], + ], + }, +}; diff --git a/package.json b/package.json index a8fa358..f6ce0a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "tdesign-vue-next-starter", - "version": "0.7.5", + "name": "@tencent/tdesign-vue-next-starter", + "version": "0.7.6", "scripts": { "dev:mock": "vite --open --mode mock", "dev": "vite --open --mode development", @@ -28,10 +28,10 @@ "pinia-plugin-persistedstate": "^3.1.0", "qrcode.vue": "^3.3.4", "qs": "^6.11.1", - "tdesign-icons-vue-next": "^0.1.8", - "tdesign-theme-generator": "^1.0.4", - "tdesign-vue-next": "^1.3.1", - "tvision-color": "^1.5.0", + "tdesign-icons-vue-next": "^0.1.11", + "tdesign-theme-generator": "^1.0.5", + "tdesign-vue-next": "^1.3.4", + "tvision-color": "^1.6.0", "vue": "^3.2.47", "vue-clipboard3": "^2.0.0", "vue-router": "~4.1.6" @@ -84,12 +84,10 @@ "lint-staged": { "*.{js,jsx,vue,ts,tsx}": [ "prettier --write", - "npm run lint:fix", - "git add ." + "npm run lint:fix" ], "*.{html,vue,vss,sass,less}": [ - "npm run stylelint:fix", - "git add ." + "npm run stylelint:fix" ] } } diff --git a/src/config/global.ts b/src/config/global.ts index 5ea972f..67aba60 100644 --- a/src/config/global.ts +++ b/src/config/global.ts @@ -1,2 +1 @@ export const prefix = 'tdesign-starter'; -export const TOKEN_NAME = 'tdesign-starter'; diff --git a/src/constants/index.ts b/src/constants/index.ts index 7c822ce..4438b88 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -34,12 +34,14 @@ export const CONTRACT_PAYMENT_TYPES = { RECEIPT: 1, }; -// 通知的优先级对应的TAG类型 -export const NOTIFICATION_TYPES = { - low: 'primary', - middle: 'warning', - high: 'danger', -}; +// 标签类型 +type TagTheme = 'default' | 'success' | 'primary' | 'warning' | 'danger'; +// 通知的优先级对应的标签类型 +export const NOTIFICATION_TYPES: Map = new Map([ + ['low', 'primary'], + ['middle', 'warning'], + ['high', 'danger'], +]); // 通用请求头 export enum ContentTypeEnum { diff --git a/src/hooks/index.ts b/src/hooks/index.ts index fe47d70..3c26653 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -39,7 +39,7 @@ export const useChart = (domId: string): Ref => { * @returns */ export const useCounter = (duration = 60): [Ref, () => void] => { - let intervalTimer; + let intervalTimer: ReturnType; onUnmounted(() => { clearInterval(intervalTimer); }); diff --git a/src/layouts/components/Header.vue b/src/layouts/components/Header.vue index 85b85de..777cc75 100644 --- a/src/layouts/components/Header.vue +++ b/src/layouts/components/Header.vue @@ -130,7 +130,7 @@ const changeCollapsed = () => { }); }; -const handleNav = (url) => { +const handleNav = (url: string) => { router.push(url); }; diff --git a/src/layouts/components/LayoutContent.vue b/src/layouts/components/LayoutContent.vue index 32c1c57..c0bf5ad 100644 --- a/src/layouts/components/LayoutContent.vue +++ b/src/layouts/components/LayoutContent.vue @@ -24,7 +24,7 @@ :min-column-width="128" :popup-props="{ overlayClassName: 'route-tabs-dropdown', - onVisibleChange: (visible, ctx) => handleTabMenuClick(visible, ctx, routeItem.path), + onVisibleChange: (visible: boolean, ctx: PopupVisibleChangeContext) => handleTabMenuClick(visible, ctx, routeItem.path), visible: activeTabPath === routeItem.path, }" > @@ -70,12 +70,13 @@ + + + diff --git a/src/pages/dashboard/base/index.ts b/src/pages/dashboard/base/index.ts index c9b2394..b75351f 100644 --- a/src/pages/dashboard/base/index.ts +++ b/src/pages/dashboard/base/index.ts @@ -1,4 +1,5 @@ import dayjs from 'dayjs'; +import { EChartsOption } from 'echarts'; import { TChartColor } from '@/config/color'; import { getRandomArray } from '@/utils/charts'; @@ -307,7 +308,7 @@ export function getPieChartDataSet({ textColor, placeholderColor, containerColor, -}: { radius?: number } & Record) { +}: { radius?: number } & Record): EChartsOption { return { color: getChartListColor(), tooltip: { diff --git a/src/pages/detail/advanced/constants.ts b/src/pages/detail/advanced/constants.ts index c8bb0fb..bc810b9 100644 --- a/src/pages/detail/advanced/constants.ts +++ b/src/pages/detail/advanced/constants.ts @@ -83,14 +83,14 @@ export const TABLE_COLUMNS_DATA = [ ellipsis: true, colKey: 'index', title: '申请号', - sorter: (a, b) => a.index.substr(3) - b.index.substr(3), + sorter: (a: any, b: any) => a.index.substr(3) - b.index.substr(3), }, { width: 200, ellipsis: true, colKey: 'pdName', title: '产品名称', - sorter: (a, b) => a.pdName.length - b.pdName.length, + sorter: (a: any, b: any) => a.pdName.length - b.pdName.length, }, { width: 200, @@ -103,7 +103,7 @@ export const TABLE_COLUMNS_DATA = [ ellipsis: true, colKey: 'purchaseNum', title: '采购数量', - sorter: (a, b) => a.purchaseNum - b.purchaseNum, + sorter: (a: any, b: any) => a.purchaseNum - b.purchaseNum, }, { width: 160, @@ -116,7 +116,7 @@ export const TABLE_COLUMNS_DATA = [ ellipsis: true, colKey: 'updateTime', title: '创建时间', - sorter: (a, b) => Date.parse(a.updateTime) - Date.parse(b.updateTime), + sorter: (a: any, b: any) => Date.parse(a.updateTime) - Date.parse(b.updateTime), }, { align: 'left' as const, diff --git a/src/pages/detail/advanced/index.vue b/src/pages/detail/advanced/index.vue index 50bc4b7..2e2d9f3 100644 --- a/src/pages/detail/advanced/index.vue +++ b/src/pages/detail/advanced/index.vue @@ -170,16 +170,16 @@ onMounted(() => { }); const visible = ref(false); -const sortChange = (val) => { +const sortChange = (val: unknown) => { console.log(val); }; -const rehandleChange = (changeParams, triggerAndData) => { +const rehandleChange = (changeParams: unknown, triggerAndData: unknown) => { console.log('统一Change', changeParams, triggerAndData); }; const listClick = () => { visible.value = true; }; -const deleteClickOp = (columns) => { +const deleteClickOp = (columns: { rowIndex: number }) => { data.value.splice(columns.rowIndex, 1); }; const onConfirm = () => { diff --git a/src/pages/detail/deploy/constants.ts b/src/pages/detail/deploy/constants.ts index 7dd3a1f..18ea0c5 100644 --- a/src/pages/detail/deploy/constants.ts +++ b/src/pages/detail/deploy/constants.ts @@ -87,7 +87,7 @@ export const TABLE_COLUMNS = [ ellipsis: true, colKey: 'name', title: '项目名称', - sorter: (a, b) => a.name.substr(10) - b.name.substr(10), + sorter: (a: any, b: any) => a.name.substr(10) - b.name.substr(10), }, { width: '280', @@ -101,7 +101,7 @@ export const TABLE_COLUMNS = [ ellipsis: true, colKey: 'updateTime', title: '创建时间', - sorter: (a, b) => Date.parse(a.updateTime) - Date.parse(b.updateTime), + sorter: (a: any, b: any) => Date.parse(a.updateTime) - Date.parse(b.updateTime), }, { align: 'left' as const, diff --git a/src/pages/detail/deploy/index.vue b/src/pages/detail/deploy/index.vue index 33878bb..1fa50ce 100644 --- a/src/pages/detail/deploy/index.vue +++ b/src/pages/detail/deploy/index.vue @@ -147,8 +147,6 @@ onMounted(() => { dataChart.setOption(get2ColBarChartDataSet({ ...chartColors.value })); }); -const intervalTimer = null; - /// / chartSize update const updateContainer = () => { monitorChart.resize({ @@ -163,7 +161,6 @@ const updateContainer = () => { onUnmounted(() => { window.removeEventListener('resize', updateContainer); - clearInterval(intervalTimer); }); const onAlertChange = () => { @@ -182,10 +179,10 @@ watch( }, ); -const sortChange = (val) => { +const sortChange = (val: unknown) => { console.log(val); }; -const rehandleChange = (changeParams, triggerAndData) => { +const rehandleChange = (changeParams: unknown, triggerAndData: unknown) => { console.log('统一Change', changeParams, triggerAndData); }; const listClick = () => { @@ -194,7 +191,7 @@ const listClick = () => { const onConfirm = () => { visible.value = false; }; -const deleteClickOp = (e) => { +const deleteClickOp = (e: { rowIndex: number }) => { data.value.splice(e.rowIndex, 1); }; diff --git a/src/pages/detail/secondary/index.vue b/src/pages/detail/secondary/index.vue index cde49dc..04b336f 100644 --- a/src/pages/detail/secondary/index.vue +++ b/src/pages/detail/secondary/index.vue @@ -6,7 +6,7 @@

- + {{ item.type }} {{ item.content }} diff --git a/src/pages/form/base/constants.ts b/src/pages/form/base/constants.ts index e321b9d..e8503a0 100644 --- a/src/pages/form/base/constants.ts +++ b/src/pages/form/base/constants.ts @@ -1,4 +1,4 @@ -import { FormRule } from 'tdesign-vue-next'; +import type { FormRule, UploadFile } from 'tdesign-vue-next'; export const FORM_RULES: Record = { name: [{ required: true, message: '请输入合同名称', type: 'error' }], @@ -23,7 +23,7 @@ export const INITIAL_DATA = { payment: '1', amount: 0, comment: '', - files: [], + files: [] as Array, }; export const TYPE_OPTIONS = [ diff --git a/src/pages/form/base/index.vue b/src/pages/form/base/index.vue index 267fdd2..514876d 100644 --- a/src/pages/form/base/index.vue +++ b/src/pages/form/base/index.vue @@ -164,6 +164,7 @@ export default { diff --git a/src/pages/form/step/index.vue b/src/pages/form/step/index.vue index 7d446be..0f0736a 100644 --- a/src/pages/form/step/index.vue +++ b/src/pages/form/step/index.vue @@ -29,7 +29,7 @@ :data="formData1" :rules="FORM_RULES" label-align="right" - @submit="(result) => onSubmit(result, 1)" + @submit="(result: SubmitContext) => onSubmit(result, 1)" > @@ -59,7 +59,7 @@ :rules="FORM_RULES" label-align="left" @reset="onReset(0)" - @submit="(result) => onSubmit(result, 2)" + @submit="(result: SubmitContext) => onSubmit(result, 2)" > @@ -96,7 +96,7 @@ :rules="FORM_RULES" label-align="left" @reset="onReset(1)" - @submit="(result) => onSubmit(result, 6)" + @submit="(result: SubmitContext) => onSubmit(result, 6)" > @@ -147,7 +147,7 @@ export default { diff --git a/src/pages/list/components/CommonTable.vue b/src/pages/list/components/CommonTable.vue index 0323863..8df81d0 100644 --- a/src/pages/list/components/CommonTable.vue +++ b/src/pages/list/components/CommonTable.vue @@ -122,7 +122,7 @@ import { useSettingStore } from '@/store'; const store = useSettingStore(); -const COLUMNS: PrimaryTableCol[] = [ +const COLUMNS: PrimaryTableCol[] = [ { title: '合同名称', fixed: 'left', @@ -167,8 +167,8 @@ const COLUMNS: PrimaryTableCol[] = [ const searchForm = { name: '', - no: undefined, - status: undefined, + no: '', + status: typeof CONTRACT_STATUS, type: '', }; @@ -233,24 +233,24 @@ onMounted(() => { fetchData(); }); -const handleClickDelete = ({ row }) => { - deleteIdx.value = row.rowIndex; +const handleClickDelete = (slot: { row: { rowIndex: number } }) => { + deleteIdx.value = slot.row.rowIndex; confirmVisible.value = true; }; -const onReset = (val) => { +const onReset = (val: unknown) => { console.log(val); }; -const onSubmit = (val) => { +const onSubmit = (val: unknown) => { console.log(val); }; const rehandlePageChange = (pageInfo: PageInfo, newDataSource: TableRowData[]) => { console.log('分页变化', pageInfo, newDataSource); }; -const rehandleChange = (changeParams, triggerAndData) => { +const rehandleChange = (changeParams: unknown, triggerAndData: unknown) => { console.log('统一Change', changeParams, triggerAndData); }; -const rehandleClickOp = ({ text, row }) => { - console.log(text, row); +const rehandleClickOp = (ctx: unknown) => { + console.log(ctx); }; const headerAffixedTop = computed( diff --git a/src/pages/list/tree/index.vue b/src/pages/list/tree/index.vue index 7101634..16b73c0 100644 --- a/src/pages/list/tree/index.vue +++ b/src/pages/list/tree/index.vue @@ -24,6 +24,7 @@ export default { diff --git a/src/pages/login/components/Login.vue b/src/pages/login/components/Login.vue index 24ba884..43339c7 100644 --- a/src/pages/login/components/Login.vue +++ b/src/pages/login/components/Login.vue @@ -80,7 +80,7 @@