feat: 登录接口联调

This commit is contained in:
DEV_DSW
2025-12-22 11:24:40 +08:00
parent 72d1869f40
commit c467f54dab
10 changed files with 71 additions and 49 deletions

View File

@@ -3,8 +3,12 @@ import { createPinia } from "pinia"
import errorHandler from "@utils/errorHandler"
import router from "./router"
import App from "./App.vue"
// 引入 Element Plus 组件库
import ElementPlus from 'element-plus'
import locale from 'element-plus/es/locale/lang/zh-cn'
// 引入 i18n 插件
import i18n from './i18n'
// import './permission'

View File

@@ -2,11 +2,15 @@ import { createRouter, createMemoryHistory } from "vue-router";
const routes = [
{
path: "/",
component: () => import("@renderer/views/login/index.vue"),
name: "Login",
meta: { requiresAuth: false },
}
path: '/',
redirect: '/home'
},
{
path: "/home",
component: () => import("@renderer/views/home/index.vue"),
name: "Home",
meta: { requiresAuth: true },
},
];
const router = createRouter({
@@ -21,24 +25,4 @@ const router = createRouter({
},
});
// router.beforeEach((to: any, from: any, next: any) => {
// const token = localStorage.getItem("token");
// if (to.meta && (to.meta as any).requiresAuth && !token) {
// next({ path: "/login" });
// return;
// }
// if (token && to.path === "/login") {
// next({ path: "/home" });
// return;
// }
// if (token && to.path === "/") {
// next({ path: "/home" });
// return;
// }
// next();
// });
export default router;

View File

@@ -1,5 +1,5 @@
<template>
<div>
<div class="bg-white box-border w-full h-full rounded-[16px] flex">
首页
</div>
</template>

View File

@@ -1,16 +1,38 @@
import '@renderer/styles/index.css'
import { createApp, type Plugin } from "vue"
import errorHandler from '@utils/errorHandler'
// 引入 Element Plus 组件库
import ElementPlus from 'element-plus'
import locale from 'element-plus/es/locale/lang/zh-cn'
// 引入 i18n 插件
import i18n from '@renderer/i18n'
import HeaderBar from '@renderer/components/HeaderBar/index.vue'
import DragRegion from '@renderer/components/DragRegion/index.vue'
import Login from './index.vue'
createApp(Login)
.use(i18n)
.use(createPinia())
.use(errorHandler)
.component('HeaderBar', HeaderBar)
.component('DragRegion', DragRegion)
.mount('#app')
// 样式文件隔离
import '@renderer/styles/index.css'
import 'element-plus/dist/index.css'
// 引入全局组件
import HeaderBar from '@components/HeaderBar/index.vue'
import DragRegion from '@components/DragRegion/index.vue'
const components: Plugin = (app) => {
app.component('HeaderBar', HeaderBar);
app.component('DragRegion', DragRegion);
}
// 创建 Vue 应用实例
const app = createApp(Login);
const pinia = createPinia();
// 使用 Pinia 状态管理
app.use(pinia);
app.use(ElementPlus, { locale })
app.use(components)
app.use(i18n)
app.use(errorHandler)
// 挂载应用到 DOM
app.mount("#app");

View File

@@ -32,7 +32,8 @@
</el-form-item>
<el-form-item prop="password">
<div class="text-[14px] text-gray-600">密码</div>
<el-input class="h-[40px]" v-model.trim="form.password" placeholder="请输入密码" clearable autocomplete="off">
<el-input class="h-[40px]" v-model.trim="form.password" type="password" placeholder="请输入密码" clearable
autocomplete="off">
<template #prefix>
<RiKey2Fill size="20px" color="#99A0AE" />
</template>
@@ -75,12 +76,12 @@
</el-form>
<!-- Copy Right -->
<div class="text-[14px] text-gray-500 text-center mt-auto">
<!-- <div class="text-[14px] text-gray-500 text-center mt-auto">
© 2025 贵州智念科技服务有限公司 版权所有
</div>
</div> -->
</div>
<img class="w-[540px]" src="@assets/images/login/logo.png" />
<!-- <img class="w-[540px]" src="@assets/images/login/logo.png" /> -->
</main>
</div>
</template>
@@ -122,8 +123,7 @@ const onSubmit = async () => {
try {
userStore.login(form).then(() => {
// window.location.href = 'index.html'
console.log(form)
window.api.app.loadPage('index');
})
} finally {
getVerifyCode()