zhuhao_dev #122

Merged
zhuhao merged 5 commits from zhuhao_dev into main 2024-08-13 11:28:29 +08:00
3 changed files with 45 additions and 16 deletions
Showing only changes of commit fe26d348fc - Show all commits

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/, '')
} }

View File

@ -42,6 +42,11 @@ const updateInit = (win) => {
logger.error('检查更新失败') logger.error('检查更新失败')
}) })
// 监听下载进度
autoUpdater.on('download-progress', (progressObj) => {
win.webContents.send('update-app-progress', progressObj.percent);
});
// 跟新下载完毕 // 跟新下载完毕
autoUpdater.on('update-downloaded', () => { autoUpdater.on('update-downloaded', () => {
dialog dialog

View File

@ -7,24 +7,47 @@
<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 :is-has-max="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 v-model="loginForm.rememberMe" class="flex mb-5">记住密码</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>
</div> </div>
<el-dialog
v-model="showDownLoading"
width="500"
:show-close="false"
:close-on-click-modal="false"
:close-on-press-escape="false"
align-center
>
<el-progress
:text-inside="true"
:stroke-width="22"
:percentage="downloadProp"
:show-text="false"
status="success"
/>
</el-dialog>
<!--选择学科--> <!--选择学科-->
<SelectSubject v-model="isSubject" :loginData="loginForm" @onSuccess="successEditSubject"/> <SelectSubject v-model="isSubject" :login-data="loginForm" @on-success="successEditSubject" />
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
@ -36,7 +59,8 @@ 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 { session } = require('@electron/remote') const { session } = require('@electron/remote')
const downloadProp = ref(0)
const showDownLoading = ref(false)
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
const formRef = ref() const formRef = ref()
const userStore = useUserStore() const userStore = useUserStore()
@ -55,7 +79,11 @@ const rules = reactive({
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }] password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }]
}) })
let curWinUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH; let curWinUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
ipcRenderer.on('update-app-progress', (e, prop) => {
downloadProp.value = prop
showDownLoading.value = prop !== 100
})
// //
const submitForm = async (formEl) => { const submitForm = async (formEl) => {
@ -83,11 +111,9 @@ const submitForm = async (formEl) => {
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
} }
@ -118,7 +144,7 @@ const getCookieDetail = (name) => {
// cookie // cookie
const setCookie = (name, value) => { const setCookie = (name, value) => {
// 30 // 30
let Days = 30; let Days = 30
let times = Math.round(Date.now() / 1000) + Days * 24 * 60 * 60 let times = Math.round(Date.now() / 1000) + Days * 24 * 60 * 60
const cookie = { const cookie = {
url: curWinUrl, url: curWinUrl,
@ -129,8 +155,6 @@ const setCookie = (name, value) => {
return session.defaultSession.cookies.set(cookie) return session.defaultSession.cookies.set(cookie)
} }
onMounted(() => { onMounted(() => {
localStorage.clear() localStorage.clear()
getCookie() getCookie()