Compare commits
No commits in common. "d2f57fd18e4cfaaf4060285c338a9bf66c7f98d7" and "bdc67a6a0e66a73f3ed386b0e6014b0604fb68c7" have entirely different histories.
d2f57fd18e
...
bdc67a6a0e
|
@ -7,8 +7,6 @@ VITE_APP_ENV = 'development'
|
|||
# AIx融合数字管理系统/开发环境
|
||||
VITE_APP_BASE_API = '/dev-api'
|
||||
|
||||
VITE_APP_UPLOAD_API = 'http://192.168.2.52:7863'
|
||||
|
||||
VITE_APP_RES_FILE_PATH = 'https://file.ysaix.com:7868/src/assets/textbook/booktxt/'
|
||||
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://file.ysaix.com:7868/'
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://file.ysaix.com:7868/'
|
|
@ -5,13 +5,11 @@ VITE_APP_TITLE = AIx数字平台
|
|||
VITE_APP_ENV = 'production'
|
||||
|
||||
# AIx融合数字管理系统/生产环境
|
||||
VITE_APP_BASE_API = 'https://file.ysaix.com:7868/prod-api'
|
||||
|
||||
VITE_APP_UPLOAD_API = 'https://file.ysaix.com:7868/prod-api'
|
||||
VITE_APP_BASE_API = 'http://192.168.2.52:7863'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
||||
VITE_APP_RES_FILE_PATH = 'https://file.ysaix.com:7868/src/assets/textbook/booktxt/'
|
||||
VITE_APP_RES_FILE_PATH = 'https://prev.ysaix.com:7868/src/assets/textbook/booktxt/'
|
||||
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://file.ysaix.com:7868/'
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/'
|
|
@ -1,3 +1,3 @@
|
|||
provider: generic
|
||||
url: http://localhost:3000/
|
||||
url: https://example.com/auto-updates
|
||||
updaterCacheDirName: electron-app-updater
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
appId: com.electron.app
|
||||
productName: AIx
|
||||
directories:
|
||||
buildResources: build
|
||||
files:
|
||||
- '!**/.vscode/*'
|
||||
- '!src/*'
|
||||
- '!electron.vite.config.{js,ts,mjs,cjs}'
|
||||
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
|
||||
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
||||
asarUnpack:
|
||||
- resources/**
|
||||
win:
|
||||
executableName: AIx
|
||||
icon: resources/logo2.ico
|
||||
nsis:
|
||||
oneClick: false
|
||||
allowToChangeInstallationDirectory: true
|
||||
artifactName: ${name}-${version}-setup.${ext}
|
||||
shortcutName: ${productName}
|
||||
uninstallDisplayName: ${productName}
|
||||
createDesktopShortcut: always
|
||||
mac:
|
||||
entitlementsInherit: build/entitlements.mac.plist
|
||||
extendInfo:
|
||||
- NSCameraUsageDescription: Application requests access to the device's camera.
|
||||
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
||||
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
||||
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
||||
notarize: false
|
||||
dmg:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
- snap
|
||||
- deb
|
||||
maintainer: electronjs.org
|
||||
category: Utility
|
||||
appImage:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: generic
|
||||
url: http://localhost:3000
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
|
@ -12,7 +12,6 @@ asarUnpack:
|
|||
- resources/**
|
||||
win:
|
||||
executableName: AIx
|
||||
icon: resources/logo2.ico
|
||||
nsis:
|
||||
oneClick: false
|
||||
allowToChangeInstallationDirectory: true
|
||||
|
@ -42,6 +41,6 @@ appImage:
|
|||
npmRebuild: false
|
||||
publish:
|
||||
provider: generic
|
||||
url: https://file.ysaix.com:7868/src/assets/smarttalk/
|
||||
url: https://example.com/auto-updates
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
|
|
|
@ -26,6 +26,11 @@ export default defineConfig({
|
|||
target: 'http://192.168.2.52:7863',
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||
},
|
||||
'/profile': {
|
||||
// target: 'http://27.128.240.72:7865',
|
||||
target: 'https://cqyy.ysaix.com:7868',
|
||||
changeOrigin: true
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
12
package.json
|
@ -13,8 +13,7 @@
|
|||
"build": "electron-vite build",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build:unpack": "npm run build && electron-builder --dir",
|
||||
"build:test": "npm run build && electron-builder --win --config ./electron-builder-test.yml",
|
||||
"build:prod": "npm run build && electron-builder --win --config ./electron-builder.yml",
|
||||
"build:win": "npm run build && electron-builder --win",
|
||||
"build:mac": "npm run build && electron-builder --mac",
|
||||
"build:linux": "npm run build && electron-builder --linux"
|
||||
},
|
||||
|
@ -22,22 +21,17 @@
|
|||
"@electron-toolkit/preload": "^3.0.1",
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
||||
"@vueuse/core": "^10.11.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"electron-dl-manager": "^3.0.0",
|
||||
"electron-log": "^5.1.7",
|
||||
"electron-updater": "^6.1.7",
|
||||
"element-plus": "^2.7.6",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"spark-md5": "^3.0.2",
|
||||
"vue-cropper": "^1.1.4",
|
||||
"vue-router": "^4.4.0",
|
||||
"xlsx": "^0.18.5"
|
||||
"vue-cropper": "^1.0.3",
|
||||
"vue-router": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-toolkit/eslint-config": "^1.0.2",
|
||||
|
|
Before Width: | Height: | Size: 264 KiB |
Before Width: | Height: | Size: 264 KiB |
281
src/main/file.js
|
@ -1,148 +1,25 @@
|
|||
import SparkMD5 from 'spark-md5'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
import { ElectronDownloadManager } from 'electron-dl-manager'
|
||||
import { dialog } from 'electron'
|
||||
import axios from 'axios'
|
||||
const uploadUrl = import.meta.env.VITE_APP_UPLOAD_API + '/smarttalk/file/upload'
|
||||
const asyncUploadUrl = import.meta.env.VITE_APP_UPLOAD_API + '/smarttalk/file/asyncUpload'
|
||||
const manager = new ElectronDownloadManager()
|
||||
export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
||||
const userDataPath = app.getPath('userData')
|
||||
const appRootFilePath = userDataPath + '\\selfFile\\'
|
||||
const appTempFilePath = userDataPath + '\\tempFile\\'
|
||||
let Spark = new SparkMD5.ArrayBuffer()
|
||||
|
||||
ipcMain.on('upload-file-change', (e, { id, fileNewName, cookie, fileType }) => {
|
||||
let filePath = appRootFilePath + fileNewName
|
||||
//执行更新,上传文件
|
||||
let formData = new FormData()
|
||||
formData.append('id', id)
|
||||
uploadFileByFS({
|
||||
url: asyncUploadUrl,
|
||||
path: filePath,
|
||||
name: fileNewName,
|
||||
cookie,
|
||||
fileType,
|
||||
formData,
|
||||
success: (response) => {
|
||||
e.reply('upload-file-change-success' + fileNewName, {
|
||||
data: response.data,
|
||||
md5: formData.md5
|
||||
})
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error uploading file:', err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/*监听文件改变,如果有改变则返回触发*/
|
||||
ipcMain.on('listen-file-change', (e, { id, fileNewName, md5, cookie, fileType }) => {
|
||||
let filePath = appRootFilePath + fileNewName
|
||||
let uploadId = null
|
||||
let isOn = false
|
||||
setInterval(() => {
|
||||
getFileMD5(filePath).then((md5New) => {
|
||||
if (md5New !== md5) {
|
||||
md5 = md5New
|
||||
if (uploadId) {
|
||||
clearTimeout(uploadId)
|
||||
}
|
||||
if (isOn === false) {
|
||||
e.reply('listen-file-change-on' + fileNewName)
|
||||
isOn = true
|
||||
}
|
||||
//倒数十秒提交更改,十秒之内有继续修改则重置倒数
|
||||
uploadId = setTimeout(() => {
|
||||
//执行更新,上传文件
|
||||
let formData = new FormData()
|
||||
formData.append('id', id)
|
||||
uploadFileByFS({
|
||||
url: asyncUploadUrl,
|
||||
path: filePath,
|
||||
name: fileNewName,
|
||||
cookie,
|
||||
fileType,
|
||||
formData,
|
||||
success: (response) => {
|
||||
e.reply('listen-file-change-success' + fileNewName, {
|
||||
data: response.data,
|
||||
md5: formData.md5
|
||||
})
|
||||
clearTimeout(uploadId)
|
||||
isOn = false
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error uploading file:', err)
|
||||
}
|
||||
})
|
||||
}, 5000)
|
||||
}
|
||||
})
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
function getFileMD5(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(path, (err, dataFile) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
return console.error(err)
|
||||
}
|
||||
Spark.append(dataFile)
|
||||
let md5 = Spark.end()
|
||||
resolve(md5)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断是否有本地文件
|
||||
* */
|
||||
ipcMain.on('is-have-local-file', (e, fileNewName) => {
|
||||
let filePath = appRootFilePath + fileNewName
|
||||
fs.access(filePath, fs.constants.F_OK, (err) => {
|
||||
if (err) {
|
||||
e.reply('is-have-local-file-reply' + fileNewName, false)
|
||||
e.reply('is-have-local-file-reply'+fileNewName, false)
|
||||
return
|
||||
}
|
||||
e.reply('is-have-local-file-reply' + fileNewName, true)
|
||||
e.reply('is-have-local-file-reply'+fileNewName, true)
|
||||
})
|
||||
})
|
||||
|
||||
/*
|
||||
* 判断是需要同步本地文件
|
||||
* */
|
||||
ipcMain.on('is-async-local-file', (e, { fileNewName, lastModifyTime, md5 }) => {
|
||||
let filePath = appRootFilePath + fileNewName
|
||||
fs.access(filePath, fs.constants.F_OK, (err) => {
|
||||
if (err) {
|
||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
||||
return
|
||||
}
|
||||
getFileMD5(filePath).then((localMd5) => {
|
||||
if (localMd5 === md5) {
|
||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: false, type: '' })
|
||||
} else {
|
||||
const stats = fs.statSync(filePath)
|
||||
//如果线上时间大于线下时间,就需要从线上下载,否则则需要上传
|
||||
let time = new Date(lastModifyTime)
|
||||
if (time > stats.mtime.getTime()) {
|
||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
||||
} else if (time < stats.mtime.getTime()) {
|
||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'upload' })
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
//默认浏览器打开url
|
||||
ipcMain.on('open-url-browser', (e, url) => {
|
||||
shell.openPath(url)
|
||||
})
|
||||
|
||||
//使用默认应用打开本地文件
|
||||
ipcMain.on('open-path-app', (e, destination) => {
|
||||
let path = appRootFilePath + destination
|
||||
|
@ -158,78 +35,6 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
})
|
||||
})
|
||||
|
||||
//导出文件
|
||||
ipcMain.on('export-file-default', (e, list) => {
|
||||
exportFile(list, (res) => {
|
||||
e.reply('export-file-default-reply', res)
|
||||
})
|
||||
})
|
||||
|
||||
function uploadFileByFS({ url, path, name, cookie, fileType, formData, success, error }) {
|
||||
fs.readFile(path, (err, data) => {
|
||||
if (err) {
|
||||
return console.error(err)
|
||||
}
|
||||
// 配置上传的请求
|
||||
const config = {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data', // 或者其他适合上传文件的Content-Type
|
||||
Authorization: 'Bearer ' + cookie
|
||||
}
|
||||
}
|
||||
Spark.append(data)
|
||||
let md5 = Spark.end()
|
||||
// 使用axios上传文件
|
||||
let file = new File([data], name, {
|
||||
type: fileType
|
||||
})
|
||||
const stats = fs.statSync(path)
|
||||
formData.append('file', file)
|
||||
formData.append('md5', md5)
|
||||
formData.append('lastModifyTime', stats.mtime.toLocaleString())
|
||||
axios
|
||||
.post(url, formData, config)
|
||||
.then((response) => {
|
||||
success(response)
|
||||
})
|
||||
.catch((errorMsg) => {
|
||||
error(errorMsg)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/*创建新的ppt文件*/
|
||||
ipcMain.on('creat-file-default', (e, { name, uploadData, cookie }) => {
|
||||
createFolder('tempFile').then(() => {
|
||||
let path = appTempFilePath + name
|
||||
fs.writeFileSync(path, '', 'utf-8')
|
||||
let fileType = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
||||
let formData = new FormData()
|
||||
for (let key in uploadData) {
|
||||
if (Object.prototype.hasOwnProperty.call(uploadData, key)) {
|
||||
// 检查是否是对象自身的属性
|
||||
formData.append(key, uploadData[key])
|
||||
}
|
||||
}
|
||||
formData.append('fileFlag', '教案')
|
||||
uploadFileByFS({
|
||||
url: uploadUrl,
|
||||
path,
|
||||
name,
|
||||
cookie,
|
||||
fileType,
|
||||
formData,
|
||||
success: (response) => {
|
||||
e.reply('creat-file-default-reply', response.data)
|
||||
console.log('File uploaded successfully:', response.data)
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error uploading file:', err)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
//获取应用文件目录
|
||||
ipcMain.on('get-root-file-path', (e) => {
|
||||
e.reply('get-root-file-path-reply', appRootFilePath)
|
||||
|
@ -248,22 +53,23 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
onDownloadStarted: async ({ id, item, webContents }) => {
|
||||
// Do something with the download id
|
||||
},
|
||||
onDownloadProgress: async ({ id, item, percentCompleted }) => {},
|
||||
onDownloadProgress: async ({ id, item, percentCompleted }) => {
|
||||
},
|
||||
onDownloadCompleted: async ({ id, item }) => {
|
||||
console.log('完成')
|
||||
e.reply('download-file-default' + fileName, true)
|
||||
e.reply('download-file-default'+fileName,true)
|
||||
},
|
||||
onDownloadCancelled: async () => {
|
||||
console.log('取消')
|
||||
e.reply('download-file-default' + fileName, false)
|
||||
e.reply('download-file-default'+fileName,false)
|
||||
},
|
||||
onDownloadInterrupted: async () => {
|
||||
console.log('中断')
|
||||
e.reply('download-file-default' + fileName, false)
|
||||
e.reply('download-file-default'+fileName,false)
|
||||
},
|
||||
onError: (err, data) => {
|
||||
console.log(err.toString())
|
||||
e.reply('download-file-default' + fileName, false)
|
||||
e.reply('download-file-default'+fileName,false)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -318,76 +124,6 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
})
|
||||
})
|
||||
|
||||
/*导出文件*/
|
||||
function exportFile(list, callback) {
|
||||
let win = BrowserWindow.getFocusedWindow()
|
||||
//通过扩展名识别文件类型
|
||||
let filePath = null //用户选择存放文件的路径
|
||||
//1- 弹出另存为弹框,用于获取保存路径
|
||||
dialog
|
||||
.showOpenDialog(win, {
|
||||
properties: ['openDirectory']
|
||||
})
|
||||
.then(async (result) => {
|
||||
if (result.filePaths[0]) {
|
||||
filePath = result.filePaths[0]
|
||||
let res = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let item = list[i]
|
||||
let source = appRootFilePath + item.id
|
||||
let destination = filePath + '/' + item.name
|
||||
await copyRelFile(source, filterCopyFile(destination), (error, path) => {
|
||||
res.push({ error, path })
|
||||
})
|
||||
}
|
||||
callback(res)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('另存为--catch')
|
||||
})
|
||||
}
|
||||
|
||||
/*文件是否已经存在*/
|
||||
function isHaveFile(path) {
|
||||
return fs.existsSync(path)
|
||||
}
|
||||
|
||||
/*判断是否已经存在这个名字的文件,如果已经存在则递增导出*/
|
||||
function filterCopyFile(path, index = 0) {
|
||||
if (isHaveFile(path) === true) {
|
||||
index++
|
||||
path = path.replaceAll('.', `(${index}).`)
|
||||
return filterCopyFile(path, index)
|
||||
} else {
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
/*复制文件*/
|
||||
function copyRelFile(source, destination, callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const readStream = fs.createReadStream(source)
|
||||
const writeStream = fs.createWriteStream(destination)
|
||||
|
||||
readStream.on('error', (error) => {
|
||||
reject()
|
||||
callback(error, null)
|
||||
})
|
||||
writeStream.on('error', (error) => {
|
||||
reject()
|
||||
callback(error, null)
|
||||
})
|
||||
writeStream.on('close', () => {
|
||||
console.log('关闭写入流')
|
||||
callback(null, destination)
|
||||
resolve()
|
||||
})
|
||||
readStream.pipe(writeStream)
|
||||
})
|
||||
}
|
||||
|
||||
/*复制文件*/
|
||||
function copyFile(source, destination, callback) {
|
||||
let path = appRootFilePath + destination
|
||||
createFolder('selfFile').then(() => {
|
||||
|
@ -408,7 +144,6 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
})
|
||||
}
|
||||
|
||||
/*创建文件夹*/
|
||||
function createFolder(folderName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const folderPath = path.join(userDataPath, folderName)
|
||||
|
|
|
@ -1,59 +1,18 @@
|
|||
import { app, shell, BrowserWindow, ipcMain, session } from 'electron'
|
||||
import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||
import { join } from 'path'
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import icon from '../../resources/icon.png?asset'
|
||||
import File from './file'
|
||||
import updateInit from './update'
|
||||
|
||||
File({ app, shell, BrowserWindow, ipcMain })
|
||||
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
||||
let mainWindow, loginWindow
|
||||
|
||||
//登录窗口
|
||||
function createLoginWindow() {
|
||||
if (loginWindow) return
|
||||
loginWindow = new BrowserWindow({
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 888,
|
||||
height: 520,
|
||||
show: false,
|
||||
frame: false,
|
||||
autoHideMenuBar: true,
|
||||
icon: join(__dirname, '../../resources/logo2.ico'),
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
// 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'})
|
||||
updateInit(loginWindow)
|
||||
}
|
||||
|
||||
// loginWindow.webContents.openDevTools()
|
||||
loginWindow.once('ready-to-show', () => {
|
||||
loginWindow.show()
|
||||
})
|
||||
|
||||
loginWindow.on('closed', () => {
|
||||
loginWindow = null
|
||||
})
|
||||
}
|
||||
//主窗口
|
||||
function createMainWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 700,
|
||||
show: false,
|
||||
frame: false, // 无边框
|
||||
autoHideMenuBar: true,
|
||||
icon: join(__dirname, '../../resources/logo2.ico'),
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
|
@ -65,119 +24,48 @@ function createMainWindow() {
|
|||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow.show()
|
||||
})
|
||||
|
||||
mainWindow.webContents.openDevTools()
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
})
|
||||
mainWindow.webContents.openDevTools()
|
||||
|
||||
// HMR for renderer base on electron-vite cli.
|
||||
// Load the remote URL for development or the local html file for production.
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] )
|
||||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
|
||||
// mainWindow.loadURL('https://file.ysaix.com:7868/')
|
||||
|
||||
} else {
|
||||
// mainWindow.loadURL('https://file.ysaix.com:7868/')
|
||||
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 作业窗口相关-开发中
|
||||
let linkWindow
|
||||
async function createLinkWin(data) {
|
||||
if (linkWindow) return
|
||||
linkWindow = new BrowserWindow({
|
||||
width: 650,
|
||||
height: 500,
|
||||
show: false,
|
||||
frame: true,
|
||||
maximizable: true,
|
||||
autoHideMenuBar: true,
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
sandbox: false,
|
||||
nodeIntegration: true,
|
||||
worldSafeExecuteJavaScript: true,
|
||||
contextIsolation: true
|
||||
}
|
||||
})
|
||||
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);
|
||||
})
|
||||
|
||||
linkWindow.loadURL(data.fullPath)
|
||||
|
||||
linkWindow.once('ready-to-show', () => {
|
||||
linkWindow.show()
|
||||
linkWindow.maximize()
|
||||
})
|
||||
linkWindow.on('closed', () => {
|
||||
linkWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化完成
|
||||
app.on('ready', () => {
|
||||
// 设置应用程序用户模型标识符
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.whenReady().then(() => {
|
||||
// Set app user model id for windows
|
||||
electronApp.setAppUserModelId('com.electron')
|
||||
|
||||
//一个新的browserWindow 被创建时触发
|
||||
// Default open or close DevTools by F12 in development
|
||||
// and ignore CommandOrControl + R in production.
|
||||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
||||
app.on('browser-window-created', (_, window) => {
|
||||
optimizer.watchWindowShortcuts(window)
|
||||
})
|
||||
|
||||
//窗口 最大、最小、关闭
|
||||
ipcMain.on('minimize-window', () => {
|
||||
if (loginWindow) {
|
||||
loginWindow.minimize()
|
||||
}
|
||||
if (mainWindow) {
|
||||
mainWindow.minimize()
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('maximize-window', () => {
|
||||
mainWindow.isMaximized() ? mainWindow.unmaximize() : mainWindow.maximize()
|
||||
})
|
||||
|
||||
ipcMain.on('close-window', () => {
|
||||
if (loginWindow) {
|
||||
loginWindow.destroy()
|
||||
}
|
||||
if (mainWindow) {
|
||||
mainWindow.destroy()
|
||||
}
|
||||
})
|
||||
createWindow()
|
||||
|
||||
// 打开主窗口
|
||||
ipcMain.on('openMainWindow', () => {
|
||||
if (!mainWindow) {
|
||||
createMainWindow()
|
||||
}
|
||||
|
||||
loginWindow.destroy()
|
||||
loginWindow = null
|
||||
})
|
||||
// 打开登录窗口
|
||||
ipcMain.on('openLoginWindow', () => {
|
||||
if (!loginWindow) {
|
||||
createLoginWindow()
|
||||
}
|
||||
mainWindow.destroy()
|
||||
mainWindow = null
|
||||
loginWindow.show()
|
||||
loginWindow.focus()
|
||||
})
|
||||
|
||||
//打开作业窗口
|
||||
ipcMain.on('openWindow', (e, data) => {
|
||||
createLinkWin(data)
|
||||
})
|
||||
|
||||
createLoginWindow()
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createLoginWindow()
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -189,3 +77,35 @@ app.on('window-all-closed', () => {
|
|||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('toggle-top', (event) => {
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
const isAlwaysOnTop = win.isAlwaysOnTop();
|
||||
win.setAlwaysOnTop(!isAlwaysOnTop);
|
||||
event.sender.send('top-status-changed', !isAlwaysOnTop);
|
||||
})
|
||||
|
||||
|
||||
ipcMain.on('minimize-window', () => {
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
win.minimize();
|
||||
});
|
||||
|
||||
ipcMain.on('maximize-window', () => {
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
if (win.isMaximized()) {
|
||||
win.unmaximize();
|
||||
} else {
|
||||
win.maximize();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('close-window', () => {
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
win.close();
|
||||
});
|
||||
ipcMain.on('set-winsize', (e, {x, y})=>{
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
win.setSize(x,y);
|
||||
win.center()
|
||||
})
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
import { dialog } from 'electron'
|
||||
import logger from 'electron-log'
|
||||
const updateURL = 'http://27.128.240.72:3000/zhuhao/AIx_Smarttalk/releases/tag/V1.0.0%28%E6%B5%8B%E8%AF%95%E7%89%88%29/'
|
||||
|
||||
// 主进程中的更新检查
|
||||
const { autoUpdater } = require('electron-updater')
|
||||
|
||||
const updateInit = (win) => {
|
||||
logger.info('进来了')
|
||||
// 检查更新
|
||||
autoUpdater.checkForUpdates()
|
||||
// 自动下载
|
||||
autoUpdater.autoDownload = false
|
||||
// 设置版本更新服务器地址
|
||||
// autoUpdater.setFeedURL(updateURL)
|
||||
|
||||
//监听更新事件
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
logger.info('发现新版本')
|
||||
dialog
|
||||
.showMessageBox(win,{
|
||||
type: 'info',
|
||||
title: '新版本可用',
|
||||
message: '有一个可用的新版本,要更新吗',
|
||||
buttons: ['是', '否']
|
||||
})
|
||||
.then((result) => {
|
||||
if (result.response === 0) {
|
||||
// 用户选择更新,触发下载和安装
|
||||
autoUpdater.downloadUpdate()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 没有新版本
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
logger.info('没有新版本')
|
||||
})
|
||||
|
||||
// 更新发生错误
|
||||
autoUpdater.on('error', () => {
|
||||
logger.error('检查更新失败')
|
||||
})
|
||||
|
||||
// 跟新下载完毕
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
dialog
|
||||
.showMessageBox({
|
||||
type: 'info',
|
||||
title: '更新下载完成',
|
||||
message: '点击确定重启获取最新内容',
|
||||
buttons: ['确定']
|
||||
})
|
||||
.then(() => {
|
||||
// 调用 quitAndInstall 来安装更新
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default updateInit
|
|
@ -8,7 +8,7 @@
|
|||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
|
||||
/> -->
|
||||
<meta http-equiv="Content-Security-Policy" content="connect-src *; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src * 'self' data: blob:" />
|
||||
<meta http-equiv="Content-Security-Policy" content="connect-src *; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:" />
|
||||
|
||||
</head>
|
||||
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
// 查询evaluation列表
|
||||
import request from '@/utils/request'
|
||||
// 查询班级列表
|
||||
export function listClassmain(query) {
|
||||
return request({
|
||||
url: '/education/classmain/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 查询学生列表
|
||||
export function listClassuser(query) {
|
||||
return request({
|
||||
url: '/education/classuser/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 新增班级
|
||||
export function addClassmain(data) {
|
||||
return request({
|
||||
url: '/education/classmain',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// 查询所有学科的列表
|
||||
export function listEvaluation(query) {
|
||||
return request({
|
||||
url: '/education/evaluation/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 新增小组
|
||||
export function addClassgroup(data) {
|
||||
return request({
|
||||
url: '/education/classgroup',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//班级详情
|
||||
export function getClassmain(id) {
|
||||
return request({
|
||||
url: '/education/classmain/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
// 获取小组列表
|
||||
export function listClassgroup(query) {
|
||||
return request({
|
||||
url: '/education/classgroup/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
//删除小组
|
||||
export function delClassgroup(id) {
|
||||
return request({
|
||||
url: '/education/classgroup/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
//查询小组信息
|
||||
export function getClassgroup(id) {
|
||||
return request({
|
||||
url: '/education/classgroup/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
//修改小组信息
|
||||
export function updateClassgroup(data) {
|
||||
return request({
|
||||
url: '/education/classgroup',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//新增学生
|
||||
export function addStudentmain(data) {
|
||||
return request({
|
||||
url: '/education/studentmain',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//修改学生信息
|
||||
export function updateStudentmain(data) {
|
||||
return request({
|
||||
url: '/education/studentmain',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//获取学生信息
|
||||
export function getStudentmain(id) {
|
||||
return request({
|
||||
url: '/education/studentmain/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
//删除学生
|
||||
export function leaveClass(data) {
|
||||
return request({
|
||||
url: '/education/classuser/leaveClass',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//删除学生所有数据
|
||||
export function removeStudentDataAll(id) {
|
||||
return request({
|
||||
url: '/education/studentmain/removeStudent/' + id,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
//删除教室
|
||||
export function delClassroom(id) {
|
||||
return request({
|
||||
url: '/education/classroom/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
//导入学生
|
||||
export function addStudentmainByNameArray(data) {
|
||||
return request({
|
||||
url: '/education/studentmain/addByNameArray',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
|
@ -9,13 +9,6 @@ export const getSmarttalkPage = (params) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const getPrepareById = (id) => {
|
||||
return request({
|
||||
url: '/smarttalk/file/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteSmarttalk(id) {
|
||||
return request({
|
||||
url: '/smarttalk/file/' + id,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 2794390 */
|
||||
src: url('iconfont.woff2?t=1721698955462') format('woff2'),
|
||||
url('iconfont.woff?t=1721698955462') format('woff'),
|
||||
url('iconfont.ttf?t=1721698955462') format('truetype'),
|
||||
url('iconfont.svg?t=1721698955462#iconfont') format('svg');
|
||||
src: url('iconfont.woff2?t=1721179711733') format('woff2'),
|
||||
url('iconfont.woff?t=1721179711733') format('woff'),
|
||||
url('iconfont.ttf?t=1721179711733') format('truetype'),
|
||||
url('iconfont.svg?t=1721179711733#iconfont') format('svg');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
|
@ -14,10 +14,6 @@
|
|||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-lingdang:before {
|
||||
content: "\e613";
|
||||
}
|
||||
|
||||
.icon-yidongdaozu:before {
|
||||
content: "\e67d";
|
||||
}
|
||||
|
|
|
@ -5,13 +5,6 @@
|
|||
"css_prefix_text": "icon-",
|
||||
"description": "",
|
||||
"glyphs": [
|
||||
{
|
||||
"icon_id": "17990800",
|
||||
"name": "铃铛",
|
||||
"font_class": "lingdang",
|
||||
"unicode": "e613",
|
||||
"unicode_decimal": 58899
|
||||
},
|
||||
{
|
||||
"icon_id": "1207918",
|
||||
"name": "移动到组",
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
/>
|
||||
<missing-glyph />
|
||||
|
||||
<glyph glyph-name="lingdang" unicode="" d="M257.7 243.70000000000005h510.6c17.9 0 32.5 14.5 32.5 32.5V480.9c0 143.2-104.6 261.9-241.5 284 2.1 5.5 3.3 11.6 3.3 17.8 0 27.4-22.2 49.6-49.6 49.6s-49.6-22.2-49.6-49.6c0-6.3 1.2-12.3 3.3-17.8-136.9-22.1-241.5-140.9-241.5-284v-204.7c0-17.9 14.6-32.5 32.5-32.5zM513-63.60000000000002c44.4 0 80.3 36 80.3 80.3H432.7c0-44.4 35.9-80.3 80.3-80.3zM911.7 115L895 148.29999999999995c-14.8 29.7-47.7 52.1-74.5 52.1h-615c-26.8 0-59.7-22.4-74.5-52.1L114.3 115c-17.5-35.1-6.6-65.9 25.9-65.9h745.6c32.5 0 43.5 30.8 25.9 65.9z" horiz-adv-x="1024" />
|
||||
|
||||
<glyph glyph-name="yidongdaozu" unicode="" d="M904.448 270.272 119.616 270.272c-23.68 0-44.736-14.656-52.48-36.48C65.024 227.968 64 221.952 64 216c0-16.32 7.616-32.192 21.184-42.688l293.248-225.728c24.128-18.56 59.008-14.464 78.016 9.088 18.944 23.552 14.848 57.664-9.28 76.224L288 156.544l616 0c30.72 0 56 29.44 56 59.456C960 246.016 935.168 270.272 904.448 270.272zM119.552 497.728l784.832 0c23.68 0 44.736 14.656 52.48 36.48C958.976 540.032 960 546.048 960 552c0 16.32-7.616 32.192-21.184 42.688l-293.248 225.728c-24.128 18.56-59.008 14.464-78.016-9.088C548.608 787.776 552.64 753.6 576.832 735.04L736 611.456 120 611.456C89.28 611.456 64 582.016 64 552 64 521.984 88.832 497.728 119.552 497.728z" horiz-adv-x="1024" />
|
||||
|
||||
<glyph glyph-name="shanchu" unicode="" d="M736.653061-33.959184H287.346939c-45.97551 0-83.591837 37.616327-83.591837 83.591837V540.734694h616.489796v-491.102041c0-45.97551-37.616327-83.591837-83.591837-83.591837zM245.55102 498.938776v-449.306123c0-22.987755 18.808163-41.795918 41.795919-41.795918h449.306122c22.987755 0 41.795918 18.808163 41.795919 41.795918V498.938776H245.55102zM407.510204 101.877551c-11.493878 0-20.897959 9.404082-20.897959 20.897959V384c0 11.493878 9.404082 20.897959 20.897959 20.897959s20.897959-9.404082 20.897959-20.897959v-261.22449c0-11.493878-9.404082-20.897959-20.897959-20.897959zM616.489796 101.877551c-11.493878 0-20.897959 9.404082-20.897959 20.897959V384c0 11.493878 9.404082 20.897959 20.897959 20.897959s20.897959-9.404082 20.897959-20.897959v-261.22449c0-11.493878-9.404082-20.897959-20.897959-20.897959zM846.367347 498.938776H177.632653c-45.97551 0-83.591837 37.616327-83.591837 83.591836v31.346939c0 45.97551 37.616327 83.591837 83.591837 83.591837h668.734694c45.97551 0 83.591837-37.616327 83.591837-83.591837v-31.346939c0-45.97551-37.616327-83.591837-83.591837-83.591836zM177.632653 655.673469c-22.987755 0-41.795918-18.808163-41.795918-41.795918v-31.346939c0-22.987755 18.808163-41.795918 41.795918-41.795918h668.734694c22.987755 0 41.795918 18.808163 41.795918 41.795918v31.346939c0 22.987755-18.808163 41.795918-41.795918 41.795918H177.632653zM650.44898 655.673469h-276.89796c-28.734694 0-52.244898 23.510204-52.244898 52.244898v41.795919c0 28.734694 23.510204 52.244898 52.244898 52.244898h276.89796c28.734694 0 52.244898-23.510204 52.244898-52.244898v-41.795919c0-28.734694-23.510204-52.244898-52.244898-52.244898z m-276.89796 104.489796c-5.746939 0-10.44898-4.702041-10.448979-10.448979v-41.795919c0-5.746939 4.702041-10.44898 10.448979-10.448979h276.89796c5.746939 0 10.44898 4.702041 10.448979 10.448979v41.795919c0 5.746939-4.702041 10.44898-10.448979 10.448979h-276.89796z" horiz-adv-x="1024" />
|
||||
|
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 394 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 67 KiB |