lyc-dev #59

Merged
lyc merged 6 commits from lyc-dev into main 2024-07-24 15:27:58 +08:00
6 changed files with 93 additions and 57 deletions
Showing only changes of commit e6da6ef65f - Show all commits

View File

@ -4,8 +4,10 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset' import icon from '../../resources/icon.png?asset'
import File from './file' import File from './file'
File({ app, shell, BrowserWindow, ipcMain }) // const handleUpdate = require("./handleUpdate");
File({ app, shell, BrowserWindow, ipcMain })
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
let mainWindow, loginWindow let mainWindow, loginWindow
//登录窗口 //登录窗口
@ -24,9 +26,13 @@ function createLoginWindow() {
nodeIntegration: true nodeIntegration: true
} }
}) })
const loginURL = is.dev ? `http://localhost:5173/#/login` : `file://${__dirname}/index.html/login` // handleUpdate(loginWindow,ipcMain)
const loginURL = is.dev ? `http://localhost:5173/#/login` : join(__dirname, '../renderer/index.html')
loginWindow.loadURL(loginURL) loginWindow.loadURL(loginURL)
loginWindow.webContents.openDevTools()
loginWindow.once('ready-to-show', () => { loginWindow.once('ready-to-show', () => {
loginWindow.show() loginWindow.show()
}) })
@ -61,17 +67,18 @@ function createMainWindow() {
mainWindow.webContents.openDevTools() mainWindow.webContents.openDevTools()
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] )
} else { } else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html')) mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
} }
} }
// 作业窗口相关-开发中 // 作业窗口相关-开发中
let openWindow let linkWindow
function createOpenWin(data) { async function createLinkWin(data) {
if (openWindow) return if (linkWindow) return
openWindow = new BrowserWindow({ linkWindow = new BrowserWindow({
width: 650, width: 650,
height: 500, height: 500,
show: false, show: false,
@ -81,26 +88,26 @@ function createOpenWin(data) {
...(process.platform === 'linux' ? { icon } : {}), ...(process.platform === 'linux' ? { icon } : {}),
webPreferences: { webPreferences: {
sandbox: false, sandbox: false,
nodeIntegration: true nodeIntegration: true,
worldSafeExecuteJavaScript: true,
contextIsolation: true
} }
}) })
let cookieDetails = { ...data.cookieData } let cookieDetails = { ...data.cookieData }
console.log(cookieDetails) await linkWindow.webContents.session.cookies.set(cookieDetails).then(()=>{
openWindow.webContents.session.cookies.set(cookieDetails, (error) => { console.log('Cookie is successful');
if (error) { }).catch( error =>{
console.error('设置cookie出错:', error) console.error('Cookie is error', error);
} else {
console.log('设置cookie成功')
}
}) })
openWindow.loadURL(data.fullPath) linkWindow.loadURL(data.fullPath)
openWindow.once('ready-to-show', () => { linkWindow.once('ready-to-show', () => {
openWindow.show() linkWindow.show()
linkWindow.maximize()
}) })
openWindow.on('closed', () => { linkWindow.on('closed', () => {
openWindow = null linkWindow = null
}) })
} }
@ -158,8 +165,8 @@ app.on('ready', () => {
}) })
//打开作业窗口 //打开作业窗口
ipcMain.on('openWork', (e, data) => { ipcMain.on('openWindow', (e, data) => {
createOpenWin(data) createLinkWin(data)
}) })
createLoginWindow() createLoginWindow()

View File

