Merge pull request 'zhuhao_dev' (#5) from zhuhao_dev into main

Reviewed-on: #5
This commit is contained in:
朱浩 2024-07-09 17:50:17 +08:00
commit c544343eec
4 changed files with 96 additions and 28 deletions

View File

@ -25,6 +25,11 @@ export default defineConfig({
target: 'http://192.168.2.52:7863',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
},
'/profile': {
// target: 'http://27.128.240.72:7865',
target: 'https://cqyy.ysaix.com:7868',
changeOrigin: true
}
},
},

View File

@ -2,13 +2,14 @@
<section class="app-main">
<transition mode="out-in" name="fade-transform">
<keep-alive>
<router-view />
<div style="height: 100%;"><router-view /></div>
</keep-alive>
</transition>
</section>
</template>
<script setup></script>
<script setup>
</script>
<style lang="scss" scoped>
.app-main{

View File

@ -27,18 +27,35 @@
<div class="right-section flex">
<div class="header-tool flex">
<span @click="minimizeWindow" title="最小化"><i class="iconfont">&#xe650;</i></span>
<span @click="maximizeWindow" :title="isMaxSize ? '向下还原':'最大化'"><i class="iconfont">{{ isMaxSize ? '&#xe600'
:"&#xe695"}}</i></span>
<span @click="closeWindow" title="关闭"><i class="iconfont">&#xe608;</i></span>
<span title="最小化" @click="minimizeWindow"><i class="iconfont">&#xe650;</i></span>
<span :title="isMaxSize ? '向下还原' : '最大化'" @click="maximizeWindow"
><i class="iconfont">{{ isMaxSize ? '&#xe600' : '&#xe695' }}</i></span
>
<span title="关闭" @click="closeWindow"><i class="iconfont">&#xe608;</i></span>
</div>
<div class="user flex">
<el-icon color="#409EFF">
<!-- <el-icon color="#409EFF">
<UserFilled />
</el-icon>
<div class="user-info flex">
<span>{{ userInfo.nickName }}</span>
<span>{{ userInfo.postnames }}</span>
</div>-->
<div class="avatar-container">
<el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
<div class="avatar-wrapper">
<img :src="userStore.user.avatar" class="user-avatar" style="float: left;" />
<div style="margin-top: 18px; font-size: 0.8em;"> {{ userStore.user.nickName }}</div>
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>个人中心</el-dropdown-item>
<el-dropdown-item divided command="logout">
<span>退出登录</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</div>
@ -48,16 +65,16 @@
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const userInfo = userStore.user
// const { ipcRenderer } = window.electron
console.log(userInfo)
const { ipcRenderer } = window.electron || {}
const radio1 = ref('resource')
const isMaxSize = ref(false)
const router = useRouter();
const router = useRouter()
//
const minimizeWindow = () => {
@ -65,7 +82,7 @@ const minimizeWindow = () => {
}
//
const maximizeWindow = () => {
ipcRenderer.send('maximize-window')
ipcRenderer?.send('maximize-window')
isMaxSize.value = !isMaxSize.value
}
//
@ -76,6 +93,35 @@ const closeWindow = () => {
const changePage = (url) => {
router.push(url)
}
function handleCommand(command) {
switch (command) {
case "setLayout":
setLayout();
break;
case "logout":
logout();
break;
default:
break;
}
}
function logout() {
ElMessageBox.confirm('确认退出系统', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
userStore.logOut().then(() => {
location.href = '/index#/login';
})
}).catch(() => { });
}
const emits = defineEmits(['setLayout'])
function setLayout() {
emits('setLayout');
}
</script>
<style lang="scss" scoped>
@ -155,7 +201,6 @@ const changePage = (url)=>{
}
}
.user {
.user-info {
padding-right: 5px;
align-items: center;
@ -164,4 +209,21 @@ const changePage = (url)=>{
}
}
}
.avatar-container {
-webkit-app-region: no-drag;
.avatar-wrapper {
display: flex;
.user-avatar {
width: 30px;
height: 30px;
border-radius: 10px;
margin-top: 8px;
}
.user-avatar:hover {
cursor: pointer;
}
}
}
</style>

View File

@ -87,7 +87,7 @@ service.interceptors.response.use(res => {
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
isRelogin.show = false;
useUserStore().logOut().then(() => {
location.href = '/index';
location.href = '/index#/login';
})
}).catch(() => {
isRelogin.show = false;