xy 2 years ago
parent 4b2f2e2995
commit 223363388f

@ -13,8 +13,6 @@ if (process.env.NODE_ENV !== 'development') {
}
export const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}` : `file://${__dirname}/index.html`
export const loadingURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}/static/loader.html` : `file://${__static}/loader.html`
export const noticeURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}/static/notice.html` : `file://${__static}/loader.html`
export const libPath = process.env.libPath
export const adminWebUri = process.env.NODE_ENV === 'development' ? "http://contract-sqhj-test.ali251.langye.net/admin_test/#/" : "http://contract-sqhj.ali251.langye.net/admin/#/"

@ -4,11 +4,17 @@ import { winURL } from '../config/StaticPath'
import downloadFile from './downloadFile'
import Update from './checkupdate'
import { updater } from './HotUpdater'
import { createAdminWindow } from "./windowManager"
import { createAdminWindow, toggleMainWindowResizable, mainWindowResize } from "./windowManager"
export default {
Mainfunc(IsUseSysTitle) {
const allUpdater = new Update();
ipcMain.handle('main-window-resize', (event, arg) => {
mainWindowResize(arg.width, arg.height)
})
ipcMain.handle('toggle-main-window-resizable', (event, arg) => {
toggleMainWindowResizable(arg)
})
ipcMain.handle("create-admin-window", async (event) => {
createAdminWindow()
})

@ -10,6 +10,12 @@ var loadWindow = null
var mainWindow = null
setIpc.Mainfunc(IsUseSysTitle)
var adminWindow = null
export function toggleMainWindowResizable (status) {
mainWindow.setResizable(status)
}
export function mainWindowResize (w,h) {
mainWindow.setSize(w,h)
}
function createAdminWindow() {
adminWindow = new BrowserWindow({
height: 800,
@ -63,10 +69,10 @@ function createMainWindow() {
* Initial window options
*/
mainWindow = new BrowserWindow({
height: 800,
height: 504,
useContentSize: true,
width: 1700,
minWidth: 1366,
width: 302,
resizable: false,
show: false,
frame: IsUseSysTitle,
titleBarStyle: platform().includes('win32') ? 'default' : 'hidden',

@ -99,6 +99,7 @@ const logout = () => {
height: 62px;
.hamburger-container {
-webkit-app-region: no-drag;
line-height: 58px;
height: 50px;
float: left;
@ -153,6 +154,7 @@ const logout = () => {
}
.select-right {
-webkit-app-region: no-drag;
.el-dropdown-link {
color: #333333;
font-weight: 400;

@ -4,6 +4,10 @@
<Logo :collapse="isCollapse" />
<sidebar-item v-for="route in routes_list" :key="route.name" :item="route" :base-path="route.path"
:collapse="isCollapse"></sidebar-item>
<sidebar-item :collapse="isCollapse" :item="{
onlyShowfirst: true,
name: '后台管理'
}"></sidebar-item>
</el-menu>
</scroll-bar>
</template>
@ -48,4 +52,4 @@ const isCollapse = computed(() => !sidebarStatus.opened)
overflow: hidden;
width: 180px;
}
</style>
</style>

@ -59,4 +59,7 @@ const classObj = computed(() => {
.NoUseSysTitle {
top: 38px
}
.sidebar-container {
-webkit-app-region: no-drag;
}
</style>

@ -2,32 +2,33 @@ import router from './router'
import Performance from '@/tools/performance'
import { usePermissionStore } from "@/store/permission"
import { useUserStore } from "@/store/user"
import { ipcRenderer } from "electron"
export function usePermission() {
let end = null
const whiteList = ['/login'] // 不重定向白名单
router.beforeEach(async (to, from, next) => {
const { GenerateRoutes, routers } = usePermissionStore()
const { GetUserInfo, token, roles, logOut } = useUserStore()
const { getUserInfo, token, roles, logOut } = useUserStore()
end = Performance.startExecute(`${from.path} => ${to.path} 路由耗时`) /// 路由性能监控
if (token) {
if (to.path === '/login') {
next({ path: '/' })
} else {
const hasRoles = roles && roles.length > 0;
if (hasRoles && routers && routers.length > 0) {
if (hasRoles) {
next()
} else {
try {
const roles = await GetUserInfo()
const accessRoutes = await GenerateRoutes(roles)
accessRoutes.forEach(item => {
router.addRoute(item)
})
const roles = await getUserInfo()
next({ ...to, replace: true })
} catch (error) {
await logOut()
console.error(error)
await ipcRenderer.invoke("toggle-main-window-resizable",false)
await ipcRenderer.invoke("main-window-resize",{
width: 320,
height: 504
})
next('/login')
}
}
@ -37,6 +38,11 @@ export function usePermission() {
if (whiteList.includes(to.path)) {
next()
} else {
await ipcRenderer.invoke("toggle-main-window-resizable",false)
await ipcRenderer.invoke("main-window-resize",{
width: 320,
height: 504
})
next('/login')
}
}

@ -8,7 +8,7 @@ export const constantRouterMap = [{
component: Layout,
redirect: '/dashboard',
name: '主页',
hidden: true,
hidden: false,
children: [{
path: 'dashboard',
name: '总览',
@ -18,7 +18,7 @@ export const constantRouterMap = [{
path: '/login',
component: () => import('@/views/login'),
hidden: true
}, {
},{
path: '*',
component: () => import('@/views/404'),
hidden: true

@ -57,6 +57,8 @@ export const useUserStore = defineStore({
getInfo().then(res => {
this.info = res
this.isLogin = true
this.roles = ['admin']
localStorage.setItem("roles", JSON.stringify(this.roles));
localStorage.setItem("name", res.name);
resolve(res)
}).then(err => {

@ -1,73 +1,57 @@
<template>
<div class="login-container">
<div ref="formContainer" class="form-container">
<template v-if="!userStore.isLogin">
<div class="title-container">
<img :src="require('@/assets/imgs/login-title.png')" alt="" />
</div>
<div
style="
display: flex;
justify-content: space-between;
padding: 0 41px 0 104px;
margin-top: 57px;
"
>
<div class="left">
<img :src="require('@/assets/imgs/login-img1.png')" alt="" />
</div>
<div class="right">
<el-form
ref="loginFormRef"
:model="loginForm"
:rules="loginRules"
class="login-form"
auto-complete="on"
label-position="left"
>
<el-form-item class="form-item" prop="username">
<el-form
ref="loginFormRef"
:model="loginForm"
:rules="loginRules"
class="login-form"
auto-complete="on"
label-position="left"
>
<el-form-item class="form-item" prop="username">
<span class="svg-container">
<svg-icon icon-class="user" />
</span>
<el-input
ref="username"
v-model:value="loginForm.username"
placeholder="请输入账号"
name="username"
type="text"
tabindex="1"
auto-complete="off"
/>
</el-form-item>
<el-form-item class="form-item" prop="password">
<el-input
ref="username"
v-model:value="loginForm.username"
placeholder="请输入账号"
name="username"
type="text"
tabindex="1"
auto-complete="off"
/>
</el-form-item>
<el-form-item class="form-item" prop="password">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="pwdType"
ref="password"
v-model:value="loginForm.password"
:type="pwdType"
placeholder="请输入密码"
name="password"
tabindex="2"
auto-complete="off"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<el-input
:key="pwdType"
ref="password"
v-model:value="loginForm.password"
:type="pwdType"
placeholder="请输入密码"
name="password"
tabindex="2"
auto-complete="off"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="pwdType === 'password' ? 'eye' : 'eye-open'" />
</span>
</el-form-item>
</el-form-item>
<el-checkbox size="large" style="margin-top: 18px;zoom: 1.3;" v-model="isRemember"></el-checkbox>
<el-checkbox size="large" style="margin-top: 18px;zoom: 1.3;" v-model="isRemember"></el-checkbox>
<el-button
:loading="loading"
type="primary"
round
style="
<el-button
:loading="loading"
type="primary"
round
style="
margin-top: 35px;
font-size: 18px;
letter-spacing: 3px;
@ -77,72 +61,10 @@
background-color: #3d7af6;
filter: drop-shadow(0px 4px 9px rgba(72, 93, 237, 0.63));
"
@click.native.prevent="handleLogin"
>登录</el-button
>
</el-form>
</div>
</div>
</template>
<template v-else>
<div class="title-container">
<img :src="require('@/assets/imgs/login-title.png')" alt="" />
</div>
<div
style="
display: flex;
justify-content: space-between;
padding: 0 41px 0 104px;
margin-top: 57px;
"
@click.native.prevent="handleLogin"
>登录</el-button
>
<div class="left">
<img :src="require('@/assets/imgs/login-img1.png')" alt="" />
</div>
<div class="right">
<el-descriptions title="用户信息" :column="2">
<el-descriptions-item label="用户名">{{ userStore.info.name }}</el-descriptions-item>
<el-descriptions-item label="手机号">{{ userStore.info.mobile }}</el-descriptions-item>
<el-descriptions-item label="职位">{{ userStore.info.position }}</el-descriptions-item>
<el-descriptions-item label="部门">
<el-tag size="small">{{ userStore.info.department ? userStore.info.department.name : "" }}</el-tag>
</el-descriptions-item>
</el-descriptions>
<div style="display: flex;justify-content: space-between;align-items: center;">
<el-button
type="primary"
round
style="
width: 44%;
margin-top: 35px;
font-size: 18px;
letter-spacing: 3px;
border-radius: 50px;
height: 50px;
background-color: #3d7af6;
filter: drop-shadow(0px 4px 9px rgba(72, 93, 237, 0.63));
"
@click.native.prevent="toAdmin"
>进入后台</el-button>
<el-button
type="danger"
round
style="
width: 44%;
margin-top: 35px;
font-size: 18px;
letter-spacing: 3px;
border-radius: 50px;
height: 50px;
filter: drop-shadow(0px 4px 9px rgba(219, 79, 43, 0.63));
"
@click.native.prevent="handleLogout"
>退出登录</el-button>
</div>
</div>
</div>
</template>
</el-form>
</div>
</div>
</template>
@ -158,10 +80,6 @@ import { useRouter } from "@/hooks/use-router";
const userStore = useUserStore()
init(".form-container")
if (userStore.token) {
userStore.getUserInfo()
}
const validateUsername = (rule, value, callback) => {
if (!isvalidUsername(value)) {
callback(new Error("请输入正确的用户名"));
@ -226,7 +144,13 @@ const handleLogin = () => {
userStore.login(loginForm.value).then(res => {
loading.value = false;
ipcRenderer.invoke("create-admin-window")
//ipcRenderer.invoke("create-admin-window")
ipcRenderer.invoke("toggle-main-window-resizable",true)
ipcRenderer.invoke("main-window-resize",{
width: 1200,
height: 800
})
router.push('/')
if (isRemember.value) {
window.localStorage.setItem('lgif',window.btoa(JSON.stringify(loginForm.value)))
} else {
@ -319,20 +243,8 @@ $light_gray: #eee;
.form-container {
transition: all .2s;
width: 930px;
max-width: 100vw;
background: #fff;
border-radius: 14px;
padding-bottom: 53px;
filter: drop-shadow(0px 5px 24.5px rgba(74, 113, 240, 0.23));
padding: 20px;
.left {
img {
width: 310px;
}
}
}
.tips {
@ -347,13 +259,6 @@ $light_gray: #eee;
}
}
.form-item {
width: 361px;
height: 51px;
margin-bottom: 0;
}
.svg-container {
padding: 6px 0;
color: $dark_gray;
@ -364,16 +269,6 @@ $light_gray: #eee;
margin-left: 15px;
}
.title-container {
display: flex;
justify-content: center;
position: relative;
margin-top: 85px;
img {
width: 754px;
}
}
.show-pwd {
position: absolute;
right: 10px;

Loading…
Cancel
Save