@ -79,10 +79,6 @@ const subjectList = ref([])
const allSubject = ref([]) const allSubject = ref([])
const dialogVisible = ref(false) const dialogVisible = ref(false)
watch(() => props.modelValue, (newVal) => {
dialogVisible.value = newVal
})
// //
const changeGrade = ()=>{ const changeGrade = ()=>{
// //
@ -120,8 +116,13 @@ const editUserInfo = async () =>{
emit('onSuccess') emit('onSuccess')
} }
watch(() => props.modelValue, (newVal) => {
dialogVisible.value = newVal
if(newVal){
getSubject()
}
})
onMounted(getSubject)
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -138,6 +139,7 @@ onMounted(getSubject)
.dialog-content { .dialog-content {
padding: 30px 20px 10px 30px; padding: 30px 20px 10px 30px;
-webkit-app-region: no-drag;
} }
.dialog-footer{ .dialog-footer{

View File

@ -1,9 +0,0 @@
// 作业
export const homeWorkConfig = {
// host 设置token 等
host: 'https://file.ysaix.com:7868',
name: 'Admin-Token',
// 完整路径
fullPath: 'https://file.ysaix.com:7868/teaching/classtaskassign?titleName=%E4%BD%9C%E4%B8%9A%E5%B8%83%E7%BD%AE'
}

View File

@ -0,0 +1,40 @@
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const baseConfig = {
// Electron 设置cookie
url: 'https://file.ysaix.com:7868',
//cookie 名称 这里为 token
name: 'Admin-Token',
//cookie 值
value: userStore.token,
// 域名
domain: 'file.ysaix.com',
}
// 作业
const homeWork = {
data: { ...baseConfig},
// 完整路径
fullPath: `${baseConfig.url}/teaching/classtaskassign?titleName=%E4%BD%9C%E4%B8%9A%E5%B8%83%E7%BD%AE`
}
// 高考研读
const gk = {
data: { ...baseConfig},
fullPath: `${baseConfig.url}/education/colentrance`
}
// 课标研读
const standard = {
data: { ...baseConfig},
fullPath: `${baseConfig.url}/teaching/chatwithstandard`
}
export default {
homeWork,
gk,
standard
}

View File

@ -31,7 +31,7 @@
</div> </div>
</div> </div>
<!--选择学科--> <!--选择学科-->
<SelectSubject v-model="isSubject" v-if="isSubject" class="select-subject" @onSuccess="successEditSubject" /> <SelectSubject v-model="isSubject" @onSuccess="successEditSubject" />
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
@ -202,7 +202,5 @@ onMounted(()=>{
.el-form-item { .el-form-item {
margin-bottom: 40px; margin-bottom: 40px;
} }
.select-subject{
-webkit-app-region: drag;
}
</style> </style>

View File

@ -7,9 +7,9 @@
<el-image style="width: 80px; height: 110px" :src="curBookImg" /> <el-image style="width: 80px; height: 110px" :src="curBookImg" />
</div> </div>
<div class="top-item"> <div class="top-item">
<el-button class="btn">教材研读</el-button> <el-button class="btn" @click="handleOutLink('standard')">课标研读</el-button>
<el-button class="btn">电子课本</el-button> <el-button class="btn" >电子课本</el-button>
<el-button class="btn">高考研读</el-button> <el-button class="btn" @click="handleOutLink('gk')">高考研读</el-button>
<el-button class="btn">教学大模型</el-button> <el-button class="btn">教学大模型</el-button>
</div> </div>
<el-button type="primary" class="to-class-btn"> <el-button type="primary" class="to-class-btn">
@ -37,7 +37,7 @@
</el-popover> </el-popover>
</div> </div>
<div style="display: flex"> <div style="display: flex">
<el-button @click="handleHomeWork">布置作业</el-button> <el-button @click="handleOutLink('homeWork')">布置作业</el-button>
<el-button @click="isDialogOpen = true">上传资料</el-button> <el-button @click="isDialogOpen = true">上传资料</el-button>
<el-button type="primary" style="margin-left: 10px" @click="createFile">新建课件</el-button> <el-button type="primary" style="margin-left: 10px" @click="createFile">新建课件</el-button>
</div> </div>
@ -73,8 +73,8 @@ import { toTimeText } from '@/utils/date'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile' import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile'
import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue'
import useUserStore from '@/store/modules/user'
import { homeWorkConfig } from '@/utils/config' import outLink from '@/utils/linkConfig'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
export default { export default {
@ -102,7 +102,6 @@ export default {
}, },
// //
curBookImg: '', curBookImg: '',
userStore: ''
} }
}, },
computed: { computed: {
@ -118,7 +117,7 @@ export default {
this.callback(param) this.callback(param)
}) })
this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime') this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime')
this.userStore = useUserStore()
}, },
mounted() { mounted() {
}, },
@ -251,15 +250,14 @@ export default {
this.uploadData.textbookId = data.textBook.curBookId this.uploadData.textbookId = data.textBook.curBookId
this.asyncAllFile() this.asyncAllFile()
}, },
// //
handleHomeWork(){ handleOutLink(key){
ipcRenderer.send('openWork',{ // key linkConfig.js
fullPath: homeWorkConfig.fullPath, let configObj = outLink[key]
cookieData: { //
url: homeWorkConfig.host, ipcRenderer.send('openWindow', {
name: homeWorkConfig.name, fullPath: configObj.fullPath,
value: this.userStore.token cookieData: {...(configObj.data)}
}
}) })
}, },
} }