Merge branch 'main' into zhuhao_dev
This commit is contained in:
commit
6dfb2d4a8a
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
// import { ipcMain } from 'electron'
|
// import { ipcMain } from 'electron'
|
||||||
// const TimMain = require('im_electron_sdk/dist/main')
|
// const TimMain = require('im_electron_sdk/dist/main')
|
||||||
import TimMain from 'im_electron_sdk/dist/main'
|
// import TimMain from 'im_electron_sdk/dist/main'
|
||||||
// import {TIMErrCode} from 'im_electron_sdk/dist/enumbers'
|
// import {TIMErrCode} from 'im_electron_sdk/dist/enumbers'
|
||||||
const sdkappidDef = 1600034736 // 可以去腾讯云即时通信IM控制台申请
|
const sdkappidDef = 1600034736 // 可以去腾讯云即时通信IM控制台申请
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { join } from 'path'
|
||||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
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'
|
||||||
import chat from './chat' // chat封装
|
// import chat from './chat' // chat封装
|
||||||
// 代理 electron/remote
|
// 代理 electron/remote
|
||||||
// 第一步:引入remote
|
// 第一步:引入remote
|
||||||
import remote from '@electron/remote/main'
|
import remote from '@electron/remote/main'
|
||||||
|
@ -230,15 +230,14 @@ app.on('window-all-closed', () => {
|
||||||
|
|
||||||
// 监听全局事件
|
// 监听全局事件
|
||||||
function handleAll() {
|
function handleAll() {
|
||||||
// chat.initialize() // im-chat 实例
|
// const chatInstance = chat.initialize() // im-chat 实例
|
||||||
const chatInstance = chat.initialize() // im-chat 实例
|
|
||||||
// 新窗口创建-监听
|
// 新窗口创建-监听
|
||||||
ipcMain.on('new-window', (e, data) => {
|
ipcMain.on('new-window', (e, data) => {
|
||||||
const { id, type } = data
|
const { id, type } = data
|
||||||
const win = BrowserWindow.fromId(id)
|
const win = BrowserWindow.fromId(id)
|
||||||
win.type = type // 绑定独立标识
|
win.type = type // 绑定独立标识
|
||||||
remote.enable(win.webContents) // 开启远程服务
|
remote.enable(win.webContents) // 开启远程服务
|
||||||
chatInstance.enable(win.webContents) // 开启im-chat
|
// chatInstance.enable(win.webContents) // 开启im-chat
|
||||||
})
|
})
|
||||||
// 用于监听-状态管理变化-同步所有窗口
|
// 用于监听-状态管理变化-同步所有窗口
|
||||||
ipcMain.handle('pinia-state-change', (e, storeName, jsonStr) => {
|
ipcMain.handle('pinia-state-change', (e, storeName, jsonStr) => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { contextBridge } from 'electron'
|
import { contextBridge } from 'electron'
|
||||||
import { electronAPI } from '@electron-toolkit/preload'
|
import { electronAPI } from '@electron-toolkit/preload'
|
||||||
import TimRender from 'im_electron_sdk/dist/renderer' // im渲染部分实例
|
// import TimRender from 'im_electron_sdk/dist/renderer' // im渲染部分实例
|
||||||
// Custom APIs for renderer
|
// Custom APIs for renderer
|
||||||
const api = {
|
const api = {
|
||||||
preloadPath: __dirname, // 当前preload地址
|
preloadPath: __dirname, // 当前preload地址
|
||||||
getTimRender: () => new TimRender(), // im渲染部分实例
|
// getTimRender: () => new TimRender(), // im渲染部分实例
|
||||||
}
|
}
|
||||||
// Use `contextBridge` APIs to expose Electron APIs to
|
// Use `contextBridge` APIs to expose Electron APIs to
|
||||||
// renderer only if context isolation is enabled, otherwise
|
// renderer only if context isolation is enabled, otherwise
|
||||||
|
|
|
@ -74,7 +74,9 @@ export class ImChat {
|
||||||
try {
|
try {
|
||||||
if(!API) reject('preload api获取失败, 初始化-未完成')
|
if(!API) reject('preload api获取失败, 初始化-未完成')
|
||||||
this.timChat = await API.getTimRender()
|
this.timChat = await API.getTimRender()
|
||||||
await this.timChat.TIMInit()
|
await this.timChat.TIMInit({
|
||||||
|
// electron_log:true,
|
||||||
|
})
|
||||||
console.log('[im-chat]:初始化成功')
|
console.log('[im-chat]:初始化成功')
|
||||||
this.status.isConnect = true
|
this.status.isConnect = true
|
||||||
this.setConfig() // 设置日志级别
|
this.setConfig() // 设置日志级别
|
||||||
|
@ -150,6 +152,7 @@ export class ImChat {
|
||||||
return this.timChat.TIMLogout().then(res => {
|
return this.timChat.TIMLogout().then(res => {
|
||||||
console.log('登出成功', res)
|
console.log('登出成功', res)
|
||||||
this.status.isLogin = false
|
this.status.isLogin = false
|
||||||
|
this.timChat.TIMUninit() // 反初始化
|
||||||
return res
|
return res
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log('登出失败', error)
|
console.log('登出失败', error)
|
||||||
|
|
|
@ -13,12 +13,14 @@ export function shareStorePlugin({store}) {
|
||||||
// 在存储变化的时候执行
|
// 在存储变化的时候执行
|
||||||
// const storeName = store.$id
|
// const storeName = store.$id
|
||||||
// const storeName = mutation.storeId
|
// const storeName = mutation.storeId
|
||||||
const { storeId: storeName, payload, events, type } = mutation // direct
|
|
||||||
// if (!Object.keys(payload).length) return
|
|
||||||
if (type != 'direct') return
|
|
||||||
// 用于多窗口共享(需要共享的状态名称)
|
// 用于多窗口共享(需要共享的状态名称)
|
||||||
const names = ['tool']
|
const names = ['tool']
|
||||||
if (names.includes(storeName)) stateSync(storeName, events.key, events.newValue) // 需要同步
|
if (names.includes(storeName)) {
|
||||||
|
const { storeId: storeName, payload, events, type } = mutation // direct
|
||||||
|
// if (!Object.keys(payload).length) return
|
||||||
|
if (type != 'direct' || !events || Array.isArray(events) || !events.key) return
|
||||||
|
stateSync(storeName, events.key, events.newValue) // 需要同步
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// 暴露方法-手动同步
|
// 暴露方法-手动同步
|
||||||
store.stateSync = (storeName, key, value) => {
|
store.stateSync = (storeName, key, value) => {
|
||||||
|
|
|
@ -99,10 +99,10 @@ const switchPageMode = () => {
|
||||||
pdfCanvaslist.value.initPdf('rest')
|
pdfCanvaslist.value.initPdf('rest')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
toolState.isPdfWin=true //设置打开pdf窗口
|
toolState.isPdfWin=true //设置打开pdf窗口
|
||||||
// pdfObj.pdfUrl = getStaticUrl(route.query.path, 'user', 'selfFile', true) //线上
|
pdfObj.pdfUrl = getStaticUrl(route.query.path, 'user', 'selfFile', true) //线上
|
||||||
pdfObj.pdfUrl = getStaticUrl('aaa.pdf', 'user', 'selfFile', true) //本地
|
// pdfObj.pdfUrl = getStaticUrl('aaa.pdf', 'user', 'selfFile', true) //本地
|
||||||
textbookId.value = route.query.textbookId
|
textbookId.value = route.query.textbookId
|
||||||
pdfObj.bookId=textbookId.value
|
pdfObj.bookId=textbookId.value
|
||||||
//初始化获取接口数据
|
//初始化获取接口数据
|
||||||
|
@ -164,4 +164,4 @@ const getUniqueArrayByLastOccurrence=(array)=> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<upvote-vue ref="upvoteRef"></upvote-vue>
|
<upvote-vue ref="upvoteRef"></upvote-vue>
|
||||||
|
|
||||||
<!-- im-chat 聊天组件 -->
|
<!-- im-chat 聊天组件 -->
|
||||||
<im-chat ref="imChatRef" @change="chatChange" />
|
<!-- <im-chat ref="imChatRef" @change="chatChange" /> -->
|
||||||
|
|
||||||
<!-- 底部工具栏 -->
|
<!-- 底部工具栏 -->
|
||||||
<div class="tool-bottom-all" @mouseenter="mouseChange(0)" @mouseleave="mouseChange(1)">
|
<div class="tool-bottom-all" @mouseenter="mouseChange(0)" @mouseleave="mouseChange(1)">
|
||||||
|
@ -78,7 +78,8 @@ const btnList = [ // 工具栏按钮列表
|
||||||
// === 页面加载完毕 ===
|
// === 页面加载完毕 ===
|
||||||
onMounted(async() => {
|
onMounted(async() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getClassInfo() // 获取课堂详情 ex3
|
classManageApi.startClass(classObj.id) // 开始上课-临时
|
||||||
|
// getClassInfo() // 获取课堂详情 ex3
|
||||||
resetStatus() // 开启重置状态-监听
|
resetStatus() // 开启重置状态-监听
|
||||||
}, 200);
|
}, 200);
|
||||||
})
|
})
|
||||||
|
@ -88,12 +89,13 @@ onMounted(async() => {
|
||||||
const getClassInfo = async () => {
|
const getClassInfo = async () => {
|
||||||
const { data } = await classManageApi.getClassInfo(classObj.id)
|
const { data } = await classManageApi.getClassInfo(classObj.id)
|
||||||
classObj.data = data
|
classObj.data = data
|
||||||
|
// console.log('classObj:', classObj)
|
||||||
if(!data.ex3 || data.ex3 == 'undefined') { // 无群直接创建
|
if(!data.ex3 || data.ex3 == 'undefined') { // 无群直接创建
|
||||||
await imChatRef.value.imChatObj.imChat.createGroup(data.className)
|
await imChatRef.value.imChatObj.imChat.createGroup(data.className)
|
||||||
const timGroupId = imChatRef.value.imChatObj.imChat.timGroupId
|
const timGroupId = imChatRef.value.imChatObj.imChat.timGroupId
|
||||||
classManageApi.startClass(classObj.id, timGroupId) // 开始上课
|
classManageApi.startClass(classObj.id, timGroupId) // 开始上课
|
||||||
} else { // 已创建群
|
} else { // 已创建群
|
||||||
// console.log('已创建群: ', data.ex3)
|
console.log('已创建群: ', data.ex3)
|
||||||
imChatRef.value.imChatObj.imChat.timGroupId = data.ex3
|
imChatRef.value.imChatObj.imChat.timGroupId = data.ex3
|
||||||
// imChatRef.value.imChatObj.imChat.setGroupMsgReceive(data.ex3)
|
// imChatRef.value.imChatObj.imChat.setGroupMsgReceive(data.ex3)
|
||||||
}
|
}
|
||||||
|
@ -181,16 +183,16 @@ const sideChange = async o => {
|
||||||
}).then(async() => {
|
}).then(async() => {
|
||||||
await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() // 发送下课消息
|
await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() // 发送下课消息
|
||||||
// const elMsg = ElMessage.warning({duration:0,message:'正在下课...'})
|
// const elMsg = ElMessage.warning({duration:0,message:'正在下课...'})
|
||||||
const elMsg = ElLoading.service({lock: true, text: '正在下课...', background: 'rgba(0, 0, 0, 0.7)'})
|
// const elMsg = ElLoading.service({lock: true, text: '正在下课...', background: 'rgba(0, 0, 0, 0.7)'})
|
||||||
// 延迟2秒后关闭窗口,如果马上解散群,会导致群组不存在
|
// 延迟2秒后关闭窗口,如果马上解散群,会导致群组不存在
|
||||||
setTimeout(async() => {
|
setTimeout(async() => {
|
||||||
elMsg.close()
|
// elMsg.close()
|
||||||
toolStore.isToolWin = false
|
toolStore.isToolWin = false
|
||||||
await classManageApi.endClass(route.query.reservId)
|
await classManageApi.endClass(route.query.reservId)
|
||||||
await imChatRef.value?.deleteGroup() // 解散群
|
await imChatRef.value?.deleteGroup() // 解散群
|
||||||
await imChatRef.value?.logout() // 退出im
|
await imChatRef.value?.logout() // 退出im
|
||||||
ipcMsgSend('tool-sphere:close') // 关闭窗口
|
ipcMsgSend('tool-sphere:close') // 关闭窗口
|
||||||
}, 2000);
|
}, 200);
|
||||||
|
|
||||||
// isOver.value = false
|
// isOver.value = false
|
||||||
// setIgnore(true) // 开启窗口鼠标-穿透
|
// setIgnore(true) // 开启窗口鼠标-穿透
|
||||||
|
|
Loading…
Reference in New Issue