diff --git a/package.json b/package.json index f9f277c..71aafb4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "electron-updater": "^6.1.7", "element-plus": "^2.7.6", "fabric": "^5.3.0", + "im_electron_sdk": "^8.0.5904", "js-cookie": "^3.0.5", "jsencrypt": "^3.3.2", "jsondiffpatch": "0.6.0", diff --git a/src/main/chat.js b/src/main/chat.js new file mode 100644 index 0000000..b6700f2 --- /dev/null +++ b/src/main/chat.js @@ -0,0 +1,20 @@ +/** + * @description 腾讯云-即时通讯-sdkID + */ +// import { ipcMain } from 'electron' +// const TimMain = require('im_electron_sdk/dist/main') +import TimMain from 'im_electron_sdk/dist/main' +// import {TIMErrCode} from 'im_electron_sdk/dist/enumbers' +const sdkappidDef = 1600034736 // 可以去腾讯云即时通信IM控制台申请 + +// 初始化 +function init(sdkappid = sdkappidDef) { + return new TimMain({sdkappid}) +} +export function initialize(){ + // ipcMain.handle('im-chat:init', (event, sdkappid) => { + // return init(sdkappid) + // }) + return init() +} +export default { initialize, init } diff --git a/src/main/index.js b/src/main/index.js index 7b93dc0..aff4dde 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -3,6 +3,7 @@ import { join } from 'path' import { electronApp, optimizer, is } from '@electron-toolkit/utils' import icon from '../../resources/icon.png?asset' import File from './file' +import chat from './chat' // chat封装 // 代理 electron/remote // 第一步:引入remote import remote from '@electron/remote/main' @@ -229,12 +230,15 @@ app.on('window-all-closed', () => { // 监听全局事件 function handleAll() { + // chat.initialize() // im-chat 实例 + const chatInstance = chat.initialize() // im-chat 实例 // 新窗口创建-监听 ipcMain.on('new-window', (e, data) => { const { id, type } = data const win = BrowserWindow.fromId(id) win.type = type // 绑定独立标识 - remote.enable(win.webContents) // 开启远程服务 + remote.enable(win.webContents) // 开启远程服务 + chatInstance.enable(win.webContents) // 开启im-chat }) // 用于监听-状态管理变化-同步所有窗口 ipcMain.handle('pinia-state-change', (e, storeName, jsonStr) => { @@ -246,4 +250,10 @@ function handleAll() { } } }) + // 用于监听-状态管理变化-初始同步 + ipcMain.handle('pinia-state-init', (e, wid, storeName, jsonStr) => { + // console.log('pinia-state-init', jsonStr) + const win = BrowserWindow.fromId(wid) + win.webContents.send('pinia-state-set', storeName, jsonStr) + }) } diff --git a/src/main/tool.js b/src/main/tool.js deleted file mode 100644 index 8be3a66..0000000 --- a/src/main/tool.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @description: electron 封装的工具函数 - * 消息整理 - * tool-sphere:create 创建-悬浮球-窗口 - */ -import { app, shell, BrowserWindow, ipcMain } from 'electron' -import { is } from '@electron-toolkit/utils' - -// const baseUrl = 'http://localhost:5173/#' // 开发环境使用 -const baseUrl = process.env['ELECTRON_RENDERER_URL']+'/#' // 开发环境使用 -// 所有窗口 -let allWindow = {} -// 其他已有窗口 wins -export function init() { - // 创建工具-悬浮球 - ipcMain.on('tool-sphere:create', async(e, data) => { - // console.log('测试xxxx', data) - await createTools(data) // 执行逻辑 - e.reply('tool-sphere:create-reply', {code: 200, msg: 'success'}) // 返回结果 - }) -} -/** - * @description: 创建工具 - * @param {*} url 路由地址 - * @param {number} [width=800] 窗口宽度 - * @param {number} [height=600] 窗口高度 - * @param {{}} [option={}] 自定义选项 - * @author: zdg - * @date 2021-07-05 14:07:01 - */ - export function createTools({url, width = 800, height = 600, option={}}) { - const { mainWindow } = allWindow||{} // 获取主窗口 - const devUrl = `${baseUrl}${url}` - const buildUrl = `file://${__dirname}/index.html${url}` - const urlAll = is.dev ? devUrl : buildUrl - return new Promise((resolve) => { - let win = new BrowserWindow({ - width, height, - type: 'toolbar', // 创建的窗口类型为工具栏窗口 - frame: false, // 要创建无边框窗口 - resizable: false, // 禁止窗口大小缩放 - transparent: true, // 设置透明 - alwaysOnTop: true, // 窗口是否总是显示在其他窗口之前 - - parent: mainWindow, // 父窗口 - autoClose: true, // 关闭窗口后自动关闭 - webPreferences: { - nodeIntegration: true, // nodeApi调用 - contextIsolation: false, // 沙箱取消 - webSecurity: false // 跨域关闭 - }, - ...option - }) - // console.log(urlAll) - // url = 'https://www.baidu.com' - console.log(urlAll) - win.loadURL(urlAll) - win.setFullScreen(true) // 设置窗口为全屏 - win.setIgnoreMouseEvents(true) // 忽略鼠标事件|使窗口不可选中 - win.once('ready-to-show', () => { - win.show() - resolve(win) - }) - win.on('closed', () => { - win = null - }) - }) -} -// 保存窗口 -export function setWin(win = {}) { - if (win && Object.keys(win).length){ - Object.keys(win).forEach(key => { - if (!allWindow[key]) { // 不存在就保存 - allWindow[key] = win[key] - } - }) - } -} diff --git a/src/preload/index.js b/src/preload/index.js index 9da4869..ffdb7a0 100644 --- a/src/preload/index.js +++ b/src/preload/index.js @@ -1,8 +1,10 @@ import { contextBridge } from 'electron' import { electronAPI } from '@electron-toolkit/preload' - +import TimRender from 'im_electron_sdk/dist/renderer' // im渲染部分实例 // Custom APIs for renderer const api = { + preloadPath: __dirname, // 当前preload地址 + getTimRender: () => new TimRender(), // im渲染部分实例 } // Use `contextBridge` APIs to expose Electron APIs to // renderer only if context isolation is enabled, otherwise diff --git a/src/renderer/src/api/apiService.js b/src/renderer/src/api/apiService.js new file mode 100644 index 0000000..ad79922 --- /dev/null +++ b/src/renderer/src/api/apiService.js @@ -0,0 +1,26 @@ +/** + * @description: 后端接口api + * @author zdg + * @date 2023-07-03 + */ +import request from '@/utils/request' +// /system/user/txCloudSign +export class ApiService { + // zdg: 公共请求-处理(可进行特殊处理) + static publicHttp(url, data, method, option = {}, type) { + method = method || 'get' // 默认GET + const config = { url, method } + if (!!data) config[method=='get'?'params':'data'] = data + if (!!option) Object.assign(config, option) + // 特殊格式处理 + if (type == 'file') config.headers = { 'Content-Type': 'multipart/form-data' } + else if (type == 'json') config.headers = { 'Content-Type': 'application/json' } + else if (type == 'form') config.headers = { 'Content-Type': 'application/x-www-form-urlencoded' } + return request(config) + } +} +// zdg: 腾讯云-即时通讯 +export class imChat { + // 获取腾讯im-chat appid 签名 + static getTxCloudSign = data => ApiService.publicHttp('/system/user/txCloudSign', data) +} diff --git a/src/renderer/src/api/classManage/index.js b/src/renderer/src/api/classManage/index.js index 923c722..dc58160 100644 --- a/src/renderer/src/api/classManage/index.js +++ b/src/renderer/src/api/classManage/index.js @@ -173,3 +173,15 @@ export function endClass(id) { params: {id} }) } +/** + * @description 获取课堂信息 + * @param {*} id + * @returns + */ +export function getClassInfo(id) { + return request({ + url: '/smarttalk/classReserv/selectById', + method: 'get', + params: {id} + }) +} diff --git a/src/renderer/src/components/pdf/index copy.vue b/src/renderer/src/components/pdf/index copy.vue index 48d93e3..45b499a 100644 --- a/src/renderer/src/components/pdf/index copy.vue +++ b/src/renderer/src/components/pdf/index copy.vue @@ -1,8 +1,12 @@ -