lyc-dev #59
|
@ -4,8 +4,10 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
|||
import icon from '../../resources/icon.png?asset'
|
||||
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
|
||||
|
||||
//登录窗口
|
||||
|
@ -24,9 +26,13 @@ function createLoginWindow() {
|
|||
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.webContents.openDevTools()
|
||||
loginWindow.once('ready-to-show', () => {
|
||||
loginWindow.show()
|
||||
})
|
||||
|
@ -67,11 +73,12 @@ function createMainWindow() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 作业窗口相关-开发中
|
||||
let openWindow
|
||||
function createOpenWin(data) {
|
||||
if (openWindow) return
|
||||
openWindow = new BrowserWindow({
|
||||
let linkWindow
|
||||
async function createLinkWin(data) {
|
||||
if (linkWindow) return
|
||||
linkWindow = new BrowserWindow({
|
||||
width: 650,
|
||||
height: 500,
|
||||
show: false,
|
||||
|
@ -81,26 +88,26 @@ function createOpenWin(data) {
|
|||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
sandbox: false,
|
||||
nodeIntegration: true
|
||||
nodeIntegration: true,
|
||||
worldSafeExecuteJavaScript: true,
|
||||
contextIsolation: true
|
||||
}
|
||||
})
|
||||
let cookieDetails = { ...data.cookieData }
|
||||
console.log(cookieDetails)
|
||||
openWindow.webContents.session.cookies.set(cookieDetails, (error) => {
|
||||
if (error) {
|
||||
console.error('设置cookie出错:', error)
|
||||
} else {
|
||||
console.log('设置cookie成功')
|
||||
}
|
||||
await linkWindow.webContents.session.cookies.set(cookieDetails).then(()=>{
|
||||
console.log('Cookie is successful');
|
||||
}).catch( error =>{
|
||||
console.error('Cookie is error', error);
|
||||
})
|
||||
|
||||
openWindow.loadURL(data.fullPath)
|
||||
linkWindow.loadURL(data.fullPath)
|
||||
|
||||
openWindow.once('ready-to-show', () => {
|
||||
openWindow.show()
|
||||
linkWindow.once('ready-to-show', () => {
|
||||
linkWindow.show()
|
||||
linkWindow.maximize()
|
||||
})
|
||||
openWindow.on('closed', () => {
|
||||
openWindow = null
|
||||
linkWindow.on('closed', () => {
|
||||
linkWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -158,8 +165,8 @@ app.on('ready', () => {
|
|||
})
|
||||
|
||||
//打开作业窗口
|
||||
ipcMain.on('openWork', (e, data) => {
|
||||
createOpenWin(data)
|
||||
ipcMain.on('openWindow', (e, data) => {
|
||||
createLinkWin(data)
|
||||
})
|
||||
|
||||
createLoginWindow()
|
||||
|
|
|
@ -79,10 +79,6 @@ const subjectList = ref([])
|
|||
const allSubject = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
dialogVisible.value = newVal
|
||||
})
|
||||
|
||||
//切换年级
|
||||
const changeGrade = ()=>{
|
||||
// 切换年级 过滤出对应学科数据
|
||||
|
@ -120,8 +116,13 @@ const editUserInfo = async () =>{
|
|||
emit('onSuccess')
|
||||
}
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
dialogVisible.value = newVal
|
||||
if(newVal){
|
||||
getSubject()
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(getSubject)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -138,6 +139,7 @@ onMounted(getSubject)
|
|||
|
||||
.dialog-content {
|
||||
padding: 30px 20px 10px 30px;
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
.dialog-footer{
|
||||
|
|
|
@ -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'
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -31,7 +31,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<!--选择学科-->
|
||||
<SelectSubject v-model="isSubject" v-if="isSubject" class="select-subject" @onSuccess="successEditSubject" />
|
||||
<SelectSubject v-model="isSubject" @onSuccess="successEditSubject" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
|
@ -202,7 +202,5 @@ onMounted(()=>{
|
|||
.el-form-item {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.select-subject{
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<el-image style="width: 80px; height: 110px" :src="curBookImg" />
|
||||
</div>
|
||||
<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" @click="handleOutLink('gk')">高考研读</el-button>
|
||||
<el-button class="btn">教学大模型</el-button>
|
||||
</div>
|
||||
<el-button type="primary" class="to-class-btn">
|
||||
|
@ -37,7 +37,7 @@
|
|||
</el-popover>
|
||||
</div>
|
||||
<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 type="primary" style="margin-left: 10px" @click="createFile">新建课件</el-button>
|
||||
</div>
|
||||
|
@ -73,8 +73,8 @@ import { toTimeText } from '@/utils/date'
|
|||
import { ElMessage } from 'element-plus'
|
||||
import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile'
|
||||
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 || {}
|
||||
|
||||
export default {
|
||||
|
@ -102,7 +102,6 @@ export default {
|
|||
},
|
||||
// 当前教材封面图
|
||||
curBookImg: '',
|
||||
userStore: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -118,7 +117,7 @@ export default {
|
|||
this.callback(param)
|
||||
})
|
||||
this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime')
|
||||
this.userStore = useUserStore()
|
||||
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
|
@ -251,15 +250,14 @@ export default {
|
|||
this.uploadData.textbookId = data.textBook.curBookId
|
||||
this.asyncAllFile()
|
||||
},
|
||||
// 布置组后也
|
||||
handleHomeWork(){
|
||||
ipcRenderer.send('openWork',{
|
||||
fullPath: homeWorkConfig.fullPath,
|
||||
cookieData: {
|
||||
url: homeWorkConfig.host,
|
||||
name: homeWorkConfig.name,
|
||||
value: this.userStore.token
|
||||
}
|
||||
// 打开外部链接
|
||||
handleOutLink(key){
|
||||
// key 对应的 linkConfig.js 外部链接配置
|
||||
let configObj = outLink[key]
|
||||
// 通知主进程
|
||||
ipcRenderer.send('openWindow', {
|
||||
fullPath: configObj.fullPath,
|
||||
cookieData: {...(configObj.data)}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue