feat(route): isMain用于判断子窗口

This commit is contained in:
BTMuli
2023-03-29 19:32:06 +08:00
parent 8e2340bc42
commit 747d80fa18
3 changed files with 72 additions and 12 deletions

View File

@@ -1,19 +1,32 @@
<template>
<v-layout>
<!-- 侧边栏菜单 -->
<t-sidebar />
<!-- 主体内容 -->
<v-main>
<v-container fluid>
<router-view />
</v-container>
</v-main>
</v-layout>
<div v-if="isMain">
<v-layout>
<!-- 侧边栏菜单 -->
<t-sidebar />
<!-- 主体内容 -->
<v-main>
<v-container fluid>
<router-view />
</v-container>
</v-main>
</v-layout>
</div>
<div v-else>
<v-layout>
<!-- 主体内容 -->
<v-main>
<v-container fluid>
<router-view />
</v-container>
</v-main>
</v-layout>
</div>
</template>
<script lang="ts" setup>
// vue
import { onMounted } from "vue";
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import TSidebar from "./components/t-sidebar.vue";
// tauri
import { fs } from "@tauri-apps/api";
@@ -25,9 +38,15 @@ import { InitTGData, DeleteTGData, WriteTGData } from "./utils/TGIndex";
import { TGAppDataList, TGGetDataList } from "./data";
const appStore = useAppStore();
const isMain = ref(true as boolean);
const route = useRouter();
onMounted(async () => {
await checkLoad();
// 判断路由meta.isMain
isMain.value = route.currentRoute.value.meta.isMain as boolean;
if (isMain.value) {
await checkLoad();
}
});
async function checkLoad() {

View File

@@ -4,6 +4,7 @@ import Home from "../pages/Home.vue";
import News from "../pages/News.vue";
// 数据交互
import Achievements from "../pages/Achievements.vue";
import TPost from "../views/t-post.vue";
// 应用配置相关
import Config from "../pages/Config.vue";
@@ -12,30 +13,56 @@ const routes = [
path: "/",
name: "首页",
component: Home,
meta: {
isMain: true,
},
},
{
path: "/achievements",
name: "成就",
component: Achievements,
meta: {
isMain: true,
},
},
{
path: "/config",
name: "设置",
component: Config,
meta: {
isMain: true,
},
},
{
path: "/GCG",
name: "卡牌",
component: GCG,
meta: {
isMain: true,
},
},
{
path: "/home",
redirect: "/",
meta: {
isMain: true,
},
},
{
path: "/news",
name: "咨讯",
component: News,
meta: {
isMain: true,
},
},
{
path: "/post_detail/:post_id",
name: "帖子详情",
component: TPost,
meta: {
isMain: false,
},
},
];

14
src/views/t-post.vue Normal file
View File

@@ -0,0 +1,14 @@
<template>
<div>TEST {{ $route.meta.isMain }}</div>
</template>
<script lang="ts" setup>
// 获取路由传参
import { useRoute } from "vue-router";
const route = useRoute();
// 获取路由参数
const id = route.params.post_id;
console.log(id);
</script>
<style lang="css"></style>