diff --git a/package.json b/package.json index 45db03d..99b4789 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "electron-log": "^5.1.7", "electron-updater": "^6.1.7", "element-plus": "^2.7.6", - "fabric": "5.3.0", + "fabric": "^5.3.0", "js-cookie": "^3.0.5", "jsencrypt": "^3.3.2", "jsondiffpatch": "0.6.0", diff --git a/src/main/index.js b/src/main/index.js index ca7c16c..673da1f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -31,17 +31,17 @@ function createLoginWindow() { preload: join(__dirname, '../preload/index.js'), sandbox: false, nodeIntegration: true, - contextIsolation: false, // 沙箱取消 + contextIsolation: false // 沙箱取消 } }) - loginWindow.type = 'login' // 唯一标识 + loginWindow.type = 'login' // 唯一标识 // handleUpdate(loginWindow,ipcMain) // const loginURL = is.dev ? `http://localhost:5173/#/login` : `file://${__dirname}/index.html/#/login` // loginWindow.loadURL(loginURL) if (is.dev && process.env['ELECTRON_RENDERER_URL']) { loginWindow.loadURL('http://localhost:5173/#/login') } else { - loginWindow.loadFile(join(__dirname, '../renderer/index.html'), {hash: 'login'}) + loginWindow.loadFile(join(__dirname, '../renderer/index.html'), { hash: 'login' }) updateInit(loginWindow) } @@ -70,17 +70,18 @@ function createMainWindow() { preload: join(__dirname, '../preload/index.js'), sandbox: false, // nodeIntegration: true, - nodeIntegration: true, // nodeApi调用 - contextIsolation: false, // 沙箱取消 + nodeIntegration: true, // nodeApi调用 + contextIsolation: false // 沙箱取消 // webSecurity: false // 跨域关闭 } }) - mainWindow.type = 'main' // 唯一标识 + mainWindow.type = 'main' // 唯一标识 mainWindow.on('ready-to-show', () => { mainWindow.show() }) mainWindow.on('closed', () => { - setTimeout(() => { // 延迟销毁 + setTimeout(() => { + // 延迟销毁 mainWindow = null }, 1000) // app.quit() // 主窗口关闭-结束所有进程 @@ -92,7 +93,7 @@ function createMainWindow() { mainWindow.webContents.openDevTools() if (is.dev && process.env['ELECTRON_RENDERER_URL']) { - mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] ) + mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) } else { mainWindow.loadFile(join(__dirname, '../renderer/index.html')) } @@ -102,7 +103,6 @@ function createMainWindow() { remote.enable(mainWindow.webContents) } - // 作业窗口相关-开发中 let linkWindow async function createLinkWin(data) { @@ -120,14 +120,17 @@ async function createLinkWin(data) { contextIsolation: true } }) - linkWindow.type = 'link' // 唯一标识 + linkWindow.type = 'link' // 唯一标识 let cookieDetails = { ...data.cookieData } - await linkWindow.webContents.session.cookies.set(cookieDetails).then(()=>{ - console.log('Cookie is successful'); - }).catch( error =>{ - console.error('Cookie is error', error); - }) - + await linkWindow.webContents.session.cookies + .set(cookieDetails) + .then(() => { + console.log('Cookie is successful') + }) + .catch((error) => { + console.error('Cookie is error', error) + }) + data.fullPath = data.fullPath.replaceAll('//', '/') linkWindow.loadURL(data.fullPath) linkWindow.once('ready-to-show', () => { @@ -169,9 +172,10 @@ app.on('ready', () => { } if (mainWindow) { mainWindow.close() // 先发出这个关闭指令 - setTimeout(() => { // + setTimeout(() => { + // mainWindow.destroy() - }, 200); + }, 200) } }) @@ -199,21 +203,19 @@ app.on('ready', () => { createLinkWin(data) }) // 新窗口创建-监听 - ipcMain.on('new-window', (e,data) => { + ipcMain.on('new-window', (e, data) => { const { id, type } = data const win = BrowserWindow.fromId(id) win.type = type // 绑定独立标识 remote.enable(win.webContents) // 开启远程服务 }) - // 打开-登录窗口 createLoginWindow() app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createLoginWindow() }) - }) // Quit when all windows are closed, except on macOS. There, it's common diff --git a/src/renderer/src/directive/drag.js b/src/renderer/src/directive/drag.js new file mode 100644 index 0000000..9eddc29 --- /dev/null +++ b/src/renderer/src/directive/drag.js @@ -0,0 +1,81 @@ +/** + * @description: v-drag + * @author zdg + * @date 2023-06-07 + */ +// 工具包 +const utils = { + // Creates an event handler that can be used in Vue code + // setup start moving end + vueDragEvent: (el, action) => { + el.dispatchEvent(new Event(`drag-${action}`)) + }, + dragStart: (el, target, axis, snap, e) => { + // el.style.cursor = 'move' + // el.onmousedown = function (e) { + // const disX = e.clientX - el.offsetLeft + // const disY = e.clientY - el.offsetTop + // document.onmousemove = function (e) { + // const left = e.clientX - disX + // const top= e.clientY - disY + // } + // } + }, +} +// 首次向元素添加可拖动配置 | Add draggable configuration to element for the first time +const mountedHook = (el, binding) => { + console.log(el, binding) + const value = binding.value || {} + const handleSelector = value instanceof Object ? value.el : value // 获取元素 + const isOpen = value instanceof Object ? value.open || true : true // 是否开启拖拽 默认:开启 + const handleArray = [] // 拖拽元素 + if (!isOpen) return false // 没有开启不加载后面的代码 + let axis + // Store all the DOM elements that will be used as handles. + // They can be declared using a string with a CSS tag, class or id, or using Vue refs. + if (!!handleSelector) { + if (handleSelector instanceof HTMLElement) { + handleArray.push(handleSelector); + } else { + // handleArray.push(document.querySelectorAll(handleSelector)); + document.querySelectorAll(handleSelector).forEach((child) => { + handleArray.push(child); + }); + } + } + if (handleArray.length !== 0) { + // Define move element and apply CSS class + // el.classList.add(window.data.class.usesHandle); + + handleArray.forEach((grabElement) => { + // Apply CSS class to each grab element + // grabElement.classList.add(window.data.class.handle); + + // Add events to start drag with handle + grabElement.onmousedown = (e) => utils.dragStart(grabElement, el, axis, e); + grabElement.ontouchstart = (e) => utils.dragStart(grabElement, el, axis, e); + }); + } else { + // Add events to start drag without handle + el.onmousedown = (e) => utils.dragStart(el, el, axis, e); + el.ontouchstart = (e) => utils.dragStart(el, el, axis, e); + } + // Vue event on setup + utils.vueDragEvent(el, 'setup') +} +export default { + // Hooks for Vue3 + mounted(el, binding) { + mountedHook(el, binding) + }, + // Hooks for Vue2 + inserted(el, binding) { + mountedHook(el, binding) + }, + + update(el, binding){ + }, + updated(el, binding){ + + }, +} \ No newline at end of file diff --git a/src/renderer/src/layout/components/AppMain.vue b/src/renderer/src/layout/components/AppMain.vue index 5e71bdb..a526b2f 100644 --- a/src/renderer/src/layout/components/AppMain.vue +++ b/src/renderer/src/layout/components/AppMain.vue @@ -1,7 +1,15 @@ - + diff --git a/src/renderer/src/layout/components/Header.vue b/src/renderer/src/layout/components/Header.vue index 8ab6111..6da0158 100644 --- a/src/renderer/src/layout/components/Header.vue +++ b/src/renderer/src/layout/components/Header.vue @@ -4,9 +4,15 @@

AIX智慧课堂

@@ -14,13 +20,17 @@
- +
- +
- -
{{ userStore.user.nickName }}
+ +
{{ userStore.user.nickName }}
diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 51d39dc..8f84c87 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -1,12 +1,17 @@