This commit is contained in:
zdg 2024-08-16 10:15:31 +08:00
commit 7fb98309fb
12 changed files with 39 additions and 38 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "aix-win", "name": "aix-win",
"version": "1.1.0", "version": "1.1.1",
"description": "An Electron application with Vue", "description": "An Electron application with Vue",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "example.com", "author": "example.com",

View File

@ -62,10 +62,12 @@ function createLoginWindow() {
function createMainWindow() { function createMainWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 1200, width: 1200,
minWidth: 1200,
height: 700, height: 700,
show: false, show: false,
frame: false, // 无边框 frame: false, // 无边框
autoHideMenuBar: true, autoHideMenuBar: true,
maximizable: false,
icon: join(__dirname, '../../resources/logo2.ico'), icon: join(__dirname, '../../resources/logo2.ico'),
...(process.platform === 'linux' ? { icon } : {}), ...(process.platform === 'linux' ? { icon } : {}),
webPreferences: { webPreferences: {

View File

@ -50,3 +50,9 @@ export function updateUserInfo(data) {
data: data data: data
}) })
} }
export function getUserInfo(userId) {
return request({
url: '/system/user/' + userId,
method: 'get'
})
}

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="500" <el-dialog v-model="model" append-to-body :show-close="false" width="500"
top="25vh" top="25vh"
:close-on-click-modal="false" :close-on-click-modal="false"
:close-on-press-escape="false" :close-on-press-escape="false"
@ -34,12 +34,14 @@
<script setup> <script setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { listEvaluation } from '@/api/subject' import { listEvaluation } from '@/api/subject'
import { updateUserInfo } from '@/api/system/user' import { updateUserInfo } from '@/api/system/user'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
const userStore = useUserStore() const userStore = useUserStore()
const { userId, userName } = userStore.user const { userId, userName } = userStore.user
const { ipcRenderer } = window.electron || {}
const props = defineProps({ const props = defineProps({
loginData: { loginData: {
@ -48,17 +50,11 @@ const props = defineProps({
return {} return {}
} }
}, },
modelValue: {
type: Boolean,
default: false
},
}) })
const model = defineModel();
const subjectLoading = ref(false) const subjectLoading = ref(false)
// web AIx
// emit
const emit = defineEmits(['update:modelValue', 'onSuccess'])
const gradeList = ref([ const gradeList = ref([
{ {
label: '高中', label: '高中',
@ -85,7 +81,6 @@ gradeVal.value = gradeList.value[0].value
// //
const subjectList = ref([]) const subjectList = ref([])
const allSubject = ref([]) const allSubject = ref([])
const dialogVisible = ref(false)
// //
const changeGrade = ()=>{ const changeGrade = ()=>{
@ -98,8 +93,8 @@ const changeGrade = ()=>{
// //
subjectVal.value = subjectList.value[0].itemtitle subjectVal.value = subjectList.value[0].itemtitle
} }
//
//
const getSubject = async ()=>{ const getSubject = async ()=>{
const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 }) const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 })
// //
@ -119,7 +114,6 @@ const editUserInfo = async () =>{
edustage: gradeVal.value, edustage: gradeVal.value,
edusubject: subjectVal.value edusubject: subjectVal.value
} }
// //
// //
subjectLoading.value = true subjectLoading.value = true
@ -128,14 +122,15 @@ const editUserInfo = async () =>{
await updateUserInfo(data) await updateUserInfo(data)
await userStore.login(props.loginData) await userStore.login(props.loginData)
await userStore.getInfo() await userStore.getInfo()
ElMessage.success('登录成功')
model.value = false
ipcRenderer && ipcRenderer.send('openMainWindow')
} finally { } finally {
subjectLoading.value = false subjectLoading.value = false
} }
emit('onSuccess')
} }
watch(() => props.modelValue, (newVal) => { watch(() => model.value, (newVal) => {
dialogVisible.value = newVal
if(newVal){ if(newVal){
getSubject() getSubject()
} }

View File

@ -29,7 +29,7 @@
@command="handleCommand" @command="handleCommand"
> >
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<img :src="userStore.user.avatar" class="user-avatar" style="float: left" /> <img :src="dev_api + userStore.user.avatar" class="user-avatar" style="float: left" />
<div style="margin-top: 18px; font-size: 0.8em">{{ userStore.user.nickName }}</div> <div style="margin-top: 18px; font-size: 0.8em">{{ userStore.user.nickName }}</div>
</div> </div>
<template #dropdown> <template #dropdown>
@ -62,6 +62,7 @@ const { ipcRenderer } = window.electron || {}
const userStore = useUserStore() const userStore = useUserStore()
const router = useRouter() const router = useRouter()
const currentRoute = ref('') const currentRoute = ref('')
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
const handleOutLink = (path, type) => { const handleOutLink = (path, type) => {
if (!path) return if (!path) return

View File

@ -37,7 +37,7 @@ const useUserStore = defineStore('user', {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo() getInfo()
.then((res) => { .then((res) => {
res.user.avatar = import.meta.env.VITE_APP_BASE_API + res.user.avatar // res.user.avatar = import.meta.env.VITE_APP_BASE_API + res.user.avatar
const user = res.user const user = res.user
this.user = user this.user = user
const avatar = user.avatar == '' || user.avatar == null ? defAva : user.avatar const avatar = user.avatar == '' || user.avatar == null ? defAva : user.avatar

View File

@ -47,7 +47,7 @@
/> />
</el-dialog> </el-dialog>
<!--选择学科--> <!--选择学科-->
<SelectSubject v-model="isSubject" :login-data="loginForm" @on-success="successEditSubject" /> <SelectSubject v-model="isSubject" :login-data="loginForm" />
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
@ -121,12 +121,6 @@ const submitForm = async (formEl) => {
}) })
} }
const successEditSubject = () => {
isSubject.value = false
ElMessage.success('登录成功')
ipcRenderer && ipcRenderer.send('openMainWindow')
}
const getCookie = async () => { const getCookie = async () => {
const username = (await getCookieDetail('username'))[0] const username = (await getCookieDetail('username'))[0]
const password = (await getCookieDetail('password'))[0] const password = (await getCookieDetail('password'))[0]

View File

@ -3,8 +3,8 @@
<ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" /> <ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" />
<div class="page-right"> <div class="page-right">
<div class="header-top flex"> <div class="header-top flex">
<div class="textbook-img"> <div class="textbook-img" @click="navtoPdf">
<el-image style="width: 80px; height: 110px" :src="curBookImg" @click="navtoPdf" /> <el-image style="width: 80px; height: 110px" :src="curBookImg" />
<el-progress <el-progress
v-if="downloadNum > 0 && downloadNum < 100" v-if="downloadNum > 0 && downloadNum < 100"
style="position: absolute; left: 0; z-index: 999" style="position: absolute; left: 0; z-index: 999"

View File

@ -11,7 +11,7 @@
<!-- 裁剪+效果 --> <!-- 裁剪+效果 -->
<div class="box"> <div class="box">
<div class="box_1"> <div class="box_1">
<img :src="filePath" ref="image" /> <img :src="dev_api + filePath" ref="image" />
</div> </div>
<!--裁剪完的图片--> <!--裁剪完的图片-->
@ -60,6 +60,7 @@ export default {
}, },
}, },
setup(props, context) { setup(props, context) {
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
// //
const uploadImg = (e) => { const uploadImg = (e) => {
@ -163,7 +164,7 @@ export default {
// //
onMounted(() => { onMounted(() => {
if (props.filePath) { if (props.filePath) {
dataFile.image.src = props.filePath; dataFile.image.src = dev_api.value + props.filePath;
copper(); copper();
} }
}); });
@ -175,6 +176,7 @@ export default {
uploadImg, uploadImg,
upLoading, upLoading,
cancle, cancle,
dev_api
}; };
}, },
}; };

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-row :gutter="20" style="display: flex;flex-wrap: nowrap;justify-content: start"> <el-row :gutter="20" style="display: flex;flex-wrap: nowrap;justify-content: start">
<el-col :xs="24" style="min-width: 260px;max-width: 260px"> <el-col :xs="24" style="min-width: 260px;max-width: 300px">
<el-card class="box-card"> <el-card class="box-card">
<template v-slot:header> <template v-slot:header>
<div class="clearfix"> <div class="clearfix">
@ -97,10 +97,10 @@ const state = reactive({
postGroup: {} postGroup: {}
}) })
function getUser() { async function getUser() {
getUserProfile().then((response) => { getUserProfile().then((response) => {
response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar // response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar
state.user = response.data Object.assign(state.user,response.data)
state.roleGroup = response.roleGroup state.roleGroup = response.roleGroup
state.postGroup = response.postGroup state.postGroup = response.postGroup
}) })

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="user-info-head" @click="editCropper()"> <div class="user-info-head" @click="editCropper()">
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" /> <img :src="dev_api + options.img" title="点击上传头像" class="img-circle img-lg" />
<el-dialog <el-dialog
v-model="open" v-model="open"
append-to-body append-to-body
@ -28,6 +28,7 @@ const userStore = useUserStore()
const open = ref(false) const open = ref(false)
const visible = ref(false) const visible = ref(false)
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
// //
const options = reactive({ const options = reactive({
@ -56,7 +57,7 @@ function uploadImg(data) {
formData.append('avatarfile', data) formData.append('avatarfile', data)
uploadAvatar(formData).then((response) => { uploadAvatar(formData).then((response) => {
open.value = false open.value = false
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl options.img = response.imgUrl
userStore.user.avatar = options.img userStore.user.avatar = options.img
ElMessage({ ElMessage({
message: '上传成功', message: '上传成功',
@ -68,7 +69,7 @@ function uploadImg(data) {
/** 关闭窗口 */ /** 关闭窗口 */
function closeDialog() { function closeDialog() {
// options.img = userStore.avatar options.img = userStore.user.avatar
options.visible = false options.visible = false
} }
const cancle = () => { const cancle = () => {

View File

@ -129,7 +129,7 @@ function submit() {
props.user.avatar = userStore.user.avatar props.user.avatar = userStore.user.avatar
updateUserInfo(props.user).then((response) => { updateUserInfo(props.user).then((response) => {
if(response.code == 200){ if(response.code == 200){
userStore.login({username:props.user.phonenumber,password:props.user.plainpwd}).then(() => { userStore.login({username:props.user.userName,password:props.user.plainpwd}).then(() => {
userStore.getInfo().then(res => { userStore.getInfo().then(res => {
if(res.code === 200){ if(res.code === 200){
ElMessage.success('修改成功') ElMessage.success('修改成功')