diff --git a/src/main/index.js b/src/main/index.js index c90837e..7b93dc0 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -61,10 +61,12 @@ function createLoginWindow() { function createMainWindow() { mainWindow = new BrowserWindow({ width: 1200, + minWidth: 1200, height: 700, show: false, frame: false, // 无边框 autoHideMenuBar: true, + maximizable: false, icon: join(__dirname, '../../resources/logo2.ico'), ...(process.platform === 'linux' ? { icon } : {}), webPreferences: { diff --git a/src/renderer/src/api/system/user.js b/src/renderer/src/api/system/user.js index b7e9e23..f8b74f0 100644 --- a/src/renderer/src/api/system/user.js +++ b/src/renderer/src/api/system/user.js @@ -50,3 +50,9 @@ export function updateUserInfo(data) { data: data }) } +export function getUserInfo(userId) { + return request({ + url: '/system/user/' + userId, + method: 'get' + }) +} diff --git a/src/renderer/src/components/choose-textbook/index.vue b/src/renderer/src/components/choose-textbook/index.vue index 9c02172..3c2f6a5 100644 --- a/src/renderer/src/components/choose-textbook/index.vue +++ b/src/renderer/src/components/choose-textbook/index.vue @@ -46,7 +46,7 @@ import { onMounted, ref, nextTick, toRaw, reactive } from 'vue'; import useUserStore from '@/store/modules/user' import { listEvaluation } from '@/api/subject' -const BaseUrl = 'https://prev.ysaix.com:7868/' +const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH // 定义要发送的emit事件 const emit = defineEmits(['nodeClick', 'changeBook']) // store diff --git a/src/renderer/src/components/select-subject/index.vue b/src/renderer/src/components/select-subject/index.vue index 52f306a..4c7cd97 100644 --- a/src/renderer/src/components/select-subject/index.vue +++ b/src/renderer/src/components/select-subject/index.vue @@ -1,5 +1,5 @@ - import { ref, watch } from 'vue' +import { ElMessage } from 'element-plus' import { listEvaluation } from '@/api/subject' import { updateUserInfo } from '@/api/system/user' import useUserStore from '@/store/modules/user' const userStore = useUserStore() const { userId, userName } = userStore.user +const { ipcRenderer } = window.electron || {} const props = defineProps({ loginData: { @@ -48,17 +50,11 @@ const props = defineProps({ return {} } }, - modelValue: { - type: Boolean, - default: false - }, }) +const model = defineModel(); const subjectLoading = ref(false) - -// 定义要发送的emit事件 -const emit = defineEmits(['update:modelValue', 'onSuccess']) - +// 默认学段 前端写死 参照web AIx const gradeList = ref([ { label: '高中', @@ -85,7 +81,6 @@ gradeVal.value = gradeList.value[0].value //学科列表数据 const subjectList = ref([]) const allSubject = ref([]) -const dialogVisible = ref(false) //切换年级 const changeGrade = ()=>{ @@ -98,8 +93,8 @@ const changeGrade = ()=>{ // 默认选中第一个学科 subjectVal.value = subjectList.value[0].itemtitle } -// 获取学科数据 +// 获取学科数据 const getSubject = async ()=>{ const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 }) // 所有学科 @@ -119,7 +114,6 @@ const editUserInfo = async () =>{ edustage: gradeVal.value, edusubject: subjectVal.value } - // 修改之后需要重新登录 查询用户信息,否则不登录 查询的用户信息是未修改之前的 // 接口如此,我也不知道为啥要这样 subjectLoading.value = true @@ -128,14 +122,15 @@ const editUserInfo = async () =>{ await updateUserInfo(data) await userStore.login(props.loginData) await userStore.getInfo() + ElMessage.success('登录成功') + model.value = false + ipcRenderer && ipcRenderer.send('openMainWindow') } finally { subjectLoading.value = false } - emit('onSuccess') } -watch(() => props.modelValue, (newVal) => { - dialogVisible.value = newVal +watch(() => model.value, (newVal) => { if(newVal){ getSubject() } diff --git a/src/renderer/src/hooks/useGetHomework.js b/src/renderer/src/hooks/useGetHomework.js index c881f94..ebdabf3 100644 --- a/src/renderer/src/hooks/useGetHomework.js +++ b/src/renderer/src/hooks/useGetHomework.js @@ -11,6 +11,7 @@ let chapterId = null export const useGetHomework = async (node) => { /** * node + * 左侧选择章节的节点数据 */ if (!node) return curNode = node @@ -26,7 +27,10 @@ export const useGetHomework = async (node) => { chapterId = rows[0].id } - return await getHomeWorkList() + return new Promise(async (resolve) =>{ + const res = await getHomeWorkList() + resolve({res,chapterId}) + }) } diff --git a/src/renderer/src/layout/components/Header.vue b/src/renderer/src/layout/components/Header.vue index 799bf33..7f5ecea 100644 --- a/src/renderer/src/layout/components/Header.vue +++ b/src/renderer/src/layout/components/Header.vue @@ -29,7 +29,7 @@ @command="handleCommand" > - + {{ userStore.user.nickName }} @@ -62,6 +62,7 @@ const { ipcRenderer } = window.electron || {} const userStore = useUserStore() const router = useRouter() const currentRoute = ref('') +const dev_api = ref(import.meta.env.VITE_APP_BASE_API) const handleOutLink = (path, type) => { if (!path) return diff --git a/src/renderer/src/store/modules/user.js b/src/renderer/src/store/modules/user.js index 3878eb7..3a45327 100644 --- a/src/renderer/src/store/modules/user.js +++ b/src/renderer/src/store/modules/user.js @@ -37,7 +37,7 @@ const useUserStore = defineStore('user', { return new Promise((resolve, reject) => { getInfo() .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 this.user = user const avatar = user.avatar == '' || user.avatar == null ? defAva : user.avatar diff --git a/src/renderer/src/views/login/index.vue b/src/renderer/src/views/login/index.vue index 2828429..b11d241 100644 --- a/src/renderer/src/views/login/index.vue +++ b/src/renderer/src/views/login/index.vue @@ -47,7 +47,7 @@ /> - +