refactor: ♻️ 完善 typescript 类型,重构代码
Former-commit-id: 5ac4e273aaab2b068e28da5146f516da80a8852b
This commit is contained in:
@@ -79,6 +79,7 @@ const tagsViewStore = useTagsViewStore();
|
||||
const appStore = useAppStore();
|
||||
|
||||
const { visitedViews } = storeToRefs(tagsViewStore);
|
||||
console.log("visitedViews", visitedViews);
|
||||
const settingsStore = useSettingsStore();
|
||||
const layout = computed(() => settingsStore.layout);
|
||||
|
||||
@@ -141,11 +142,14 @@ function filterAffixTags(routes: RouteRecordRaw[], basePath = "/") {
|
||||
let tags: TagView[] = [];
|
||||
routes.forEach(processRoute);
|
||||
|
||||
console.log("filterAffixTags", tags);
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
function initTags() {
|
||||
const tags: TagView[] = filterAffixTags(permissionStore.routes);
|
||||
console.log("initTags", tags);
|
||||
affixTags.value = tags;
|
||||
for (const tag of tags) {
|
||||
// Must have tag name
|
||||
@@ -156,6 +160,7 @@ function initTags() {
|
||||
}
|
||||
|
||||
function addTags() {
|
||||
console.log("addTags", visitedViews);
|
||||
if (route.meta.title) {
|
||||
tagsViewStore.addView({
|
||||
name: route.name as string,
|
||||
@@ -169,13 +174,14 @@ function addTags() {
|
||||
}
|
||||
|
||||
function moveToCurrentTag() {
|
||||
console.log("moveToCurrentTag", visitedViews);
|
||||
// 使用 nextTick() 的目的是确保在更新 tagsView 组件之前,scrollPaneRef 对象已经滚动到了正确的位置。
|
||||
nextTick(() => {
|
||||
for (const tag of visitedViews.value) {
|
||||
if (tag.path === route.path) {
|
||||
scrollPaneRef.value.moveToTarget(tag);
|
||||
// when query is different then update
|
||||
route.query = { ...route.query, ...tag.query };
|
||||
// route.query = { ...route.query, ...tag.query };
|
||||
if (tag.fullPath !== route.fullPath) {
|
||||
tagsViewStore.updateVisitedView({
|
||||
name: route.name as string,
|
||||
|
||||
Reference in New Issue
Block a user