Skip to content

Commit

Permalink
feat: upgrade to vue 3.4 and fix route issues (#699)
Browse files Browse the repository at this point in the history
* feat: 升级Vue3.4,修复Route调用方式造成一系列问题

* fix: 修复编译问题
  • Loading branch information
timi137137 authored Mar 30, 2024
1 parent 0f7096a commit 13505fd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"qrcode.vue": "^3.4.1",
"qs": "^6.11.2",
"tdesign-icons-vue-next": "^0.2.2",
"tdesign-vue-next": "^1.8.1",
"tdesign-vue-next": "^1.9.3",
"tvision-color": "^1.6.0",
"vue": "~3.3.8",
"vue": "~3.4.21",
"vue-i18n": "^9.9.1",
"vue-router": "~4.2.5"
"vue-router": "~4.3.0"
},
"devDependencies": {
"@commitlint/cli": "^18.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/list/base/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
:header-affixed-top="headerAffixedTop"
@page-change="rehandlePageChange"
@change="rehandleChange"
@select-change="(value) => rehandleSelectChange(value as number[])"
@select-change="(value: number[]) => rehandleSelectChange(value)"
>
<template #status="{ row }">
<t-tag v-if="row.status === CONTRACT_STATUS.FAIL" theme="danger" variant="light">
Expand Down
5 changes: 3 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uniq from 'lodash/uniq';
import { createRouter, createWebHistory, RouteRecordRaw, useRoute } from 'vue-router';
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';

const env = import.meta.env.MODE || 'development';

Expand Down Expand Up @@ -59,7 +59,8 @@ export const getRoutesExpanded = () => {
};

export const getActive = (maxLevel = 3): string => {
const route = useRoute();
// 非组件内调用必须通过Router实例获取当前路由
const route = router.currentRoute.value;

if (!route.path) {
return '';
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"jsxImportSource": "vue",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
Expand Down

0 comments on commit 13505fd

Please sign in to comment.