feat: 路由

This commit is contained in:
手瓜一十雪 2024-11-15 10:41:55 +08:00
parent f83bf197d2
commit 9b20e9db29
7 changed files with 44 additions and 18 deletions

View File

@ -11,7 +11,8 @@
"dependencies": { "dependencies": {
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"tdesign-vue-next": "^1.10.3", "tdesign-vue-next": "^1.10.3",
"vue": "^3.5.12" "vue": "^3.5.12",
"vue-router": "^4.4.5"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^5.1.4", "@vitejs/plugin-vue": "^5.1.4",

View File

@ -1,25 +1,11 @@
<!-- <template>
<div id="app">
<LoginForm />
</div>
</template>
<script setup>
import LoginForm from './components/QQ.vue';
</script> -->
<template> <template>
<div id="app"> <div id="app">
<QQLogin /> <router-view />
</div> </div>
</template> </template>
<script> <script>
import QQLogin from './components/QQLogin.vue';
export default { export default {
name: 'App', name: 'App'
components: {
QQLogin
}
}; };
</script> </script>

View File

@ -0,0 +1,12 @@
<template>
<div>
<h1>面板</h1>
<p>欢迎来到面板页面</p>
</div>
</template>
<script>
export default {
name: 'Dashboard'
};
</script>

View File

@ -20,7 +20,10 @@
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next'; import { MessagePlugin } from 'tdesign-vue-next';
import { LockOnIcon } from 'tdesign-icons-vue-next'; import { LockOnIcon } from 'tdesign-icons-vue-next';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter()
const route = useRoute()
const formData = reactive({ const formData = reactive({
token: '', token: '',
@ -28,11 +31,13 @@ const formData = reactive({
const onSubmit = async ({ validateResult, firstError }) => { const onSubmit = async ({ validateResult, firstError }) => {
if (validateResult === true) { if (validateResult === true) {
await router.push({ path: '/dashboard' });
MessagePlugin.success('登录中...'); MessagePlugin.success('登录中...');
} else { } else {
MessagePlugin.error('登录失败'); MessagePlugin.error('登录失败');
} }
}; };
</script> </script>
<style scoped> <style scoped>
.login-container { .login-container {

View File

@ -10,13 +10,14 @@ import {
Option as TOption Option as TOption
} from 'tdesign-vue-next'; } from 'tdesign-vue-next';
import { router } from './router';
const app = createApp(App); const app = createApp(App);
app.use(router);
app.use(TButton); app.use(TButton);
app.use(TInput); app.use(TInput);
app.use(TForm); app.use(TForm);
app.use(TFormItem); app.use(TFormItem);
app.use(TSelect); app.use(TSelect);
app.use(TOption); app.use(TOption);
app.mount('#app'); app.mount('#app');

View File

@ -0,0 +1,16 @@
import { createWebHistory, createRouter } from 'vue-router'
import Dashboard from '../components/Dashboard.vue';
import QQLogin from '../components/QQLogin.vue';
import WebUiLogin from '../components/WebUiLogin.vue';
const routes = [
{ path: '/', redirect: '/webui' },
{ path: '/webui', component: WebUiLogin, name: 'WebUiLogin' },
{ path: '/qqlogin', component: QQLogin , name: 'QQLogin'},
{ path: '/dashboard', component: Dashboard, name: 'Dashboard' }
]
export const router = createRouter({
history: createWebHistory(),
routes,
})

5
napcat.webui/src/shims-vue.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}