feat: 登录接口联调
This commit is contained in:
3
global.d.ts
vendored
3
global.d.ts
vendored
@@ -60,7 +60,8 @@ declare global {
|
|||||||
isWindowMaximized: () => Promise<boolean>,
|
isWindowMaximized: () => Promise<boolean>,
|
||||||
viewIsReady: () => void
|
viewIsReady: () => void
|
||||||
app: {
|
app: {
|
||||||
setFrameless: (route?: string) => void
|
setFrameless: (route?: string) => void,
|
||||||
|
loadPage: (page: string) => void
|
||||||
},
|
},
|
||||||
tabs: {
|
tabs: {
|
||||||
create: (url?: string) => void,
|
create: (url?: string) => void,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export enum IPC_EVENTS {
|
|||||||
WINDOW_CLOSE = 'window-close',
|
WINDOW_CLOSE = 'window-close',
|
||||||
IS_WINDOW_MAXIMIZED = 'is-window-maximized',
|
IS_WINDOW_MAXIMIZED = 'is-window-maximized',
|
||||||
APP_SET_FRAMELESS = 'app:set-frameless',
|
APP_SET_FRAMELESS = 'app:set-frameless',
|
||||||
|
APP_LOAD_PAGE = 'app:load-page',
|
||||||
TAB_CREATE = 'tab:create',
|
TAB_CREATE = 'tab:create',
|
||||||
TAB_LIST = 'tab:list',
|
TAB_LIST = 'tab:list',
|
||||||
TAB_NAVIGATE = 'tab:navigate',
|
TAB_NAVIGATE = 'tab:navigate',
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ class WindowService {
|
|||||||
ipcMain.on(IPC_EVENTS.WINDOW_MINIMIZE, handleMinimizeWindow);
|
ipcMain.on(IPC_EVENTS.WINDOW_MINIMIZE, handleMinimizeWindow);
|
||||||
ipcMain.on(IPC_EVENTS.WINDOW_MAXIMIZE, handleMaximizeWindow);
|
ipcMain.on(IPC_EVENTS.WINDOW_MAXIMIZE, handleMaximizeWindow);
|
||||||
ipcMain.handle(IPC_EVENTS.IS_WINDOW_MAXIMIZED, handleIsWindowMaximized);
|
ipcMain.handle(IPC_EVENTS.IS_WINDOW_MAXIMIZED, handleIsWindowMaximized);
|
||||||
|
ipcMain.handle(IPC_EVENTS.APP_LOAD_PAGE, (e: IpcMainInvokeEvent, page: string) => {
|
||||||
|
const win = BrowserWindow.fromWebContents(e.sender);
|
||||||
|
if (win) this._loadPage(win, page);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getInstance(): WindowService {
|
public static getInstance(): WindowService {
|
||||||
@@ -211,12 +215,16 @@ class WindowService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _loadWindowTemplate(window: BrowserWindow, name: WindowNames) {
|
private _loadPage(window: BrowserWindow, pageName: string) {
|
||||||
// 检查是否存在开发服务器 URL,若存在则表示处于开发环境
|
|
||||||
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
|
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
|
||||||
return window.loadURL(`${MAIN_WINDOW_VITE_DEV_SERVER_URL}${'/html/' + (name === 'main' ? '' : name)}`);
|
return window.loadURL(`${MAIN_WINDOW_VITE_DEV_SERVER_URL}/html/${pageName}.html`);
|
||||||
}
|
}
|
||||||
window.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/html/${name === 'main' ? 'login' : name}.html`));
|
window.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/html/${pageName}.html`));
|
||||||
|
}
|
||||||
|
|
||||||
|
private _loadWindowTemplate(window: BrowserWindow, name: WindowNames) {
|
||||||
|
const page = name === 'main' ? 'login' : name;
|
||||||
|
this._loadPage(window, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ const api: WindowApi = {
|
|||||||
viewIsReady: () => ipcRenderer.send(IPC_EVENTS.RENDERER_IS_READY),
|
viewIsReady: () => ipcRenderer.send(IPC_EVENTS.RENDERER_IS_READY),
|
||||||
|
|
||||||
app: {
|
app: {
|
||||||
setFrameless: (route?: string) => ipcRenderer.invoke(IPC_EVENTS.APP_SET_FRAMELESS, route)
|
setFrameless: (route?: string) => ipcRenderer.invoke(IPC_EVENTS.APP_SET_FRAMELESS, route),
|
||||||
|
loadPage: (page: string) => ipcRenderer.invoke(IPC_EVENTS.APP_LOAD_PAGE, page)
|
||||||
},
|
},
|
||||||
|
|
||||||
tabs: {
|
tabs: {
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ import { createPinia } from "pinia"
|
|||||||
import errorHandler from "@utils/errorHandler"
|
import errorHandler from "@utils/errorHandler"
|
||||||
import router from "./router"
|
import router from "./router"
|
||||||
import App from "./App.vue"
|
import App from "./App.vue"
|
||||||
|
|
||||||
|
// 引入 Element Plus 组件库
|
||||||
import ElementPlus from 'element-plus'
|
import ElementPlus from 'element-plus'
|
||||||
import locale from 'element-plus/es/locale/lang/zh-cn'
|
import locale from 'element-plus/es/locale/lang/zh-cn'
|
||||||
|
|
||||||
|
// 引入 i18n 插件
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
// import './permission'
|
// import './permission'
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,15 @@ import { createRouter, createMemoryHistory } from "vue-router";
|
|||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: '/',
|
||||||
component: () => import("@renderer/views/login/index.vue"),
|
redirect: '/home'
|
||||||
name: "Login",
|
},
|
||||||
meta: { requiresAuth: false },
|
{
|
||||||
}
|
path: "/home",
|
||||||
|
component: () => import("@renderer/views/home/index.vue"),
|
||||||
|
name: "Home",
|
||||||
|
meta: { requiresAuth: true },
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = createRouter({
|
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;
|
export default router;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="bg-white box-border w-full h-full rounded-[16px] flex">
|
||||||
首页
|
首页
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,16 +1,38 @@
|
|||||||
import '@renderer/styles/index.css'
|
import { createApp, type Plugin } from "vue"
|
||||||
|
|
||||||
import errorHandler from '@utils/errorHandler'
|
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 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'
|
import Login from './index.vue'
|
||||||
|
|
||||||
createApp(Login)
|
// 样式文件隔离
|
||||||
.use(i18n)
|
import '@renderer/styles/index.css'
|
||||||
.use(createPinia())
|
import 'element-plus/dist/index.css'
|
||||||
.use(errorHandler)
|
|
||||||
.component('HeaderBar', HeaderBar)
|
// 引入全局组件
|
||||||
.component('DragRegion', DragRegion)
|
import HeaderBar from '@components/HeaderBar/index.vue'
|
||||||
.mount('#app')
|
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");
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="password">
|
<el-form-item prop="password">
|
||||||
<div class="text-[14px] text-gray-600">密码</div>
|
<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>
|
<template #prefix>
|
||||||
<RiKey2Fill size="20px" color="#99A0AE" />
|
<RiKey2Fill size="20px" color="#99A0AE" />
|
||||||
</template>
|
</template>
|
||||||
@@ -75,12 +76,12 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<!-- Copy Right -->
|
<!-- 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 贵州智念科技服务有限公司 版权所有
|
© 2025 贵州智念科技服务有限公司 版权所有
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<img class="w-[540px]" src="@assets/images/login/logo.png" />
|
<!-- <img class="w-[540px]" src="@assets/images/login/logo.png" /> -->
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -122,8 +123,7 @@ const onSubmit = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
userStore.login(form).then(() => {
|
userStore.login(form).then(() => {
|
||||||
// window.location.href = 'index.html'
|
window.api.app.loadPage('index');
|
||||||
console.log(form)
|
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
getVerifyCode()
|
getVerifyCode()
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default defineConfig(async () => {
|
|||||||
resolve(__dirname, 'html/index.html'),
|
resolve(__dirname, 'html/index.html'),
|
||||||
resolve(__dirname, 'html/dialog.html'),
|
resolve(__dirname, 'html/dialog.html'),
|
||||||
resolve(__dirname, 'html/setting.html'),
|
resolve(__dirname, 'html/setting.html'),
|
||||||
|
resolve(__dirname, 'html/login.html'),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user