Skip to content

Commit

Permalink
chore: sync main for develop
Browse files Browse the repository at this point in the history
chore: sync main for develop
  • Loading branch information
timi137137 authored May 30, 2023
2 parents 9840fd4 + f3f266b commit 95039ea
Show file tree
Hide file tree
Showing 36 changed files with 173 additions and 130 deletions.
11 changes: 10 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -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'],
],
},
};
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -28,9 +28,9 @@
"pinia-plugin-persistedstate": "^3.1.0",
"qrcode.vue": "^3.3.4",
"qs": "^6.11.1",
"tdesign-icons-vue-next": "^0.1.8",
"tdesign-vue-next": "^1.2.2",
"tvision-color": "^1.5.0",
"tdesign-icons-vue-next": "^0.1.11",
"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"
Expand Down Expand Up @@ -83,12 +83,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"
]
}
}
1 change: 0 additions & 1 deletion src/config/global.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const prefix = 'tdesign-starter';
export const TOKEN_NAME = 'tdesign-starter';
14 changes: 8 additions & 6 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, TagTheme> = new Map([
['low', 'primary'],
['middle', 'warning'],
['high', 'danger'],
]);

// 通用请求头
export enum ContentTypeEnum {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useChart = (domId: string): Ref<echarts.ECharts> => {
* @returns
*/
export const useCounter = (duration = 60): [Ref<number>, () => void] => {
let intervalTimer;
let intervalTimer: ReturnType<typeof setInterval>;
onUnmounted(() => {
clearInterval(intervalTimer);
});
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const changeCollapsed = () => {
});
};
const handleNav = (url) => {
const handleNav = (url: string) => {
router.push(url);
};
Expand Down
15 changes: 8 additions & 7 deletions src/layouts/components/LayoutContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}"
>
Expand Down Expand Up @@ -70,12 +70,13 @@
</template>

<script setup lang="ts">
import type { PopupVisibleChangeContext } from 'tdesign-vue-next';
import { computed, nextTick, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { prefix } from '@/config/global';
import { useSettingStore, useTabsRouterStore } from '@/store';
import type { TRouterInfo } from '@/types/interface';
import type { TRouterInfo, TTabRemoveOptions } from '@/types/interface';
import LBreadcrumb from './Breadcrumb.vue';
import LContent from './Content.vue';
Expand All @@ -95,12 +96,12 @@ const handleChangeCurrentTab = (path: string) => {
router.push({ path, query: route.query });
};
const handleRemove = ({ value: path, index }) => {
const handleRemove = (options: TTabRemoveOptions) => {
const { tabRouters } = tabsRouterStore;
const nextRouter = tabRouters[index + 1] || tabRouters[index - 1];
const nextRouter = tabRouters[options.index + 1] || tabRouters[options.index - 1];
tabsRouterStore.subtractCurrentTabRouter({ path, routeIdx: index });
if (path === route.path) router.push({ path: nextRouter.path, query: nextRouter.query });
tabsRouterStore.subtractCurrentTabRouter({ path: options.value as string, routeIdx: options.index });
if ((options.value as string) === route.path) router.push({ path: nextRouter.path, query: nextRouter.query });
};
const handleRefresh = (route: TRouterInfo, routeIdx: number) => {
Expand Down Expand Up @@ -147,7 +148,7 @@ const handleOperationEffect = (type: 'other' | 'ahead' | 'behind', routeIndex: n
activeTabPath.value = null;
};
const handleTabMenuClick = (visible: boolean, ctx, path: string) => {
const handleTabMenuClick = (visible: boolean, ctx: PopupVisibleChangeContext, path: string) => {
if (ctx.trigger === 'document') activeTabPath.value = null;
if (visible) activeTabPath.value = path;
};
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/components/LayoutSideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { computed } from 'vue';
import { useRoute } from 'vue-router';
import { usePermissionStore, useSettingStore } from '@/store';
import type { MenuRoute } from '@/types/interface';
import LSideNav from './SideNav.vue';
Expand All @@ -26,7 +27,7 @@ const { routers: menuRouters } = storeToRefs(permissionStore);
const sideMenu = computed(() => {
const { layout, splitMenu } = settingStore;
let newMenuRouters = menuRouters.value;
let newMenuRouters = menuRouters.value as Array<MenuRoute>;
if (layout === 'mix' && splitMenu) {
newMenuRouters.forEach((menu) => {
if (route.path.indexOf(menu.path) === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const initStyleConfig = () => {
const styleConfig = STYLE_CONFIG;
for (const key in styleConfig) {
if (Object.prototype.hasOwnProperty.call(styleConfig, key)) {
styleConfig[key] = settingStore[key];
(styleConfig[key as keyof typeof STYLE_CONFIG] as any) = settingStore[key as keyof typeof STYLE_CONFIG];
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/dashboard/base/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dayjs from 'dayjs';
import { EChartsOption } from 'echarts';

import { TChartColor } from '@/config/color';
import { getRandomArray } from '@/utils/charts';
Expand Down Expand Up @@ -307,7 +308,7 @@ export function getPieChartDataSet({
textColor,
placeholderColor,
containerColor,
}: { radius?: number } & Record<string, string>) {
}: { radius?: number } & Record<string, string>): EChartsOption {
return {
color: getChartListColor(),
tooltip: {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/detail/advanced/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/detail/advanced/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/detail/deploy/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions src/pages/detail/deploy/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ onMounted(() => {
dataChart.setOption(get2ColBarChartDataSet({ ...chartColors.value }));
});
const intervalTimer = null;
/// / chartSize update
const updateContainer = () => {
monitorChart.resize({
Expand All @@ -163,7 +161,6 @@ const updateContainer = () => {
onUnmounted(() => {
window.removeEventListener('resize', updateContainer);
clearInterval(intervalTimer);
});
const onAlertChange = () => {
Expand All @@ -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 = () => {
Expand All @@ -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);
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/detail/secondary/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<t-list v-if="msgDataList.length > 0" class="secondary-msg-list" :split="true">
<t-list-item v-for="(item, index) in msgDataList" :key="index">
<p :class="['content', { unread: item.status }]" @click="setReadStatus(item)">
<t-tag size="medium" :theme="NOTIFICATION_TYPES[item.quality]" variant="light">
<t-tag size="medium" :theme="NOTIFICATION_TYPES.get(item.quality)" variant="light">
{{ item.type }}
</t-tag>
{{ item.content }}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/form/base/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormRule } from 'tdesign-vue-next';
import type { FormRule, UploadFile } from 'tdesign-vue-next';

export const FORM_RULES: Record<string, FormRule[]> = {
name: [{ required: true, message: '请输入合同名称', type: 'error' }],
Expand All @@ -23,7 +23,7 @@ export const INITIAL_DATA = {
payment: '1',
amount: 0,
comment: '',
files: [],
files: [] as Array<UploadFile>,
};

export const TYPE_OPTIONS = [
Expand Down
13 changes: 7 additions & 6 deletions src/pages/form/base/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default {
</script>

<script setup lang="ts">
import type { SubmitContext, UploadFailContext, UploadFile } from 'tdesign-vue-next';
import { MessagePlugin } from 'tdesign-vue-next';
import { ref } from 'vue';
Expand All @@ -174,12 +175,12 @@ const formData = ref({ ...INITIAL_DATA });
const onReset = () => {
MessagePlugin.warning('取消新建');
};
const onSubmit = ({ validateResult }) => {
if (validateResult === true) {
const onSubmit = (ctx: SubmitContext) => {
if (ctx.validateResult === true) {
MessagePlugin.success('新建成功');
}
};
const beforeUpload = (file) => {
const beforeUpload = (file: UploadFile) => {
if (!/\.(pdf)$/.test(file.name)) {
MessagePlugin.warning('请上传pdf文件');
return false;
Expand All @@ -190,11 +191,11 @@ const beforeUpload = (file) => {
}
return true;
};
const handleFail = ({ file }) => {
MessagePlugin.error(`文件 ${file.name} 上传失败`);
const handleFail = (options: UploadFailContext) => {
MessagePlugin.error(`文件 ${options.file.name} 上传失败`);
};
// 用于格式化接口响应值,error 会被用于上传失败的提示文字;url 表示文件/图片地址
const formatResponse = (res) => {
const formatResponse = (res: any) => {
return { ...res, error: '上传失败,请重试', url: res.url };
};
</script>
Expand Down
Loading

0 comments on commit 95039ea

Please sign in to comment.