mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-12 12:13:46 +08:00
opt: 抽离 session 验证函数,修正前端路由覆盖 bug
This commit is contained in:
@@ -1,17 +1,40 @@
|
||||
<template>
|
||||
<div>{{ title }}</div>
|
||||
<div class="page-404" :style="{ height: winHeight + 'px' }">
|
||||
<div class="inner">
|
||||
<h1>404</h1>
|
||||
<h2>饶了地球一圈,还是没有找到您要的页面</h2>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from "vue"
|
||||
<script setup>
|
||||
import {ref} from "vue"
|
||||
|
||||
export default defineComponent({
|
||||
name: 'NotFound',
|
||||
data () {
|
||||
return {
|
||||
title: "404 Page",
|
||||
|
||||
}
|
||||
},
|
||||
})
|
||||
const winHeight = ref(window.innerHeight)
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
.page-404 {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
background-color: #282c34;
|
||||
|
||||
.inner {
|
||||
text-align center
|
||||
|
||||
h1 {
|
||||
color: #202020;
|
||||
font-size: 120px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 0.1em;
|
||||
text-shadow: -1px -1px 1px #111111, 2px 2px 1px #363636;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color #ffffff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -218,6 +218,7 @@ import {useRouter} from "vue-router";
|
||||
import Clipboard from "clipboard";
|
||||
import ConfigDialog from "@/components/ConfigDialog.vue";
|
||||
import PasswordDialog from "@/components/PasswordDialog.vue";
|
||||
import {checkSession} from "@/action/session";
|
||||
|
||||
const title = ref('ChatGPT-智能助手');
|
||||
const logo = 'images/logo.png';
|
||||
@@ -278,16 +279,6 @@ onMounted(() => {
|
||||
})
|
||||
});
|
||||
|
||||
const checkSession = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
httpGet('/api/user/session').then(res => {
|
||||
resolve(res)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 加载会话
|
||||
const loadChats = function () {
|
||||
httpGet("/api/chat/list?user_id=" + user.value.id).then((res) => {
|
||||
|
||||
@@ -1,40 +1,18 @@
|
||||
<template>
|
||||
<div class="home" :style="{ height: winHeight + 'px' }">
|
||||
<h1>{{ title }}</h1>
|
||||
</div>
|
||||
<h1>{{ title }}</h1>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref} from "vue"
|
||||
import {useRouter} from "vue-router"; // 导入useRouter函数
|
||||
import {useRouter} from "vue-router";
|
||||
import {checkSession} from "@/action/session";
|
||||
|
||||
const title = ref("HI, ChatGPT PLUS!");
|
||||
const winHeight = ref(window.innerHeight)
|
||||
const router = useRouter();
|
||||
// onMounted(() => {
|
||||
// if (isMobile()) {
|
||||
// router.push("mobile");
|
||||
// } else {
|
||||
// router.push("chat");
|
||||
// }
|
||||
// })
|
||||
|
||||
checkSession().then(() => {
|
||||
router.push("chat")
|
||||
}).catch(() => {
|
||||
router.push("login")
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
.home {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #202020;
|
||||
background-color: #282c34;
|
||||
|
||||
h1 {
|
||||
font-size: 300%;
|
||||
font-weight: bold;
|
||||
letter-spacing: 0.1em;
|
||||
text-shadow: -1px -1px 1px #111111, 2px 2px 1px #363636;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user