From cd2939cd4f8b0cd26e08328a7cf596cf8d814736 Mon Sep 17 00:00:00 2001 From: yuyang Date: Tue, 18 Apr 2023 16:20:51 +0800 Subject: [PATCH 01/10] chore: card detail style (#475) --- src/main.ts | 9 +++++---- src/pages/dashboard/detail/index.vue | 19 ++++++++++++++++++- src/style/layout.less | 8 -------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main.ts b/src/main.ts index f2c8c01..5569f42 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,4 @@ -import 'tdesign-vue-next/es/style/index.css'; -import '@/style/index.less'; -import './permission'; - +/* eslint-disable simple-import-sort/imports */ import TDesign from 'tdesign-vue-next'; import { createApp } from 'vue'; @@ -9,6 +6,10 @@ import App from './App.vue'; import router from './router'; import { store } from './store'; +import 'tdesign-vue-next/es/style/index.css'; +import '@/style/index.less'; +import './permission'; + const app = createApp(App); app.use(TDesign); diff --git a/src/pages/dashboard/detail/index.vue b/src/pages/dashboard/detail/index.vue index 98e082d..fba58ef 100644 --- a/src/pages/dashboard/detail/index.vue +++ b/src/pages/dashboard/detail/index.vue @@ -37,7 +37,7 @@ v-for="(item, index) in PRODUCT_LIST" :key="index" :product="item" - :class="{ 'row-margin': index !== 0 }" + :class="{ 'row-margin': index !== 0, 'product-card': true }" /> @@ -166,6 +166,23 @@ const onMaterialChange = (value: string[]) => { margin-top: 16px; } +.product-card { + padding: var(--td-comp-paddingTB-xl) var(--td-comp-paddingTB-xl); + + :deep(.t-card__header) { + padding: 0; + } + + :deep(.t-card__body) { + padding: 0; + margin-top: var(--td-comp-margin-xxl); + margin-bottom: var(--td-comp-margin-xxl); + } + + :deep(.t-card__footer) { + padding: 0; + } +} // 统一增加8px; .dashboard-detail-card { padding: var(--td-comp-paddingTB-xxl) var(--td-comp-paddingLR-xxl); diff --git a/src/style/layout.less b/src/style/layout.less index fb4cd83..f6c305f 100644 --- a/src/style/layout.less +++ b/src/style/layout.less @@ -55,14 +55,6 @@ background: var(--td-gray-color-13); } -.t-default-menu:not(.t-menu--dark) .t-menu__item.t-is-active:not(.t-is-opened) { - background-color: var(--td-brand-color-1); - color: var(--td-brand-color); - .t-icon { - color: var(--td-brand-color); - } -} - .@{starter-prefix} { // 布局元素调整 &-wrapper { From a0c67b05d96a1f13d1e8de188a0b5680a06b8a82 Mon Sep 17 00:00:00 2001 From: WenKang Date: Wed, 19 Apr 2023 16:24:45 +0800 Subject: [PATCH 02/10] fix: update token (#476) Co-authored-by: kadenzhong --- src/pages/dashboard/base/components/OutputOverview.vue | 4 ++-- src/pages/dashboard/base/components/TopPanel.vue | 4 ++-- src/pages/dashboard/detail/index.vue | 6 +++--- src/pages/detail/advanced/components/Product.vue | 2 +- src/pages/detail/advanced/index.less | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/dashboard/base/components/OutputOverview.vue b/src/pages/dashboard/base/components/OutputOverview.vue index d342d1c..a71dac0 100644 --- a/src/pages/dashboard/base/components/OutputOverview.vue +++ b/src/pages/dashboard/base/components/OutputOverview.vue @@ -198,8 +198,8 @@ const onStokeDataChange = (checkedValues: string[]) => { &__content { &-title { - font: var(--td-font-headline-medium); - font-weight: 400; + font-size: var(--td-font-size-headline-medium); + line-height: var(--td-line-height-headline-medium); } &-footer { diff --git a/src/pages/dashboard/base/components/TopPanel.vue b/src/pages/dashboard/base/components/TopPanel.vue index 864401f..dd139c6 100644 --- a/src/pages/dashboard/base/components/TopPanel.vue +++ b/src/pages/dashboard/base/components/TopPanel.vue @@ -191,8 +191,8 @@ watch( > span { display: inline-block; color: var(--td-text-color-primary); - font: var(--td-font-headline-medium); - font-weight: 400; + font-size: var(--td-font-size-headline-medium); + line-height: var(--td-line-height-headline-medium); } } diff --git a/src/pages/dashboard/detail/index.vue b/src/pages/dashboard/detail/index.vue index fba58ef..7d28a40 100644 --- a/src/pages/dashboard/detail/index.vue +++ b/src/pages/dashboard/detail/index.vue @@ -29,7 +29,7 @@ @change="onMaterialChange" /> -
+
@@ -240,8 +240,8 @@ const onMaterialChange = (value: string[]) => { } &__number { - font: var(--td-font-headline-large); - font-weight: 400; + font-size: var(--td-font-size-headline-medium); + line-height: var(--td-font-size-headline-medium); color: var(--td-text-color-primary); margin-bottom: var(--td-comp-margin-xxl); } diff --git a/src/pages/detail/advanced/components/Product.vue b/src/pages/detail/advanced/components/Product.vue index d7128c9..c48ab97 100644 --- a/src/pages/detail/advanced/components/Product.vue +++ b/src/pages/detail/advanced/components/Product.vue @@ -65,7 +65,7 @@ export default defineComponent({ height: 240px; .operator-title-icon { - background: var(--td-brand-color-focus); + background: var(--td-brand-color-light); color: var(--td-brand-color); font-size: var(--td-comp-size-xxxl); padding: calc(var(--td-comp-size-xxxl) - var(--td-comp-size-xl)); diff --git a/src/pages/detail/advanced/index.less b/src/pages/detail/advanced/index.less index 0a6714d..9af9963 100644 --- a/src/pages/detail/advanced/index.less +++ b/src/pages/detail/advanced/index.less @@ -56,7 +56,7 @@ border-radius: var(--td-radius-medium); .product-sub-icon { - background: var(--td-brand-color-focus); + background: var(--td-brand-color-light); color: var(--td-brand-color); font-size: var(--td-comp-size-xxxl); padding: calc(var(--td-comp-size-xxxl) - var(--td-comp-size-xl)); From 0d70db425d744bc995c899f6ffaf21b4c351ce5d Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Mon, 8 May 2023 22:15:59 +0800 Subject: [PATCH 03/10] =?UTF-8?q?chore:=20=E5=85=88=E9=AA=8C=E8=AF=81token?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E8=8E=B7=E5=8F=96=E8=8F=9C=E5=8D=95=20(#487)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/permission.ts b/src/permission.ts index b22d8dc..cd82e62 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -23,6 +23,16 @@ router.beforeEach(async (to, from, next) => { next(); return; } + try { + await userStore.getUserInfo(); + } catch (error) { + MessagePlugin.error(error); + next({ + path: '/login', + query: { redirect: encodeURIComponent(to.fullPath) }, + }); + NProgress.done(); + } const { asyncRoutes } = permissionStore; @@ -42,21 +52,10 @@ router.beforeEach(async (to, from, next) => { } } - try { - await userStore.getUserInfo(); - - if (router.hasRoute(to.name)) { - next(); - } else { - next(`/`); - } - } catch (error) { - MessagePlugin.error(error); - next({ - path: '/login', - query: { redirect: encodeURIComponent(to.fullPath) }, - }); - NProgress.done(); + if (router.hasRoute(to.name)) { + next(); + } else { + next(`/`); } } else { /* white list router */ From 2794bdcb5c9784189306d883487ef49b180fd1fe Mon Sep 17 00:00:00 2001 From: "Gui.H" Date: Mon, 8 May 2023 22:16:19 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=EF=BC=8C=E8=80=8C=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E4=B8=BATencent=20(#485)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update user.ts * Update Header.vue * Update user.ts * Update user.ts --- src/layouts/components/Header.vue | 5 +++-- src/store/modules/user.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/layouts/components/Header.vue b/src/layouts/components/Header.vue index bffa0ba..c74bce7 100644 --- a/src/layouts/components/Header.vue +++ b/src/layouts/components/Header.vue @@ -48,7 +48,7 @@ - + @@ -71,7 +71,7 @@ import { useRouter } from 'vue-router'; import LogoFull from '@/assets/assets-logo-full.svg?component'; import { prefix } from '@/config/global'; import { getActive } from '@/router'; -import { useSettingStore } from '@/store'; +import { useSettingStore, useUserStore } from '@/store'; import type { MenuRoute } from '@/types/interface'; import MenuContent from './MenuContent.vue'; @@ -111,6 +111,7 @@ const props = defineProps({ const router = useRouter(); const settingStore = useSettingStore(); +const user = useUserStore(); const toggleSettingPanel = () => { settingStore.updateConfig({ diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index b1590a1..7a5fbc1 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -4,6 +4,7 @@ import { TOKEN_NAME } from '@/config/global'; import { store, usePermissionStore } from '@/store'; const InitUserInfo = { + name: '', // 用户名,用于展示在页面右上角头像处 roles: [], // 前端权限模型使用 如果使用请配置modules/permission-fe.ts使用 }; @@ -57,7 +58,7 @@ export const useUserStore = defineStore('user', { const mockRemoteUserInfo = async (token: string) => { if (token === 'main_token') { return { - name: 'td_main', + name: 'Tencent', roles: ['all'], // 前端权限模型使用 如果使用请配置modules/permission-fe.ts使用 }; } From 4bcf7d22aa13df5edb36b80538ed241f1e3efa56 Mon Sep 17 00:00:00 2001 From: yuyang Date: Wed, 10 May 2023 19:52:57 +0800 Subject: [PATCH 05/10] feat: trigger action on site branch (#493) --- .github/workflows/pull-request.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e456b38..280a82f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,15 +1,14 @@ -# 文件名建议统一为 pull-request.yml +# 文件名建议统一为 pull-request.yml # 应用 test-build.yml 的 demo name: MAIN_PULL_REQUEST on: pull_request: - branches: [develop, main] + branches: [develop, main, site] types: [opened, synchronize, reopened] jobs: call-test-build: uses: Tencent/tdesign/.github/workflows/test-build.yml@main - -# install lint \ No newline at end of file +# install lint From c89f434ce8ad2e476137943d059ee455a836d6c7 Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Thu, 11 May 2023 22:10:32 +0800 Subject: [PATCH 06/10] =?UTF-8?q?perf:=20=E8=B7=AF=E7=94=B1=E5=AE=88?= =?UTF-8?q?=E5=8D=AB=E8=8E=B7=E5=8F=96=E8=8F=9C=E5=8D=95=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=EF=BC=8C=E8=B7=B3=E8=BD=AC=E7=99=BB=E5=BD=95=E9=A1=B5=E5=B9=B6?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=8F=90=E7=A4=BA=20(#502)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.ts | 49 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/permission.ts b/src/permission.ts index cd82e62..5a9ea5e 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -25,38 +25,37 @@ router.beforeEach(async (to, from, next) => { } try { await userStore.getUserInfo(); + + const { asyncRoutes } = permissionStore; + + if (asyncRoutes && asyncRoutes.length === 0) { + const routeList = await permissionStore.buildAsyncRoutes(); + routeList.forEach((item: RouteRecordRaw) => { + router.addRoute(item); + }); + + if (to.name === PAGE_NOT_FOUND_ROUTE.name) { + // 动态添加路由后,此处应当重定向到fullPath,否则会加载404页面内容 + next({ path: to.fullPath, replace: true, query: to.query }); + } else { + const redirect = decodeURIComponent((from.query.redirect || to.path) as string); + next(to.path === redirect ? { ...to, replace: true } : { path: redirect }); + return; + } + } + if (router.hasRoute(to.name)) { + next(); + } else { + next(`/`); + } } catch (error) { - MessagePlugin.error(error); + MessagePlugin.error(error.message); next({ path: '/login', query: { redirect: encodeURIComponent(to.fullPath) }, }); NProgress.done(); } - - const { asyncRoutes } = permissionStore; - - if (asyncRoutes && asyncRoutes.length === 0) { - const routeList = await permissionStore.buildAsyncRoutes(); - routeList.forEach((item: RouteRecordRaw) => { - router.addRoute(item); - }); - - if (to.name === PAGE_NOT_FOUND_ROUTE.name) { - // 动态添加路由后,此处应当重定向到fullPath,否则会加载404页面内容 - next({ path: to.fullPath, replace: true, query: to.query }); - } else { - const redirect = decodeURIComponent((from.query.redirect || to.path) as string); - next(to.path === redirect ? { ...to, replace: true } : { path: redirect }); - return; - } - } - - if (router.hasRoute(to.name)) { - next(); - } else { - next(`/`); - } } else { /* white list router */ if (whiteListRouters.indexOf(to.path) !== -1) { From 4292bd2118326f770351ba00c3f613ea1b63f837 Mon Sep 17 00:00:00 2001 From: "Gui.H" Date: Fri, 12 May 2023 20:35:44 +0800 Subject: [PATCH 07/10] =?UTF-8?q?perf:=20=E8=A7=84=E8=8C=83=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=B3=BB=E7=BB=9F=E4=B8=AD=E7=9A=84=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E7=AC=A6=20(#505)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: eol * fix: 测试效果 * fix: 默认全部文件eol=lf * fix: 防止误判,仅对部分明确的文件设置 * fix: 新建文件eol格式错误进行互补 * Update settings.json --- .gitattributes | 6 ++++++ .vscode/settings.json | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..326caac --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +*.ts text eol=lf +*.vue text eol=lf +*.tsx text eol=lf +*.jsx text eol=lf +*.html text eol=lf +*.json text eol=lf \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9f7e7d1..02a0913 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,6 @@ { + "files.eol":"\n", + "editor.tabSize": 2, "eslint.format.enable": true, "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"], "[vue]": { From 03adc83ba228ef0bc022d97e1fa1f776df2c51d0 Mon Sep 17 00:00:00 2001 From: You Date: Tue, 16 May 2023 22:00:36 +0800 Subject: [PATCH 08/10] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=B0=86=E9=80=9A=E7=9F=A5=E8=AE=BE=E4=B8=BA=E6=9C=AA?= =?UTF-8?q?=E8=AF=BB=20(#511)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/detail/secondary/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/detail/secondary/index.vue b/src/pages/detail/secondary/index.vue index 05e5455..cde49dc 100644 --- a/src/pages/detail/secondary/index.vue +++ b/src/pages/detail/secondary/index.vue @@ -104,7 +104,7 @@ const setReadStatus = (item: NotificationItem) => { const changeMsg = msgData.value; changeMsg.forEach((e: NotificationItem) => { if (e.id === item.id) { - if (e.status) e.status = false; + e.status = !e.status; } }); store.setMsgData(changeMsg); From 665e0dacec6d7401c295ca8d7a1897b50b1a74a9 Mon Sep 17 00:00:00 2001 From: "Gui.H" Date: Thu, 18 May 2023 11:29:01 +0800 Subject: [PATCH 09/10] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20store=20?= =?UTF-8?q?=E4=B8=AD=E5=B9=B6=E6=9C=AA=E5=AF=B9=20localStorage=20=E7=9A=84?= =?UTF-8?q?=20TOKEN=5FNAME=20=E9=94=AE=E8=BF=9B=E8=A1=8C=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7=20(#504)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 接口请求不携带token * fix: 优化token持久化策略 * fix: 删除多余的log --- src/permission.ts | 5 +++-- src/store/modules/user.ts | 16 ++++++++++------ src/utils/request/index.ts | 5 ++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/permission.ts b/src/permission.ts index 5a9ea5e..bde2890 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -4,6 +4,7 @@ import NProgress from 'nprogress'; // progress bar import { MessagePlugin } from 'tdesign-vue-next'; import { RouteRecordRaw } from 'vue-router'; +import { TOKEN_NAME } from '@/config/global'; import router from '@/router'; import { getPermissionStore, getUserStore } from '@/store'; import { PAGE_NOT_FOUND_ROUTE } from '@/utils/route/constant'; @@ -17,8 +18,8 @@ router.beforeEach(async (to, from, next) => { const { whiteListRouters } = permissionStore; const userStore = getUserStore(); - const { token } = userStore; - if (token) { + + if (userStore[TOKEN_NAME]) { if (to.path === '/login') { next(); return; diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 7a5fbc1..57bed86 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -10,7 +10,7 @@ const InitUserInfo = { export const useUserStore = defineStore('user', { state: () => ({ - token: localStorage.getItem(TOKEN_NAME) || 'main_token', // 默认token不走权限 + [TOKEN_NAME]: 'main_token', // 默认token不走权限 userInfo: { ...InitUserInfo }, }), getters: { @@ -49,7 +49,7 @@ export const useUserStore = defineStore('user', { const res = await mockLogin(userInfo); if (res.code === 200) { - this.token = res.data; + this.setToken(res.data); } else { throw res; } @@ -67,17 +67,19 @@ export const useUserStore = defineStore('user', { roles: ['UserIndex', 'DashboardBase', 'login'], // 前端权限模型使用 如果使用请配置modules/permission-fe.ts使用 }; }; - const res = await mockRemoteUserInfo(this.token); + const res = await mockRemoteUserInfo(this[TOKEN_NAME]); this.userInfo = res; }, async logout() { - localStorage.removeItem(TOKEN_NAME); - this.token = ''; + this.removeToken(); this.userInfo = { ...InitUserInfo }; }, async removeToken() { - this.token = ''; + this.setToken(''); + }, + async setToken(token: string) { + this[TOKEN_NAME] = token; }, }, persist: { @@ -85,6 +87,8 @@ export const useUserStore = defineStore('user', { const permissionStore = usePermissionStore(); permissionStore.initRoutes(); }, + key: 'user', + paths: [TOKEN_NAME], }, }); diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts index 3dc7ed8..dfa538f 100644 --- a/src/utils/request/index.ts +++ b/src/utils/request/index.ts @@ -5,6 +5,7 @@ import merge from 'lodash/merge'; import { TOKEN_NAME } from '@/config/global'; import { ContentTypeEnum } from '@/constants'; +import { getUserStore } from '@/store'; import { VAxios } from './Axios'; import type { AxiosTransform, CreateAxiosOptions } from './AxiosTransform'; @@ -113,7 +114,9 @@ const transform: AxiosTransform = { // 请求拦截器处理 requestInterceptors: (config, options) => { // 请求之前处理config - const token = localStorage.getItem(TOKEN_NAME); + const userStore = getUserStore(); + const token = userStore[TOKEN_NAME]; + if (token && (config as Recordable)?.requestOptions?.withToken !== false) { // jwt token (config as Recordable).headers.Authorization = options.authenticationScheme From 7a7ee4ab7c9f51fa9a77e837a97e21579234f187 Mon Sep 17 00:00:00 2001 From: yuyang Date: Thu, 18 May 2023 17:58:02 +0800 Subject: [PATCH 10/10] chore: release 0.7.5 (#512) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d29b745..9952028 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tdesign-vue-next-starter", - "version": "0.7.4", + "version": "0.7.5", "scripts": { "dev:mock": "vite --open --mode mock", "dev": "vite --open --mode development",