Compare commits

..

No commits in common. "77c1ca7d50b61d69b57d31ab902165c07310af76" and "f057320625484de0df09b046de92b8702cdd44cb" have entirely different histories.

4 changed files with 38 additions and 77 deletions

View File

@ -24,8 +24,8 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
'/dev-api': { '/dev-api': {
// target: 'http://27.128.240.72:7865', target: 'http://27.128.240.72:7865',
target: 'http://192.168.2.52:7863', // target: 'http://192.168.2.52:7863',
changeOrigin: true, changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '') rewrite: (p) => p.replace(/^\/dev-api/, '')
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

View File

@ -23,15 +23,12 @@ function createLoginWindow() {
show: false, show: false,
frame: false, frame: false,
autoHideMenuBar: true, autoHideMenuBar: true,
maximizable: false,
resizable: false,
icon: join(__dirname, '../../resources/logo2.ico'), icon: join(__dirname, '../../resources/logo2.ico'),
...(process.platform === 'linux' ? { icon } : {}), ...(process.platform === 'linux' ? { icon } : {}),
webPreferences: { webPreferences: {
preload: join(__dirname, '../preload/index.js'), preload: join(__dirname, '../preload/index.js'),
sandbox: false, sandbox: false,
nodeIntegration: true, nodeIntegration: true
contextIsolation: false, // 沙箱取消
} }
}) })
loginWindow.type = 'login' // 唯一标识 loginWindow.type = 'login' // 唯一标识
@ -53,8 +50,6 @@ function createLoginWindow() {
loginWindow.on('closed', () => { loginWindow.on('closed', () => {
loginWindow = null loginWindow = null
}) })
remote.enable(loginWindow.webContents)
} }
//主窗口 //主窗口
function createMainWindow() { function createMainWindow() {

View File

@ -7,18 +7,25 @@
<img class="welcome-img" :src="leftBg2" /> <img class="welcome-img" :src="leftBg2" />
</div> </div>
<div class="box-item login"> <div class="box-item login">
<WindowTools :isHasMax="false" /> <WindowTools :isHasMax="false"/>
<div class="login-title">账号登录</div> <div class="login-title">账号登录</div>
<el-form ref="formRef" class="login-form" :model="loginForm" :rules="rules" size="large"> <el-form ref="formRef" class="login-form" :model="loginForm" :rules="rules" size="large">
<el-form-item prop="username"> <el-form-item prop="username">
<el-input v-model.trim="loginForm.username" placeholder="请输入用户名" /> <el-input v-model.trim="loginForm.username" placeholder="请输入用户名" />
</el-form-item> </el-form-item>
<el-form-item prop="password" style="margin-bottom: 15px"> <el-form-item prop="password" style="margin-bottom: 15px">
<el-input v-model="loginForm.password" autocomplete="on" type="password" placeholder="请输入密码" /> <el-input
v-model="loginForm.password"
autocomplete="on"
type="password"
placeholder="请输入密码"
/>
</el-form-item> </el-form-item>
<el-checkbox class="flex mb-5" v-model="loginForm.rememberMe">记住密码</el-checkbox> <el-checkbox class="flex mb-5" v-model="loginForm.rememberMe">记住密码</el-checkbox>
<el-form-item> <el-form-item>
<el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)">登录</el-button> <el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)"
>登录</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -35,8 +42,6 @@ import leftBg2 from '@/assets/images/login/left-bg2.png'
import WindowTools from '@/components/window-tools/index.vue' import WindowTools from '@/components/window-tools/index.vue'
import SelectSubject from '@/components/select-subject/index.vue' import SelectSubject from '@/components/select-subject/index.vue'
const { BrowserWindow, session } = require('@electron/remote')
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
const formRef = ref() const formRef = ref()
const userStore = useUserStore() const userStore = useUserStore()
@ -54,86 +59,58 @@ const rules = reactive({
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }] password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }]
}) })
let curWinUrl;
// //
const submitForm = async (formEl) => { const submitForm = async (formEl) => {
if (!formEl) return if (!formEl) return
await formEl.validate(async (valid) => { await formEl.validate(async (valid) => {
if (valid) { if (valid) {
btnLoading.value = true btnLoading.value = true
// cookie // cookie
if (loginForm.rememberMe) { if (loginForm.rememberMe) {
await setCookie('username', loginForm.username) localStorage.setItem('username', loginForm.username)
await setCookie('password', encrypt(loginForm.password)) localStorage.setItem('password', encrypt(loginForm.password))
await setCookie('rememberMe', loginForm.rememberMe.toString()) localStorage.setItem('rememberMe', loginForm.rememberMe)
} else { } else {
// //
await session.defaultSession.clearStorageData({ localStorage.removeItem('username')
origin: curWinUrl, localStorage.removeItem('password')
storages: ['cookies'] localStorage.removeItem('rememberMe')
})
} }
try{
try {
await userStore.login(loginForm) await userStore.login(loginForm)
await userStore.getInfo() await userStore.getInfo()
if (userStore.user.edustage || userStore.user.edusubject) { if(userStore.user.edustage || userStore.user.edusubject){
ElMessage.success('登录成功') ElMessage.success('登录成功')
ipcRenderer && ipcRenderer.send('openMainWindow') ipcRenderer && ipcRenderer.send('openMainWindow')
} }
else { else{
isSubject.value = true isSubject.value = true
} }
} finally { }finally{
btnLoading.value = false btnLoading.value = false
} }
} }
}) })
} }
const successEditSubject = () => { const successEditSubject = ()=>{
isSubject.value = false isSubject.value = false
ElMessage.success('登录成功') ElMessage.success('登录成功')
ipcRenderer && ipcRenderer.send('openMainWindow') ipcRenderer && ipcRenderer.send('openMainWindow')
} }
const getCookie = async () => { const getCookie = () => {
const username = (await getCookieDetail('username'))[0] const username = localStorage.getItem('username')
const password = (await getCookieDetail('password'))[0] const password = localStorage.getItem('password')
const rememberMe = (await getCookieDetail('rememberMe'))[0] const rememberMe = localStorage.getItem('rememberMe')
loginForm.username = username ? username.value : loginForm.username loginForm.username = username ? username : loginForm.username
loginForm.password = password ? decrypt(password.value) : loginForm.password loginForm.password = password ? decrypt(password) : loginForm.password
loginForm.rememberMe = rememberMe ? Boolean(rememberMe.value) : false loginForm.rememberMe = rememberMe ? Boolean(rememberMe) : false
} }
// cookie onMounted(()=>{
const getCookieDetail = (name) => {
return session.defaultSession.cookies.get({ url: curWinUrl, name })
}
// cookie
const setCookie = (name, value) => {
// 30
let Days = 30;
let times = Math.round(Date.now() / 1000) + Days * 24 * 60 * 60
const cookie = {
url: curWinUrl,
name,
value,
expirationDate: times
}
return session.defaultSession.cookies.set(cookie)
}
onMounted(() => {
// URL
curWinUrl = BrowserWindow.getFocusedWindow().webContents.getURL()
getCookie() getCookie()
}) })
</script> </script>
@ -145,11 +122,9 @@ onMounted(() => {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
-webkit-app-region: drag; -webkit-app-region: drag;
.box-item { .box-item {
width: 444px; width: 444px;
height: 520px; height: 520px;
&.desc { &.desc {
background: #ffffff; background: #ffffff;
border-radius: 12px 0px 0px 12px; border-radius: 12px 0px 0px 12px;
@ -161,17 +136,14 @@ onMounted(() => {
justify-content: flex-start; justify-content: flex-start;
background-color: #003b94; background-color: #003b94;
} }
&.login { &.login {
background: #ffffff; background: #ffffff;
border-radius: 0px 12px 12px 0px; border-radius: 0px 12px 12px 0px;
padding: 34px 42px; padding: 34px 42px;
position: relative; position: relative;
} }
.welcome { .welcome {
padding-top: 35px; padding-top: 35px;
p { p {
color: #ffffff; color: #ffffff;
line-height: 25px; line-height: 25px;
@ -181,13 +153,11 @@ onMounted(() => {
font-size: 26px; font-size: 26px;
} }
} }
.welcome-img { .welcome-img {
margin-top: 20px; margin-top: 20px;
width: 350px; width: 350px;
height: 350px; height: 350px;
} }
.login-title { .login-title {
font-size: 20px; font-size: 20px;
text-align: center; text-align: center;
@ -195,10 +165,8 @@ onMounted(() => {
margin-bottom: 35px; margin-bottom: 35px;
margin-top: 50px; margin-top: 50px;
} }
.login-form { .login-form {
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
.captcha-input { .captcha-input {
width: 60%; width: 60%;
} }
@ -221,20 +189,18 @@ onMounted(() => {
} }
} }
} }
.header-tool { .header-tool {
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
span { span {
padding: 5px 10px; padding: 5px 10px;
cursor: pointer; cursor: pointer;
} }
} }
.el-form-item { .el-form-item {
margin-bottom: 40px; margin-bottom: 40px;
} }
</style> </style>