baigl #180
|
@ -9,7 +9,8 @@ VITE_APP_BASE_API = '/dev-api'
|
|||
|
||||
VITE_APP_DOMAIN = 'file.ysaix.com'
|
||||
|
||||
VITE_APP_UPLOAD_API = 'http://192.168.2.52:7863'
|
||||
VITE_APP_UPLOAD_API = 'https://file.ysaix.com:7868/prod-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/'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# 页面标题
|
||||
VITE_APP_TITLE = AIx数字平台
|
||||
VITE_APP_TITLE = AIx数字平台(测试版)
|
||||
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV = 'production'
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
appId: com.electron.app
|
||||
productName: AIx
|
||||
directories:
|
||||
output: dist
|
||||
buildResources: build
|
||||
win:
|
||||
executableName: AIx
|
||||
icon: resources/logo2.ico
|
||||
files:
|
||||
- '!**/.vscode/*'
|
||||
- '!src/*'
|
||||
|
@ -10,9 +14,6 @@ files:
|
|||
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
||||
asarUnpack:
|
||||
- resources/**
|
||||
win:
|
||||
executableName: AIx
|
||||
icon: resources/logo2.ico
|
||||
nsis:
|
||||
oneClick: false
|
||||
allowToChangeInstallationDirectory: true
|
||||
|
@ -45,3 +46,9 @@ publish:
|
|||
url: https://prev.ysaix.com:7868/src/assets/smarttalk/
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
# 额外依赖打包到输出目录
|
||||
extraFiles:
|
||||
- from: ./node_modules/im_electron_sdk/lib/
|
||||
to: ./resources
|
||||
filter:
|
||||
- '**/*'
|
||||
|
|
|
@ -45,3 +45,9 @@ publish:
|
|||
url: http://localhost:3000
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
# 额外依赖打包到输出目录
|
||||
extraFiles:
|
||||
- from: ./node_modules/im_electron_sdk/lib/
|
||||
to: ./resources
|
||||
filter:
|
||||
- '**/*'
|
||||
|
|
|
@ -45,3 +45,9 @@ publish:
|
|||
url: https://file.ysaix.com:7868/src/assets/smarttalk/
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
# 额外依赖打包到输出目录
|
||||
extraFiles:
|
||||
- from: ./node_modules/im_electron_sdk/lib/
|
||||
to: ./resources
|
||||
filter:
|
||||
- '**/*'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "aix-win",
|
||||
"version": "1.0.7",
|
||||
"version": "1.1.8",
|
||||
"description": "An Electron application with Vue",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "example.com",
|
||||
|
@ -30,18 +30,21 @@
|
|||
"crypto-js": "^4.2.0",
|
||||
"electron-dl-manager": "^3.0.0",
|
||||
"electron-log": "^5.1.7",
|
||||
"electron-store": "8.0.0",
|
||||
"electron-updater": "^6.1.7",
|
||||
"element-plus": "^2.7.6",
|
||||
"fabric": "^5.3.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"jsondiffpatch": "0.6.0",
|
||||
"im_electron_sdk": "^8.0.5904",
|
||||
"lodash": "^4.17.21",
|
||||
"pdfjs-dist": "4.4.168",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"spark-md5": "^3.0.2",
|
||||
"vue-router": "^4.4.0",
|
||||
"xgplayer": "^3.0.19",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
@ -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 }
|
|
@ -42,19 +42,23 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
let filePath = appRootFilePath + fileNewName
|
||||
let uploadId = null
|
||||
let isOn = false
|
||||
let lastMTime = fs.statSync(filePath).mtime.getTime()
|
||||
console.log(lastMTime)
|
||||
setInterval(() => {
|
||||
getFileMD5(filePath).then((md5New) => {
|
||||
if (md5New !== md5) {
|
||||
md5 = md5New
|
||||
getFileMsg(filePath).then((msg) => {
|
||||
if (msg !== lastMTime) {
|
||||
lastMTime = msg
|
||||
if (uploadId) {
|
||||
clearTimeout(uploadId)
|
||||
}
|
||||
if (isOn === false) {
|
||||
console.log(fileNewName)
|
||||
e.reply('listen-file-change-on' + fileNewName)
|
||||
isOn = true
|
||||
}
|
||||
//倒数十秒提交更改,十秒之内有继续修改则重置倒数
|
||||
uploadId = setTimeout(() => {
|
||||
console.log(223)
|
||||
//执行更新,上传文件
|
||||
let formData = new FormData()
|
||||
formData.append('id', id)
|
||||
|
@ -77,12 +81,19 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
console.error('Error uploading file:', err)
|
||||
}
|
||||
})
|
||||
}, 20000)
|
||||
}, 5000)
|
||||
}
|
||||
})
|
||||
}, 10000)
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
function getFileMsg(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const stats = fs.statSync(path)
|
||||
return resolve(stats.mtime.getTime())
|
||||
})
|
||||
}
|
||||
|
||||
function getFileMD5(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(path, (err, dataFile) => {
|
||||
|
@ -121,13 +132,14 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
||||
return
|
||||
}
|
||||
getFileMD5(filePath).then((localMd5) => {
|
||||
if (localMd5 === md5) {
|
||||
getFileMsg(filePath).then((msg) => {
|
||||
let time = new Date(lastModifyTime).getTime();
|
||||
msg = parseInt(msg/1000)*1000;
|
||||
if (msg == time) {
|
||||
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()) {
|
||||
|
@ -146,7 +158,7 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
|||
//使用默认应用打开本地文件
|
||||
ipcMain.on('open-path-app', (e, destination) => {
|
||||
let path = appRootFilePath + destination
|
||||
shell.openExternal(path).catch((error) => {
|
||||
shell.openPath(path).catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -3,12 +3,19 @@ import { join } from 'path'
|
|||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import icon from '../../resources/icon.png?asset'
|
||||
import File from './file'
|
||||
import Logger from './logger' // 日志封装
|
||||
import chat from './chat' // chat封装
|
||||
import Store from './store' // Store封装
|
||||
import updateInit from './update'
|
||||
// 代理 electron/remote
|
||||
// 第一步:引入remote
|
||||
import remote from '@electron/remote/main'
|
||||
// 第二步: 初始化remote
|
||||
remote.initialize()
|
||||
import updateInit from './update'
|
||||
// 日志配置-初始化(日志直接绑定到console上)
|
||||
if(!is.dev) Logger.initialize()
|
||||
// 持久化数据-初始化
|
||||
Store.initialize()
|
||||
|
||||
File({ app, shell, BrowserWindow, ipcMain })
|
||||
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
||||
|
@ -28,6 +35,7 @@ function createLoginWindow() {
|
|||
icon: join(__dirname, '../../resources/logo2.ico'),
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
defaultEncoding: 'utf-8',
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
nodeIntegration: true,
|
||||
|
@ -60,13 +68,16 @@ function createLoginWindow() {
|
|||
function createMainWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
minWidth: 1200,
|
||||
height: 700,
|
||||
show: false,
|
||||
frame: false, // 无边框
|
||||
autoHideMenuBar: true,
|
||||
maximizable: false,
|
||||
icon: join(__dirname, '../../resources/logo2.ico'),
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
defaultEncoding: 'utf-8',
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
// nodeIntegration: true,
|
||||
|
@ -115,6 +126,7 @@ async function createLinkWin(data) {
|
|||
autoHideMenuBar: true,
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
defaultEncoding: 'utf-8',
|
||||
sandbox: false,
|
||||
nodeIntegration: true,
|
||||
worldSafeExecuteJavaScript: true,
|
||||
|
@ -126,13 +138,14 @@ async function createLinkWin(data) {
|
|||
let cookieDetails = { ...data.cookieData }
|
||||
await linkWin[data.key].webContents.session.cookies
|
||||
.set(cookieDetails)
|
||||
.then(() => {
|
||||
console.log('Cookie is successful')
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Cookie is error', error)
|
||||
})
|
||||
.then(() => {})
|
||||
.catch((error) => {})
|
||||
data.fullPath = data.fullPath.replaceAll('//', '/')
|
||||
if (data.fullPath.indexOf('?') !== -1) {
|
||||
data.fullPath += '&urlSource=smarttalk'
|
||||
}else {
|
||||
data.fullPath += '?urlSource=smarttalk'
|
||||
}
|
||||
linkWin[data.key].loadURL(data.fullPath)
|
||||
|
||||
linkWin[data.key].once('ready-to-show', () => {
|
||||
|
@ -147,6 +160,8 @@ async function createLinkWin(data) {
|
|||
|
||||
// 初始化完成
|
||||
app.on('ready', () => {
|
||||
appWatchError() // 监听app错误
|
||||
process.env.LANG = 'en_US.UTF-8'
|
||||
// 设置应用程序用户模型标识符
|
||||
electronApp.setAppUserModelId('com.electron')
|
||||
|
||||
|
@ -226,12 +241,14 @@ app.on('window-all-closed', () => {
|
|||
|
||||
// 监听全局事件
|
||||
function handleAll() {
|
||||
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) => {
|
||||
|
@ -243,4 +260,41 @@ 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)
|
||||
})
|
||||
}
|
||||
|
||||
// app 崩溃监听器
|
||||
function appWatchError() {
|
||||
// 渲染进程崩溃
|
||||
app.on('renderer-process-crashed', (event, webContents, killed) => {
|
||||
console.error(
|
||||
`APP-ERROR:renderer-process-crashed; event: ${JSON.stringify(event)}; webContents:${JSON.stringify(
|
||||
webContents
|
||||
)}; killed:${JSON.stringify(killed)}`
|
||||
)
|
||||
})
|
||||
|
||||
// GPU进程崩溃
|
||||
app.on('gpu-process-crashed', (event, killed) => {
|
||||
console.error(`APP-ERROR:gpu-process-crashed; event: ${JSON.stringify(event)}; killed: ${JSON.stringify(killed)}`)
|
||||
})
|
||||
|
||||
// 渲染进程结束
|
||||
app.on('render-process-gone', async (event, webContents, details) => {
|
||||
console.error(
|
||||
`APP-ERROR:render-process-gone; event: ${JSON.stringify(event)}; webContents:${JSON.stringify(
|
||||
webContents
|
||||
)}; details:${JSON.stringify(details)}`
|
||||
)
|
||||
})
|
||||
|
||||
// 子进程结束
|
||||
app.on('child-process-gone', async (event, details) => {
|
||||
console.error(`APP-ERROR:child-process-gone; event: ${JSON.stringify(event)}; details:${JSON.stringify(details)}`)
|
||||
})
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* @description 日志配置
|
||||
* @author zdg
|
||||
* @date 2021-07-05 14:07:01
|
||||
*/
|
||||
// import log from 'electron-log'
|
||||
import log from 'electron-log/main'
|
||||
import { app } from 'electron'
|
||||
import path from 'path'
|
||||
|
||||
// 关闭控制台打印
|
||||
// 日志控制台等级,默认值:false
|
||||
log.transports.console.level = false
|
||||
// log.transports.console.level = 'info'
|
||||
// 日志文件等级,默认值:false
|
||||
log.transports.file.level = 'info'
|
||||
// 日志文件名,默认:main.log
|
||||
// log.transports.file.fileName = 'main.log';
|
||||
// 日志大小,默认:1048576(1M),达到最大上限后,备份文件并重命名为:main.old.log,有且仅有一个备份文件
|
||||
log.transports.file.maxSize = 10 * 1024 * 1024; // 文件最大不超过 10M
|
||||
// 自定义日志文件滚动策略
|
||||
log.transports.file.rollSize = 10 * 1024 * 1024; // 10MB
|
||||
// 日志格式,默认:[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}
|
||||
log.transports.file.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}'
|
||||
let date = new Date()
|
||||
let dateStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
|
||||
// 文件位置及命名方式
|
||||
// 默认位置为:C:\Users\[user]\AppData\Roaming\[appname]\electron_log\
|
||||
// 文件名为:年-月-日.log
|
||||
// 自定义文件保存位置为安装目录下 \log\年-月-日.log
|
||||
// log.transports.file.resolvePathFn = () => 'logs\\' + dateStr+ '.log';
|
||||
log.transports.file.resolvePathFn = () => path.join(app.getPath('userData'), `logs/${dateStr}.log`)
|
||||
|
||||
// 有六个日志级别error, warn, info, verbose, debug, silly。默认是silly
|
||||
export const logger = {
|
||||
error: (...args) => log.error(...args),
|
||||
warn: (...args) => log.warn(...args),
|
||||
info: (...args) => log.info(...args),
|
||||
verbose: (...args) => log.verbose(...args),
|
||||
debug: (...args) => log.debug(...args),
|
||||
silly: (...args) => log.silly(...args)
|
||||
}
|
||||
export function initialize(bool = true, type = 'all') {
|
||||
log.initialize() // 为渲染器进行初始化
|
||||
if (bool) { // 是否替换默认的console
|
||||
if (type == 'all') Object.assign(console, log.functions)
|
||||
else { // 替换指定类型
|
||||
console[type] = log[type]
|
||||
}
|
||||
}
|
||||
}
|
||||
export default { initialize }
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* @description 解决 主进程|渲染进程 数据共享
|
||||
*/
|
||||
import Store from 'electron-store' // 持久化存储
|
||||
|
||||
// 设置ipc与渲染器通信
|
||||
Store.initRenderer()
|
||||
|
||||
// 默认共享数据
|
||||
const defaultData = {
|
||||
session: { // 缓存(临时sessionStorage)
|
||||
model: 'select', // 悬浮球-当前模式
|
||||
showBoardAll: false, // 全屏画板-是否显示
|
||||
isPdfWin: false, // pdf窗口是否打开
|
||||
isToolWin: false, // 工具窗口是否打开
|
||||
curSubjectNode: {
|
||||
data: {}, // 当前教材节点 (包含当前教材 单元)
|
||||
querySearch: {} // 查询资源所需参数
|
||||
}
|
||||
},
|
||||
local: { // 本地(永久localStorage)
|
||||
},
|
||||
}
|
||||
|
||||
// 初始化
|
||||
export function initialize(){
|
||||
// 缓存数据-sessionStore
|
||||
const sessionStore = new Store({
|
||||
name: 'session-store', // 存储文件名
|
||||
fileExtension: 'ini', // 文件后缀名
|
||||
encryptionKey: 'BvPLmgCC4DSIG0KkTec5', // 数据加密-防止用户直接改配置
|
||||
beforeEachMigration: (store, context) => { // 版本迁移回调
|
||||
console.log(`[session-store] 迁移从 ${context.fromVersion} → ${context.toVersion}`);
|
||||
},
|
||||
migrations: { // 版本变化
|
||||
'0.0.0': store => {
|
||||
// store.set('debugPhase', true);
|
||||
}
|
||||
}
|
||||
})
|
||||
sessionStore.clear() // 先清除-所有缓存数据
|
||||
sessionStore.set(defaultData.session) // 初始化-默认数据
|
||||
|
||||
// 缓存数据-localStore
|
||||
const localStore = new Store({
|
||||
name: 'local-store', // 存储文件名
|
||||
fileExtension: 'ini', // 文件后缀名
|
||||
encryptionKey: '6CyoHQmUaPmLzvVsh', // 数据加密-防止用户直接改配置
|
||||
beforeEachMigration: (store, context) => { // 版本迁移回调
|
||||
console.log(`[local-store] 迁移从 ${context.fromVersion} → ${context.toVersion}`);
|
||||
},
|
||||
migrations: { // 版本变化
|
||||
'0.0.0': store => {
|
||||
// store.set('debugPhase', true);
|
||||
}
|
||||
}
|
||||
})
|
||||
localStore.set(defaultData.local) // 初始化-默认数据
|
||||
return {sessionStore, localStore}
|
||||
}
|
||||
export default { initialize }
|
|
@ -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]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>AIx智慧教育</title>
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<!-- <meta
|
||||
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' 'unsafe-eval'; 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' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *;img-src * 'self' data: blob:" />
|
||||
|
||||
</head>
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @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)
|
||||
// 特殊格式处理
|
||||
let headers
|
||||
if (type == 'file') headers = { 'Content-Type': 'multipart/form-data' }
|
||||
else if (type == 'json') headers = { 'Content-Type': 'application/json' }
|
||||
else if (type == 'form') headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||
headers && (config.headers = { ...config.headers, ...headers })
|
||||
return request(config)
|
||||
}
|
||||
}
|
||||
// zdg: 腾讯云-即时通讯
|
||||
export class imChat {
|
||||
// 获取腾讯im-chat appid 签名
|
||||
static getTxCloudSign = data => ApiService.publicHttp('/system/user/txCloudSign', data)
|
||||
}
|
|
@ -50,7 +50,7 @@ export function getClassmain(id) {
|
|||
// 获取小组列表
|
||||
export function listClassgroup(query) {
|
||||
return request({
|
||||
url: '/education/classgroup/list',
|
||||
url: '/education/classgroup/new/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
|
@ -159,11 +159,13 @@ export function deleteSmartReserv(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
export function startClass(id) {
|
||||
export function startClass(id, ex3) {
|
||||
const params = {id}
|
||||
!!ex3 && (params.ex3 = ex3)
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/startClass',
|
||||
method: 'get',
|
||||
params: {id}
|
||||
params
|
||||
})
|
||||
}
|
||||
export function endClass(id) {
|
||||
|
@ -173,3 +175,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}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
// 查询evaluation列表
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询反馈列表
|
||||
|
||||
// 查询classworkdata列表 班级作业列表
|
||||
export function listClassworkdata(query) {
|
||||
return request({
|
||||
url: '/education/classworkdata/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询entpcoursework列表 课程作业列表
|
||||
export function listEntpcoursework(query) {
|
||||
return request({
|
||||
url: '/education/entpcoursework/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询classworkeval列表 课堂作业列表
|
||||
export function listClassworkeval(query) {
|
||||
return request({
|
||||
url: '/education/classworkeval/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 修改classworkeval
|
||||
export function updateClassworkeval(data) {
|
||||
return request({
|
||||
url: '/education/classworkeval',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 0------------------------
|
||||
// 查询班级列表
|
||||
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/new/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
|
||||
})
|
||||
}
|
||||
//新增课程预约
|
||||
export function addSmartClassReserv(data) {
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/addSmartClassReserv',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//修改课程预约
|
||||
export function updateSmartClassReserv(data) {
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/updateSmartClassReserv',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
//查询课程预约
|
||||
export function getSelfReserv() {
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/getSelfReserv',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
export function deleteSmartReserv(id) {
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
export function startClass(id, ex3) {
|
||||
const params = {id}
|
||||
!!ex3 && (params.ex3 = ex3)
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/startClass',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
export function endClass(id) {
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/endClass',
|
||||
method: 'get',
|
||||
params: {id}
|
||||
})
|
||||
}
|
||||
/**
|
||||
* @description 获取课堂信息
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function getClassInfo(id) {
|
||||
return request({
|
||||
url: '/smarttalk/classReserv/selectById',
|
||||
method: 'get',
|
||||
params: {id}
|
||||
})
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
//查询第三方课件的接口
|
||||
import request from '@/utils/request'
|
||||
//获取学科
|
||||
export const getSubjects = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getSubjects',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
//获取教材版本
|
||||
export const getTextbookVersion = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getVersions',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
//获得书籍
|
||||
export const getTextbook = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getBooks',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
//获取书籍章节
|
||||
export const getBook = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getChapters',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
//获取知识点信息
|
||||
export const getKnowledge = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getKnowledgePoints',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
//查询列表资源
|
||||
export const getBookList = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getDocuments',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
//获取图片路径
|
||||
export const getImgPath = (params) => {
|
||||
return request({
|
||||
url: '/smarttalk/cnjy/getPreview',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -50,3 +50,9 @@ export function updateUserInfo(data) {
|
|||
data: data
|
||||
})
|
||||
}
|
||||
export function getUserInfo(userId) {
|
||||
return request({
|
||||
url: '/system/user/' + userId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -43,3 +43,12 @@ export function delClasswork(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增classwork
|
||||
export function addClassworkReturnId(data) {
|
||||
return request({
|
||||
url: '/education/classwork/saveAndReturnId',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 2794390 */
|
||||
src: url('iconfont.woff2?t=1723452423265') format('woff2'),
|
||||
url('iconfont.woff?t=1723452423265') format('woff'),
|
||||
url('iconfont.ttf?t=1723452423265') format('truetype'),
|
||||
url('iconfont.svg?t=1723452423265#iconfont') format('svg');
|
||||
src: url('iconfont.woff2?t=1724212790213') format('woff2'),
|
||||
url('iconfont.woff?t=1724212790213') format('woff'),
|
||||
url('iconfont.ttf?t=1724212790213') format('truetype'),
|
||||
url('iconfont.svg?t=1724212790213#iconfont') format('svg');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
|
@ -14,6 +14,94 @@
|
|||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-yiwen:before {
|
||||
content: "\e687";
|
||||
}
|
||||
|
||||
.icon-yiwen-01:before {
|
||||
content: "\e688";
|
||||
}
|
||||
|
||||
.icon-yihuo:before {
|
||||
content: "\e689";
|
||||
}
|
||||
|
||||
.icon-a-yiwen:before {
|
||||
content: "\e6b1";
|
||||
}
|
||||
|
||||
.icon-zan:before {
|
||||
content: "\e658";
|
||||
}
|
||||
|
||||
.icon-zan1:before {
|
||||
content: "\e659";
|
||||
}
|
||||
|
||||
.icon-zan2:before {
|
||||
content: "\e65a";
|
||||
}
|
||||
|
||||
.icon-zan3:before {
|
||||
content: "\e65c";
|
||||
}
|
||||
|
||||
.icon-zan4:before {
|
||||
content: "\e67c";
|
||||
}
|
||||
|
||||
.icon-yizan:before {
|
||||
content: "\e67e";
|
||||
}
|
||||
|
||||
.icon-zan5:before {
|
||||
content: "\e67f";
|
||||
}
|
||||
|
||||
.icon-zan-yizan:before {
|
||||
content: "\e680";
|
||||
}
|
||||
|
||||
.icon-zan6:before {
|
||||
content: "\e681";
|
||||
}
|
||||
|
||||
.icon-MBEfenggeduosetubiao-xihuan:before {
|
||||
content: "\e682";
|
||||
}
|
||||
|
||||
.icon-zan7:before {
|
||||
content: "\e683";
|
||||
}
|
||||
|
||||
.icon-zan11:before {
|
||||
content: "\e6ff";
|
||||
}
|
||||
|
||||
.icon-zan8:before {
|
||||
content: "\e684";
|
||||
}
|
||||
|
||||
.icon-dianzan-red:before {
|
||||
content: "\e685";
|
||||
}
|
||||
|
||||
.icon-zan9:before {
|
||||
content: "\e69e";
|
||||
}
|
||||
|
||||
.icon-zanping:before {
|
||||
content: "\100ae";
|
||||
}
|
||||
|
||||
.icon-zan10:before {
|
||||
content: "\e686";
|
||||
}
|
||||
|
||||
.icon-arrangement:before {
|
||||
content: "\e656";
|
||||
}
|
||||
|
||||
.icon-zanwushuju:before {
|
||||
content: "\e655";
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,160 @@
|
|||
"css_prefix_text": "icon-",
|
||||
"description": "",
|
||||
"glyphs": [
|
||||
{
|
||||
"icon_id": "20574719",
|
||||
"name": "疑问",
|
||||
"font_class": "yiwen",
|
||||
"unicode": "e687",
|
||||
"unicode_decimal": 59015
|
||||
},
|
||||
{
|
||||
"icon_id": "21052326",
|
||||
"name": "yiwen-01",
|
||||
"font_class": "yiwen-01",
|
||||
"unicode": "e688",
|
||||
"unicode_decimal": 59016
|
||||
},
|
||||
{
|
||||
"icon_id": "30456317",
|
||||
"name": "疑惑",
|
||||
"font_class": "yihuo",
|
||||
"unicode": "e689",
|
||||
"unicode_decimal": 59017
|
||||
},
|
||||
{
|
||||
"icon_id": "33439935",
|
||||
"name": "[疑问]",
|
||||
"font_class": "a-yiwen",
|
||||
"unicode": "e6b1",
|
||||
"unicode_decimal": 59057
|
||||
},
|
||||
{
|
||||
"icon_id": "1242129",
|
||||
"name": "赞",
|
||||
"font_class": "zan",
|
||||
"unicode": "e658",
|
||||
"unicode_decimal": 58968
|
||||
},
|
||||
{
|
||||
"icon_id": "1741390",
|
||||
"name": "赞",
|
||||
"font_class": "zan1",
|
||||
"unicode": "e659",
|
||||
"unicode_decimal": 58969
|
||||
},
|
||||
{
|
||||
"icon_id": "3159200",
|
||||
"name": "赞",
|
||||
"font_class": "zan2",
|
||||
"unicode": "e65a",
|
||||
"unicode_decimal": 58970
|
||||
},
|
||||
{
|
||||
"icon_id": "3402139",
|
||||
"name": "赞",
|
||||
"font_class": "zan3",
|
||||
"unicode": "e65c",
|
||||
"unicode_decimal": 58972
|
||||
},
|
||||
{
|
||||
"icon_id": "4931286",
|
||||
"name": "赞 (1)",
|
||||
"font_class": "zan4",
|
||||
"unicode": "e67c",
|
||||
"unicode_decimal": 59004
|
||||
},
|
||||
{
|
||||
"icon_id": "4942300",
|
||||
"name": "已赞",
|
||||
"font_class": "yizan",
|
||||
"unicode": "e67e",
|
||||
"unicode_decimal": 59006
|
||||
},
|
||||
{
|
||||
"icon_id": "5806181",
|
||||
"name": "赞",
|
||||
"font_class": "zan5",
|
||||
"unicode": "e67f",
|
||||
"unicode_decimal": 59007
|
||||
},
|
||||
{
|
||||
"icon_id": "7172310",
|
||||
"name": "赞-已赞",
|
||||
"font_class": "zan-yizan",
|
||||
"unicode": "e680",
|
||||
"unicode_decimal": 59008
|
||||
},
|
||||
{
|
||||
"icon_id": "7293361",
|
||||
"name": "赞2",
|
||||
"font_class": "zan6",
|
||||
"unicode": "e681",
|
||||
"unicode_decimal": 59009
|
||||
},
|
||||
{
|
||||
"icon_id": "8705087",
|
||||
"name": "MBE风格多色图标-喜欢",
|
||||
"font_class": "MBEfenggeduosetubiao-xihuan",
|
||||
"unicode": "e682",
|
||||
"unicode_decimal": 59010
|
||||
},
|
||||
{
|
||||
"icon_id": "10024138",
|
||||
"name": "赞",
|
||||
"font_class": "zan7",
|
||||
"unicode": "e683",
|
||||
"unicode_decimal": 59011
|
||||
},
|
||||
{
|
||||
"icon_id": "11055391",
|
||||
"name": "赞",
|
||||
"font_class": "zan11",
|
||||
"unicode": "e6ff",
|
||||
"unicode_decimal": 59135
|
||||
},
|
||||
{
|
||||
"icon_id": "11086734",
|
||||
"name": "赞",
|
||||
"font_class": "zan8",
|
||||
"unicode": "e684",
|
||||
"unicode_decimal": 59012
|
||||
},
|
||||
{
|
||||
"icon_id": "23592614",
|
||||
"name": "点赞",
|
||||
"font_class": "dianzan-red",
|
||||
"unicode": "e685",
|
||||
"unicode_decimal": 59013
|
||||
},
|
||||
{
|
||||
"icon_id": "26327261",
|
||||
"name": "赞",
|
||||
"font_class": "zan9",
|
||||
"unicode": "e69e",
|
||||
"unicode_decimal": 59038
|
||||
},
|
||||
{
|
||||
"icon_id": "27804883",
|
||||
"name": "赞评",
|
||||
"font_class": "zanping",
|
||||
"unicode": "100ae",
|
||||
"unicode_decimal": 65710
|
||||
},
|
||||
{
|
||||
"icon_id": "29252894",
|
||||
"name": "赞",
|
||||
"font_class": "zan10",
|
||||
"unicode": "e686",
|
||||
"unicode_decimal": 59014
|
||||
},
|
||||
{
|
||||
"icon_id": "4978988",
|
||||
"name": "作业-布置作业",
|
||||
"font_class": "arrangement",
|
||||
"unicode": "e656",
|
||||
"unicode_decimal": 58966
|
||||
},
|
||||
{
|
||||
"icon_id": "9689424",
|
||||
"name": "暂无数据",
|
||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 352 KiB After Width: | Height: | Size: 337 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -42,11 +42,11 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref, nextTick, toRaw, reactive,watch } from 'vue';
|
||||
import { onMounted, ref, nextTick, toRaw, reactive } from 'vue';
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { listEvaluation } from '@/api/subject'
|
||||
|
||||
const BaseUrl = 'https://prev.ysaix.com:7868/'
|
||||
const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
||||
// 定义要发送的emit事件
|
||||
const emit = defineEmits(['nodeClick', 'changeBook'])
|
||||
// store
|
||||
|
@ -75,8 +75,9 @@ const curBookImg = ref('')
|
|||
const curBookPath = ref('')
|
||||
// 上册
|
||||
const volumeOne = ref([])
|
||||
// 下册
|
||||
//
|
||||
const volumeTwo = ref([])
|
||||
|
||||
// 当前节点
|
||||
const currentNode = reactive({
|
||||
data:{}
|
||||
|
@ -91,14 +92,15 @@ const defaultExpandedKeys = ref([])
|
|||
const refTree = ref(null)
|
||||
|
||||
|
||||
//获取教材下面的单元内容
|
||||
//获取教材下面的单元 + 章节
|
||||
const getSubjectContent = async () => {
|
||||
treeLoading.value = true
|
||||
const params = {
|
||||
edusubject,
|
||||
edustage,
|
||||
entpcourseedituserid: userId,
|
||||
pageSize: 500
|
||||
// entpcourseedituserid: userId,
|
||||
itemgroup: 'textbook',
|
||||
pageSize: 10000
|
||||
}
|
||||
|
||||
let data;
|
||||
|
@ -111,9 +113,12 @@ const getSubjectContent = async () => {
|
|||
//获取教材版本
|
||||
await getSubject()
|
||||
//上册
|
||||
volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
|
||||
//下册
|
||||
volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
|
||||
/**
|
||||
* 不区分上下册
|
||||
* 2024/08/20调整
|
||||
*/
|
||||
// volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
|
||||
// volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
|
||||
getTreeData()
|
||||
}
|
||||
|
||||
|
@ -131,13 +136,11 @@ const changeBook = ({ id, itemtitle, avartar, fileurl }) => {
|
|||
|
||||
const getTreeData = () => {
|
||||
//数据过滤
|
||||
let upData = transData(volumeOne.value)
|
||||
let downData = transData(volumeTwo.value)
|
||||
if(upData.length && downData.length){
|
||||
treeData.value = [...upData,...downData]
|
||||
}
|
||||
else if(upData.length || downData.length){
|
||||
treeData.value = upData.length ? upData : downData
|
||||
let upData = transData(evaluationList.value)
|
||||
|
||||
|
||||
if(upData.length){
|
||||
treeData.value = [...upData]
|
||||
}
|
||||
else{
|
||||
treeData.value = []
|
||||
|
@ -225,30 +228,33 @@ const transData = (data) => {
|
|||
let ary = []
|
||||
data.forEach(item => {
|
||||
let obj = {}
|
||||
// 根据当前教材ID 过滤出对应的单元、章节
|
||||
if (item.rootid == curBookId.value) {
|
||||
obj.label = item.itemtitle
|
||||
obj.id = item.id
|
||||
obj.itemtitle = item.itemtitle
|
||||
obj.edudegree = item.edudegree
|
||||
obj.edustage = item.edustage
|
||||
obj.edusubject = item.edusubject
|
||||
let ary2 = []
|
||||
evaluationList.value.forEach(el => {
|
||||
let obj2 = {}
|
||||
if (item.id == el.parentid) {
|
||||
obj2 = {
|
||||
label: el.itemtitle,
|
||||
id: el.id,
|
||||
itemtitle : el.itemtitle,
|
||||
edudegree : el.edudegree,
|
||||
edustage : el.edustage,
|
||||
edusubject : el.edusubject,
|
||||
if(item.level == 1){
|
||||
obj.label = item.itemtitle
|
||||
obj.id = item.id
|
||||
obj.itemtitle = item.itemtitle
|
||||
obj.edudegree = item.edudegree
|
||||
obj.edustage = item.edustage
|
||||
obj.edusubject = item.edusubject
|
||||
let ary2 = []
|
||||
evaluationList.value.forEach(el => {
|
||||
let obj2 = {}
|
||||
if (item.id == el.parentid) {
|
||||
obj2 = {
|
||||
label: el.itemtitle,
|
||||
id: el.id,
|
||||
itemtitle : el.itemtitle,
|
||||
edudegree : el.edudegree,
|
||||
edustage : el.edustage,
|
||||
edusubject : el.edusubject,
|
||||
}
|
||||
ary2.push(obj2)
|
||||
}
|
||||
ary2.push(obj2)
|
||||
}
|
||||
obj.children = ary2
|
||||
})
|
||||
ary.push(obj)
|
||||
obj.children = ary2
|
||||
})
|
||||
ary.push(obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
return ary
|
||||
|
@ -257,8 +263,10 @@ const transData = (data) => {
|
|||
//获取教材
|
||||
const getSubject = async () => {
|
||||
|
||||
const { rows } = await listEvaluation({ itemkey: "version", pageSize: 500 })
|
||||
subjectList.value = rows.filter(item => item.edustage == edustage && item.edusubject == edusubject)
|
||||
const { rows } = await listEvaluation({ itemkey: "version", edusubject, edustage, pageSize: 10000 })
|
||||
|
||||
// subjectList.value = rows.filter(item => item.edustage == edustage && item.edusubject == edusubject)
|
||||
subjectList.value = rows
|
||||
localStorage.setItem('subjectList', JSON.stringify(subjectList.value))
|
||||
|
||||
// 默认第一个
|
||||
|
@ -270,11 +278,11 @@ const getSubject = async () => {
|
|||
}
|
||||
|
||||
|
||||
// const isHaveUnit = (id) => {
|
||||
// return evaluationList.value.some(item => {
|
||||
// return item.rootid == id
|
||||
// })
|
||||
// }
|
||||
const isHaveUnit = (id) => {
|
||||
return evaluationList.value.some(item => {
|
||||
return item.rootid == id
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const handleNodeClick = (data, node) => {
|
||||
|
@ -305,9 +313,6 @@ const handleNodeClick = (data, node) => {
|
|||
currentNode.data = curData
|
||||
emit('nodeClick', curData)
|
||||
}
|
||||
watch(() => userStore.edusubject, () => {
|
||||
console.log(userStore.edusubject,'userStore.edusubject')
|
||||
})
|
||||
onMounted(() => {
|
||||
getSubjectContent()
|
||||
})
|
||||
|
|
|
@ -0,0 +1,291 @@
|
|||
<template>
|
||||
<div class="book-wrap">
|
||||
<el-scrollbar height="100%">
|
||||
<div class="book-name">
|
||||
<el-dropdown style="width: 100%;height: 100%">
|
||||
<div class="el-dropdown-link flex" style="width: 100%;height: 100%;justify-content: space-between;align-items: center">
|
||||
<span>{{titleName}}</span>
|
||||
<!-- <i class="iconfont icon-xiangyou"></i>-->
|
||||
</div>
|
||||
<!-- 学科学段选择-->
|
||||
<template #dropdown>
|
||||
<div style="width: 300px;padding: 20px">
|
||||
<ThirdIndex @getVertion="getVertion"></ThirdIndex>
|
||||
</div>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<div class="book-list" v-loading="treeLoading">
|
||||
<el-tree ref="refTree" :data="treeData" :props="defaultProps" node-key="id"
|
||||
:default-expanded-keys="defaultExpandedKeys" :current-node-key="node.currentNodeId" highlight-current
|
||||
@node-click="handleNodeClick">
|
||||
</el-tree>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import ThirdIndex from './third/index.vue'
|
||||
import {nextTick, reactive, ref,onMounted,watch} from 'vue'
|
||||
import {getBook, getTextbook} from '@/api/file/third'
|
||||
import useThirdStore from '@/store/modules/thirdTextbook'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
const useThird = useThirdStore()
|
||||
const useStore = useUserStore()
|
||||
const emit = defineEmits(['nodeClick'])
|
||||
const titleName = ref('')
|
||||
//树结构的数据
|
||||
const treeData = ref([])
|
||||
// 默认展开的节点
|
||||
const defaultExpandedKeys = ref([])
|
||||
const treeLoading = ref(false)
|
||||
const node = reactive({
|
||||
// 当前节点
|
||||
currentNode:{
|
||||
data:{}
|
||||
},
|
||||
// 当前选中的节点ID
|
||||
currentNodeId:0,
|
||||
// 当前选中的节点名称
|
||||
currentNodeName:''
|
||||
})
|
||||
//获取bookid
|
||||
const bookId = ref(0)
|
||||
//获取第一步所有章节
|
||||
const getVertion = (data) => {
|
||||
const arr = [...data]
|
||||
treeData.value = arr.map(item => {
|
||||
return {
|
||||
level:0,
|
||||
id: item.versionId,
|
||||
name: item.versionName,
|
||||
childs: []
|
||||
}
|
||||
})
|
||||
nextTick(() => {
|
||||
defaultExpandedKeys.value = [treeData.value[0].id]
|
||||
node.currentNode.data = treeData.value[0]
|
||||
node.currentNodeId = treeData.value[0].id
|
||||
node.currentNodeName = treeData.value[0].name
|
||||
treeLoading.value = false
|
||||
})
|
||||
}
|
||||
//初始化树形结构
|
||||
const getCurrent = (data) => {
|
||||
if(!data || data.length == 0) return
|
||||
nextTick(() => {
|
||||
defaultExpandedKeys.value = [data[0].id]
|
||||
node.currentNode.data = data[0]
|
||||
node.currentNodeId = data[0].id
|
||||
node.currentNodeName = data[0].name
|
||||
})
|
||||
}
|
||||
//获取教材
|
||||
const textbook = async (item) => {
|
||||
treeLoading.value = true
|
||||
const res = await getTextbook({versionId:item.id})
|
||||
if(res.code === 200){
|
||||
item.childs = res.data.map(items => {
|
||||
return {
|
||||
level:1,
|
||||
id: items.bookId,
|
||||
name: items.bookName,
|
||||
childs: []
|
||||
}
|
||||
})
|
||||
getCurrent(item.childs)
|
||||
treeLoading.value = false
|
||||
}
|
||||
}
|
||||
//获取年级
|
||||
const grade = async (item) => {
|
||||
treeLoading.value = true
|
||||
bookId.value = item.id
|
||||
const res = await getBook({bookId:item.id})
|
||||
if(res.code === 200){
|
||||
item.childs = res.data.map(items => {
|
||||
return {
|
||||
...items,
|
||||
}
|
||||
})
|
||||
getLastLevelData(item.childs)
|
||||
getCurrent(item.childs)
|
||||
treeLoading.value = false
|
||||
}
|
||||
}
|
||||
const getLastLevelData = (tree) => {
|
||||
let lastLevelData = [];
|
||||
// 递归函数遍历树形结构
|
||||
function traverseTree(nodes) {
|
||||
nodes.forEach((node) => {
|
||||
// 如果当前节点有子节点,继续遍历
|
||||
if (node.childs && node.childs.length > 0) {
|
||||
traverseTree(node.childs);
|
||||
} else {
|
||||
// 如果没有子节点,说明是最后一层的节点
|
||||
lastLevelData.push(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 调用递归函数开始遍历
|
||||
traverseTree(tree);
|
||||
|
||||
// 返回最后一层的数据
|
||||
return lastLevelData;
|
||||
}
|
||||
|
||||
//点击节点
|
||||
const handleNodeClick = (data,node) => {
|
||||
/**
|
||||
* data : 当前节点数据
|
||||
* node : 当前节点对象 包含当前节点所有数据 parent属性 指向父节点Node对象
|
||||
*/
|
||||
switch(node.data.level){
|
||||
case 0: textbook(data); break;
|
||||
case 1: grade(data); break;
|
||||
default: {
|
||||
getCurrent(data.childs);
|
||||
//获取资源列表
|
||||
emit('nodeClick',{
|
||||
chapterId:data.id,
|
||||
bookId:bookId.value,
|
||||
stage:data.stage,
|
||||
subjectId:data.subjectId,
|
||||
})
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//缓存
|
||||
onMounted(() => {
|
||||
titleName.value = `${useStore.user.edustage}-${useStore.user.edusubject}`
|
||||
treeLoading.value = true
|
||||
//存在查看无课程的情况,两秒后关闭loading框
|
||||
setTimeout(() => {
|
||||
treeLoading.value = false
|
||||
},2000)
|
||||
})
|
||||
//监听数据变化
|
||||
watch(() => useThird,() => {
|
||||
titleName.value = `${useStore.user.edustage}-${useStore.user.edusubject}`
|
||||
},{deep:true})
|
||||
|
||||
const defaultProps = {
|
||||
children: 'childs',
|
||||
label: 'name',
|
||||
class: 'textbook-tree'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.book-wrap {
|
||||
width: 300px;
|
||||
height: 100%;
|
||||
background: #ffffff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 0px 20px 0px rgba(99, 99, 99, 0.06);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
|
||||
.book-name {
|
||||
background-color: #ffffff;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 45px;
|
||||
padding: 0 15px;
|
||||
z-index: 1;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #3b3b3b;
|
||||
cursor: pointer;
|
||||
border-bottom: solid #f4f5f7 1px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
border-radius: 10px 10px 0 0;
|
||||
}
|
||||
|
||||
.book-list {
|
||||
padding: 45px 10px 0 10px;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.choose-dialog) {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.choose-book-header {
|
||||
justify-content: space-between;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
|
||||
.icon-guanbi {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.textbook-container {
|
||||
.textbook-item {
|
||||
padding: 10px 20px;
|
||||
align-items: center;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
|
||||
.book-name {
|
||||
margin-left: 20px;
|
||||
color: #3b3b3b;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f4f7f9;
|
||||
}
|
||||
}
|
||||
|
||||
.active-item {
|
||||
background-color: #f4f7f9;
|
||||
|
||||
.book-name {
|
||||
color: #368fff;
|
||||
font-weight: bold
|
||||
}
|
||||
}
|
||||
|
||||
.textbook-img {
|
||||
width: 55px;
|
||||
height: 70px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-tree-node) {
|
||||
.el-tree-node__content {
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
|
||||
&:hover {
|
||||
background-color: #eaf3ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tree-label {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
:deep(.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content) {
|
||||
background-color: #eaf3ff !important;
|
||||
color: #409EFF
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,73 @@
|
|||
<template>
|
||||
<el-tabs v-model="active" class="demo-tabs" @tab-change="handleClick">
|
||||
<template v-for="(item,index) in gradeList" :key="index">
|
||||
<el-tab-pane :label="item.label" :name="item.value" disabled>
|
||||
<SelectSubject ref="selectSubject" :subjectList="subjectList" @clickTag="getTagId"></SelectSubject>
|
||||
</el-tab-pane>
|
||||
</template>
|
||||
</el-tabs>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref,onMounted} from 'vue'
|
||||
import { gradeList } from '@/utils/resourceDict'
|
||||
import SelectSubject from './selectSubject.vue'
|
||||
import {getSubjects,getTextbookVersion} from '@/api/file/third'
|
||||
import useThirdStore from '@/store/modules/thirdTextbook'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
const useThird = useThirdStore()
|
||||
const useStore = useUserStore()
|
||||
|
||||
const emit = defineEmits(['getVertion'])
|
||||
const active = ref(1)
|
||||
//用来获取所有学科
|
||||
const subjectList = ref([])
|
||||
//用来获取学科的id
|
||||
const textbookVersionId = ref(0)
|
||||
//不需要切换年级教材了
|
||||
const handleClick = (tab) => {
|
||||
console.log(tab,'tab')
|
||||
getSubject(tab)
|
||||
}
|
||||
//获取当前学段所有学科
|
||||
const getSubject = (value) => {
|
||||
const currentIndex = gradeList.findIndex(item => item.value === value)
|
||||
getSubjects({stage:value}).then(res => {
|
||||
if(res.code === 200){
|
||||
if(res.data.length === 0) return
|
||||
subjectList.value = res.data.map(item => {
|
||||
return {
|
||||
...item,
|
||||
gradeName:gradeList[currentIndex].label
|
||||
}
|
||||
})
|
||||
const nameIndex = subjectList.value.findIndex(item => item.subjectName === useStore.user.edusubject)
|
||||
getTagId({subjectId:subjectList.value[nameIndex].subjectId,subjectName:subjectList.value[nameIndex].subjectName})
|
||||
if(textbookVersionId.value === 0){
|
||||
getTagId(subjectList.value[0])
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取教材列表
|
||||
const getTagId = (item) => {
|
||||
textbookVersionId.value = item.subjectId
|
||||
const currentIndex = gradeList.findIndex(item => item.value === active.value)
|
||||
getTextbookVersion({stage:active.value,subjectId:textbookVersionId.value}).then(res => {
|
||||
if(res.code === 200){
|
||||
emit('getVertion',res.data)
|
||||
useThird.getSelectBookInfo({...item,activeGrade:active.value,gradeName:gradeList[currentIndex].label})
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
const currentIndex = gradeList.findIndex(item => item.label === useStore.user.edustage)
|
||||
//首次渲染获取
|
||||
getSubject(gradeList[currentIndex].value)
|
||||
active.value = gradeList[currentIndex].value
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -0,0 +1,35 @@
|
|||
<template>
|
||||
<template v-for="item in subjectList" :key="item.subjectId">
|
||||
<el-tag
|
||||
:type="useStore.user.edusubject === item.subjectName && useStore.user.edustage === item.gradeName ? 'primary' : 'info'"
|
||||
effect="dark"
|
||||
round
|
||||
class="tagItem"
|
||||
:style="useStore.user.edusubject === item.subjectName && useStore.user.edustage === item.gradeName ? {'cursor': 'pointer'} : {'cursor': 'no-Drop'}"
|
||||
>
|
||||
{{ item.subjectName }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script setup name="selectSubject">
|
||||
import useUserStore from "@/store/modules/user";
|
||||
const useStore = useUserStore()
|
||||
const props = defineProps({
|
||||
subjectList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['clickTag'])
|
||||
// const clickTag = (item) => {
|
||||
// emit('clickTag',item)
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tagItem{
|
||||
margin-right: 5px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
|
@ -5,7 +5,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, defineProps, onMounted, defineEmits } from 'vue';
|
||||
import { ref, watch, onMounted, defineEmits } from 'vue';
|
||||
const placeholder = ref('')
|
||||
|
||||
const props = defineProps({
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
<template>
|
||||
<el-drawer v-model="model" class="preview-drawer" title="title" :modal="false" :with-header="false" append-to-body
|
||||
size="50%">
|
||||
<div class="flex drawer-header">
|
||||
<div>
|
||||
<div class="flex file-name">
|
||||
<FileImage :size="30" :file-name="'row.fileName'" />
|
||||
<span class="name">{{ row.fileShowName }}</span>
|
||||
</div>
|
||||
<div class="flex file-tag">
|
||||
<el-tag type="info" class="tag">{{ row.fileSuffix }}</el-tag>
|
||||
<el-tag type="info" class="tag">{{ row.fileFlag }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-close" @click="onClose"><i class="iconfont icon-guanbi"></i></div>
|
||||
</div>
|
||||
<div class="drawer-content">
|
||||
<!-- <iframe src="./aaa.pdf" width="600px" height="600px"></iframe> -->
|
||||
<!-- <div ref="playerRef" class="video-box"></div> -->
|
||||
<!-- <video src="" controls autoplay></video> -->
|
||||
<el-image style="width: 100%;" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" />
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
<script setup>
|
||||
import { watch, ref, nextTick } from 'vue'
|
||||
import Player from 'xgplayer'
|
||||
import 'xgplayer/dist/index.min.css'
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
|
||||
|
||||
const model = defineModel()
|
||||
const props = defineProps({
|
||||
row: {
|
||||
type: Object,
|
||||
default(){
|
||||
return {}
|
||||
}
|
||||
},
|
||||
})
|
||||
const playerRef = ref();
|
||||
const handleClose = () => {
|
||||
|
||||
}
|
||||
// 关闭
|
||||
const onClose = () => {
|
||||
model.value = false
|
||||
}
|
||||
|
||||
const init = () => {
|
||||
nextTick(() => {
|
||||
// 播放器 基础用法
|
||||
let player = new Player({
|
||||
el: playerRef.value,
|
||||
url: '//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4',
|
||||
width: '100%',
|
||||
autoplay: false,// 是否自动播放(默认false)
|
||||
videoAttributes: {// video扩展属性
|
||||
crossOrigin: 'anonymous',// 元素获取数据的 CORS 请求的配置
|
||||
},
|
||||
cssFullscreen: false,
|
||||
loop:true,// 是否开启循环播放(默认false)
|
||||
commonStyle:{
|
||||
progressColor: '#cccccce6',//进度条底色
|
||||
},
|
||||
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
watch(model, (newVal) => {
|
||||
if (newVal) {
|
||||
// init()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-drawer__body) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.preview-drawer {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.drawer-header {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
|
||||
.file-name {
|
||||
align-items: center;
|
||||
margin-bottom: 5px;
|
||||
|
||||
.name {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.file-tag {
|
||||
.tag {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.header-close {
|
||||
cursor: pointer;
|
||||
|
||||
.icon-guanbi {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.drawer-content {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.video-box {
|
||||
width: 100%;
|
||||
height: 300px
|
||||
}
|
||||
</style>
|
|
@ -88,8 +88,6 @@ const curBookId = ref(-1)
|
|||
const curBookName = ref('')
|
||||
// 上册
|
||||
const volumeOne = ref([])
|
||||
// 下册
|
||||
const volumeTwo = ref([])
|
||||
// 当前节点
|
||||
const currentNode = reactive({
|
||||
data: {}
|
||||
|
@ -115,7 +113,8 @@ const getSubjectContent = async () => {
|
|||
const params = {
|
||||
edusubject,
|
||||
edustage,
|
||||
entpcourseedituserid: userId,
|
||||
// entpcourseedituserid: userId,
|
||||
itemgroup: 'textbook',
|
||||
pageSize: 500
|
||||
}
|
||||
let data;
|
||||
|
@ -127,9 +126,12 @@ const getSubjectContent = async () => {
|
|||
//获取教材版本
|
||||
getSubject()
|
||||
//上册
|
||||
volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
|
||||
//下册
|
||||
volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
|
||||
/**
|
||||
* 不区分上下册
|
||||
* 2024/08/20调整
|
||||
*/
|
||||
// volumeOne.value = data.filter(item => item.level == 1)
|
||||
|
||||
getTreeData()
|
||||
}
|
||||
|
||||
|
@ -140,8 +142,8 @@ const getSubject = async () => {
|
|||
subjectList.value = JSON.parse(localStorage.getItem('subjectList'))
|
||||
}
|
||||
else {
|
||||
const { rows } = await listEvaluation({ itemkey: "version", pageSize: 500 })
|
||||
subjectList.value = rows.filter(item => item.edustage == edustage && item.edusubject == edusubject && isHaveUnit(item.id))
|
||||
const { rows } = await listEvaluation({ itemkey: "version", edusubject, edustage, pageSize: 500 })
|
||||
subjectList.value = rows
|
||||
localStorage.setItem('subjectList', JSON.stringify(subjectList.value))
|
||||
}
|
||||
|
||||
|
@ -159,14 +161,9 @@ const isHaveUnit = (id) => {
|
|||
|
||||
const getTreeData = () => {
|
||||
//数据过滤
|
||||
let upData = transData(volumeOne.value)
|
||||
let downData = transData(volumeTwo.value)
|
||||
|
||||
if(upData.length && downData.length){
|
||||
treeData.value = [...upData,...downData]
|
||||
}
|
||||
else if(upData.length || downData.length){
|
||||
treeData.value = upData.length ? upData : downData
|
||||
let upData = transData(evaluationList.value)
|
||||
if(upData.length){
|
||||
treeData.value = [...upData]
|
||||
}
|
||||
else{
|
||||
treeData.value = []
|
||||
|
@ -252,26 +249,35 @@ const handleNodeClick = (data, node) => {
|
|||
|
||||
const transData = (data) => {
|
||||
let ary = []
|
||||
|
||||
data.forEach(item => {
|
||||
let obj = {}
|
||||
|
||||
// 根据当前教材ID 过滤出对应的单元、章节
|
||||
if (item.rootid == curBookId.value) {
|
||||
obj.label = item.itemtitle
|
||||
obj.id = item.id
|
||||
let ary2 = []
|
||||
evaluationList.value.forEach(el => {
|
||||
let obj2 = {}
|
||||
if (item.id == el.parentid) {
|
||||
obj2 = {
|
||||
label: el.itemtitle,
|
||||
id: el.id
|
||||
if(item.level == 1){
|
||||
obj.label = item.itemtitle
|
||||
obj.id = item.id
|
||||
obj.itemtitle = item.itemtitle
|
||||
obj.edudegree = item.edudegree
|
||||
obj.edustage = item.edustage
|
||||
obj.edusubject = item.edusubject
|
||||
let ary2 = []
|
||||
evaluationList.value.forEach(el => {
|
||||
let obj2 = {}
|
||||
if (item.id == el.parentid) {
|
||||
obj2 = {
|
||||
label: el.itemtitle,
|
||||
id: el.id,
|
||||
itemtitle : el.itemtitle,
|
||||
edudegree : el.edudegree,
|
||||
edustage : el.edustage,
|
||||
edusubject : el.edusubject,
|
||||
}
|
||||
ary2.push(obj2)
|
||||
}
|
||||
ary2.push(obj2)
|
||||
}
|
||||
obj.children = ary2
|
||||
})
|
||||
ary.push(obj)
|
||||
obj.children = ary2
|
||||
})
|
||||
ary.push(obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
return ary
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<template>
|
||||
pdfAdnFabric<template>
|
||||
<div class="canvasitem">
|
||||
<div class="pdfAdnFabric" id="pdfAdnFabric">
|
||||
<canvas id="pdf-fabric"></canvas>
|
||||
<canvas id="pdf-fabric1" v-if="props.pdfObj.numberOfPdf == 2"></canvas>
|
||||
<div class="pdfAdnFabric" id="pdfAdnFabric" >
|
||||
<div :class="ispointer ? 'ispointer' : ''">
|
||||
<canvas ref="fabriccanvas" />
|
||||
</div>
|
||||
<div v-if="props.pdfObj.numberOfPdf === 2" :class="ispointer ? 'ispointer' : ''">
|
||||
<canvas ref="fabriccanvas1" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -13,12 +17,20 @@ import {
|
|||
onMounted,
|
||||
watch,
|
||||
reactive,
|
||||
defineProps,
|
||||
defineExpose,
|
||||
nextTick,
|
||||
defineEmits,watchEffect
|
||||
} from 'vue'
|
||||
import { fabric } from 'fabric'
|
||||
// import { fabric } from 'fabric'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { handleevent, savecanvsStore, initcanvasdata, displayData } from '@/utils/pdfAndFabric'
|
||||
import { fabricVue, TYPES } from '@/plugins/fabric'
|
||||
import { updateSmartBookMarkContent, addsmartBookMark,getBookMarkById } from '@/api/eTextbook/index'
|
||||
import {useToolState} from '@/store/modules/tool'
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const toolState = useToolState();
|
||||
const props = defineProps({
|
||||
pdfObj: {
|
||||
type: Object,
|
||||
|
@ -29,13 +41,16 @@ const props = defineProps({
|
|||
}
|
||||
}
|
||||
})
|
||||
const ispointer = ref(false) //是否画笔模式
|
||||
// canvas的所有数据
|
||||
const canvsStore = reactive({
|
||||
id: 'xxxx',
|
||||
pageArr: []
|
||||
})
|
||||
const fabriccanvas = ref(null)
|
||||
const fabriccanvas1 = ref(null)
|
||||
|
||||
const canvasFabricVue = ref(null)
|
||||
const canvas1FabricVue = ref(null)
|
||||
// 页面总数
|
||||
const numPagesTotal = ref(0)
|
||||
const imgarr = ref([])
|
||||
|
@ -47,9 +62,9 @@ const renderPage = async (canvasobj) => {
|
|||
const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise
|
||||
// 渲染当前页
|
||||
const page = await pdf.getPage(canvasobj.page)
|
||||
var screenWidth = window.innerWidth/2-100;
|
||||
var screenHeight = window.innerHeight;
|
||||
const viewport = page.getViewport({ scale:2})
|
||||
var screenWidth = window.innerWidth / 2 - 100
|
||||
var screenHeight = window.innerHeight
|
||||
const viewport = page.getViewport({ scale: 2 })
|
||||
|
||||
const canvasElement = canvasobj.canvas
|
||||
canvasElement.width = viewport.width
|
||||
|
@ -58,6 +73,11 @@ const renderPage = async (canvasobj) => {
|
|||
canvasContext: canvasobj.context,
|
||||
viewport: viewport
|
||||
}
|
||||
// console.log(renderContext,22222222222222222222)
|
||||
// const textContent = await page.getTextContent();
|
||||
// console.log(textContent);
|
||||
// const annotations = await page.getAnnotations();
|
||||
// console.log(annotations);
|
||||
page.render(renderContext).promise.then((res) => {
|
||||
const img = document.createElement('img')
|
||||
img.src = canvasobj.canvas.toDataURL('image/png')
|
||||
|
@ -68,34 +88,66 @@ const renderPage = async (canvasobj) => {
|
|||
// 根据传过来的pdf对象 判断改渲染哪一个fabric
|
||||
if (props.pdfObj.numberOfPdf == 2) {
|
||||
if (canvasobj.index == 0) {
|
||||
|
||||
fabriccanvas.value.setWidth(screenWidth)
|
||||
fabriccanvas.value.setHeight(screenHeight)
|
||||
displayData(fabriccanvas, canvsStore, canvasobj, fabric, img)
|
||||
canvasFabricVue.value.canvas.setWidth(screenWidth)
|
||||
canvasFabricVue.value.canvas.setHeight(screenHeight)
|
||||
// updateCanvasBackgroundImage(canvasFabricVue,img)
|
||||
displayData(canvasFabricVue, canvsStore, canvasobj, fabric, img)
|
||||
} else {
|
||||
fabriccanvas1.value.setWidth(screenWidth)
|
||||
fabriccanvas1.value.setHeight(screenHeight)
|
||||
displayData(fabriccanvas1, canvsStore, canvasobj, fabric, img)
|
||||
canvas1FabricVue.value.canvas.setWidth(screenWidth)
|
||||
canvas1FabricVue.value.canvas.setHeight(screenHeight)
|
||||
displayData(canvas1FabricVue, canvsStore, canvasobj, fabric, img)
|
||||
}
|
||||
} else {
|
||||
fabriccanvas.value.setWidth(screenWidth)
|
||||
fabriccanvas.value.setHeight(screenHeight)
|
||||
displayData(fabriccanvas, canvsStore, canvasobj, fabric, img)
|
||||
canvasFabricVue.value.canvas.setHeight(screenHeight)
|
||||
displayData(canvasFabricVue, canvsStore, canvasobj, fabric, img)
|
||||
}
|
||||
// console.log(imgarr.value)
|
||||
img.remove()
|
||||
}
|
||||
// 判断imgarr的JSONdata在canvsStore.pageArr有没有
|
||||
canvsStore.pageArr.forEach((item) => {
|
||||
if (item.page == canvasobj.page) {
|
||||
imgarr.value.forEach((img) => {
|
||||
if (img.page == canvasobj.page) {
|
||||
img.JSONdata = item.JSONdata
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
// 保存数据
|
||||
const savaDataStore = () => {
|
||||
if(!toolState.isToolWin){
|
||||
toolState.isPdfWin=false
|
||||
toolState.showBoardAll=true //恢复默认值
|
||||
// ipcRenderer.invoke('tool-sphere:reset') //重置tool状态
|
||||
ipcRenderer.send('open-PDF:minimize')
|
||||
return
|
||||
}
|
||||
imgarr.value.forEach((a) => {
|
||||
if (a.index == 0) {
|
||||
a.JSONdata = canvasFabricVue.value.canvas.toJSON()
|
||||
} else {
|
||||
a.JSONdata = canvas1FabricVue.value.canvas.toJSON()
|
||||
}
|
||||
})
|
||||
const nameMap = new Map(canvsStore.pageArr.map((item) => [item.page, item.id]))
|
||||
// 创建一个用于存储所有异步操作的数组
|
||||
let promises = []
|
||||
imgarr.value.forEach((item) => {
|
||||
if (nameMap.has(item.page)) {
|
||||
const params = {
|
||||
id: nameMap.get(item.page),
|
||||
contentData: JSON.stringify(item.JSONdata.objects)
|
||||
}
|
||||
promises.push(updateSmartBookMarkContent([params]))
|
||||
} else {
|
||||
promises.push(addsmartBookMark({
|
||||
pageNum: item.page,
|
||||
contentData: JSON.stringify(item.JSONdata.objects),
|
||||
bookId: props.pdfObj.bookId,
|
||||
type: '教材',
|
||||
source: 'smarttalk'
|
||||
}))
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
Promise.all(promises).then(res=>{
|
||||
toolState.isPdfWin=false
|
||||
toolState.showBoardAll=true //恢复默认值
|
||||
// ipcRenderer.invoke('tool-sphere:reset') //重置tool状态
|
||||
ipcRenderer.send('open-PDF:minimize')
|
||||
})
|
||||
}
|
||||
const updatePage = (canvasobj) => {
|
||||
renderPage(canvasobj)
|
||||
|
@ -105,16 +157,55 @@ const loadPdf = async (canvasobj) => {
|
|||
}
|
||||
|
||||
const initPdf = async (type = 'default') => {
|
||||
imgarr.value.forEach((a) => {
|
||||
if (a.index == 0) {
|
||||
a.JSONdata = canvasFabricVue.value.canvas.toJSON()
|
||||
} else {
|
||||
a.JSONdata = canvas1FabricVue.value.canvas.toJSON()
|
||||
}
|
||||
})
|
||||
// 判断是否翻页以及工具窗口是否打开 满足 翻页+打开工具才能保存数据
|
||||
if (type != 'default' && toolState.isToolWin) {
|
||||
const nameMap = new Map(canvsStore.pageArr.map((item) => [item.page, item.id]))
|
||||
// 创建一个用于存储所有异步操作的数组
|
||||
let promises = []
|
||||
imgarr.value.forEach((item) => {
|
||||
if (nameMap.has(item.page)) {
|
||||
const params = {
|
||||
id: nameMap.get(item.page),
|
||||
contentData: JSON.stringify(item.JSONdata.objects)
|
||||
}
|
||||
promises.push(updateSmartBookMarkContent([params]))
|
||||
} else {
|
||||
promises.push(addsmartBookMark({
|
||||
pageNum: item.page,
|
||||
contentData: JSON.stringify(item.JSONdata.objects),
|
||||
bookId: props.pdfObj.bookId,
|
||||
type: '教材',
|
||||
source: 'smarttalk'
|
||||
}))
|
||||
|
||||
}
|
||||
})
|
||||
Promise.all(promises).then(res=>{
|
||||
getBookMarkById(props.pdfObj.bookId).then(res=>{
|
||||
const pageArr=getUniqueArrayByLastOccurrence(res.data)
|
||||
canvsStore.pageArr=[]
|
||||
pageArr.forEach((a) => {
|
||||
canvsStore.pageArr.push({ page: a.pageNum, id: a.id, JSONdata: a.contentData })
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
// 保存数据
|
||||
savecanvsStore(imgarr, canvsStore)
|
||||
// initcanvasdata(fabriccanvas)
|
||||
// initcanvasdata(fabriccanvas1)
|
||||
// 单页模式
|
||||
if (type == 'restone') {
|
||||
// 清除 canvas 上的所有对象
|
||||
fabriccanvas1.value.clear()
|
||||
// 释放 canvas 的资源
|
||||
fabriccanvas1.value.dispose()
|
||||
// savecanvsStore(imgarr, canvsStore)
|
||||
|
||||
if (props.pdfObj.numberOfPdf == 1) {
|
||||
// imgarr.value[0]
|
||||
canvasFabricVue.value.history.clean()
|
||||
} else {
|
||||
canvasFabricVue.value.history.clean()
|
||||
canvas1FabricVue.value.history.clean()
|
||||
}
|
||||
// 清除现有 canvas 元素的内容
|
||||
canvasNumbsValue.value.forEach((canvasObj) => {
|
||||
|
@ -146,7 +237,6 @@ const initPdf = async (type = 'default') => {
|
|||
} else {
|
||||
canvasNumbsValue.value[i].page = props.pdfObj.numPages + 1
|
||||
}
|
||||
|
||||
canvasNumbsValue.value[i].index = i
|
||||
// 加载FabricVue
|
||||
await loadPdf(canvasNumbsValue.value[i])
|
||||
|
@ -154,47 +244,154 @@ const initPdf = async (type = 'default') => {
|
|||
}
|
||||
}
|
||||
}
|
||||
//根据page去重
|
||||
const getUniqueArrayByLastOccurrence=(array)=> {
|
||||
const uniqueItems = array.reduce((acc, current) => {
|
||||
// 使用 Map 来跟踪最后一个出现的 pageNum 和它的对象
|
||||
acc.set(current.pageNum, current);
|
||||
return acc;
|
||||
}, new Map());
|
||||
|
||||
// 将 Map 的值转换回数组
|
||||
const resultArray = Array.from(uniqueItems.values());
|
||||
|
||||
return resultArray;
|
||||
}
|
||||
const initPdfone = async () => {
|
||||
setTimeout(() => {
|
||||
fabriccanvas1.value = new fabric.Canvas('pdf-fabric1')
|
||||
fabriccanvas1.value.isDrawingMode = true
|
||||
fabriccanvas1.value.freeDrawingBrush.color = '#A33AFE'
|
||||
fabriccanvas1.value.freeDrawingCursor = 'default'
|
||||
fabriccanvas1.value.setWidth(860)
|
||||
handleevent(fabriccanvas1.value, imgarr, 'two')
|
||||
setTimeout(async () => {
|
||||
const option = { freeDrawingCursor: 'default' }
|
||||
const canvas2 = new fabricVue()
|
||||
await canvas2.initCanvas(fabriccanvas1.value, option)
|
||||
canvas2.canvas.setWidth(window.innerWidth / 2 - 100)
|
||||
canvas1FabricVue.value = canvas2
|
||||
await initPdf('addOnePage')
|
||||
}, 0)
|
||||
initPdf('addOnePage')
|
||||
}
|
||||
onMounted(async () => {
|
||||
try {
|
||||
// 创建canvas转化成图片
|
||||
const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise
|
||||
numPagesTotal.value = pdf.numPages
|
||||
// console.log(pdf)
|
||||
// 初始化fabriccanvas
|
||||
fabriccanvas.value = new fabric.Canvas('pdf-fabric')
|
||||
fabriccanvas.value.setWidth(860)
|
||||
fabriccanvas.value.isDrawingMode = true
|
||||
fabriccanvas.value.freeDrawingBrush.color = '#A33AFE'
|
||||
fabriccanvas.value.freeDrawingCursor = 'default'
|
||||
|
||||
fabriccanvas1.value = new fabric.Canvas('pdf-fabric1')
|
||||
fabriccanvas1.value.isDrawingMode = true
|
||||
fabriccanvas1.value.freeDrawingBrush.color = '#A33AFE'
|
||||
fabriccanvas1.value.freeDrawingCursor = 'default'
|
||||
fabriccanvas1.value.setWidth(860)
|
||||
const option = { freeDrawingCursor: 'default' }
|
||||
const canvas1 = new fabricVue()
|
||||
// canvas1.boardConfig.mode= TYPES.ActionMode.OTHER
|
||||
// canvas1.boardConfig.mode= TYPES.ActionMode.ERASE
|
||||
await canvas1.initCanvas(fabriccanvas.value, option)
|
||||
canvas1.canvas.setWidth(window.innerWidth / 2 - 100)
|
||||
canvasFabricVue.value = canvas1
|
||||
const canvas2 = new fabricVue()
|
||||
await canvas2.initCanvas(fabriccanvas1.value, option)
|
||||
canvas2.canvas.setWidth(window.innerWidth / 2 - 100)
|
||||
// canvas2.canvas.isDrawingMode=false
|
||||
canvas1FabricVue.value = canvas2
|
||||
window.test = { canvas1, canvas2 }
|
||||
emit('update:numPagesTotal', pdf.numPages)
|
||||
initPdf()
|
||||
|
||||
if (props.pdfObj.allPageData.length) {
|
||||
props.pdfObj.allPageData.forEach((a) => {
|
||||
if (a.pageNum == 1 || a.pageNum == 2) {
|
||||
canvsStore.pageArr.push({ page: a.pageNum, id: a.id, JSONdata: a.contentData })
|
||||
}
|
||||
})
|
||||
}
|
||||
await initPdf()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
ElMessage.error('pdf文件错误')
|
||||
}
|
||||
setToolStatus()
|
||||
// 监听2个canvas事件
|
||||
handleevent(fabriccanvas.value, imgarr)
|
||||
handleevent(fabriccanvas1.value, imgarr, 'two')
|
||||
// handleevent(fabriccanvas.value, imgarr)
|
||||
// handleevent(fabriccanvas1.value, imgarr, 'two')
|
||||
})
|
||||
// zdg: 设置-底部工具栏-状态
|
||||
const setToolStatus = () => {
|
||||
toolState.showBoardAll = false
|
||||
}
|
||||
// 判断元素是否加载完成
|
||||
const handleMode = (vale,type)=>{
|
||||
if(vale=='select'){
|
||||
ispointer.value=true
|
||||
}else{
|
||||
ispointer.value=false
|
||||
}
|
||||
switch(vale) {
|
||||
case 'select': // 选择模式
|
||||
canvasFabricVue.value?.handleMode(TYPES.ActionMode.OTHER)
|
||||
canvas1FabricVue.value?.handleMode(TYPES.ActionMode.OTHER)
|
||||
break
|
||||
case 'brush': // 画笔模式
|
||||
canvasFabricVue.value?.handleMode(TYPES.ActionMode.DRAW)
|
||||
canvasFabricVue.value.canvas.freeDrawingCursor = 'default'
|
||||
canvas1FabricVue.value?.handleMode(TYPES.ActionMode.DRAW)
|
||||
canvas1FabricVue.value.canvas.freeDrawingCursor = 'default'
|
||||
break
|
||||
case 'erase': // 板擦模式
|
||||
canvasFabricVue.value?.handleMode(TYPES.ActionMode.ERASE)
|
||||
canvas1FabricVue.value?.handleMode(TYPES.ActionMode.ERASE)
|
||||
break
|
||||
case 'clear': // 清空画布
|
||||
clearCanvas()
|
||||
// canvas1FabricVue.value.history?.clean()
|
||||
break
|
||||
}
|
||||
}
|
||||
// 清空canvas
|
||||
const clearCanvas=()=>{
|
||||
if(canvasFabricVue.value){
|
||||
const objects = canvasFabricVue.value.canvas.getObjects();
|
||||
objects.forEach((obj) => {
|
||||
// 检查对象是否是背景
|
||||
if (obj !== canvasFabricVue.value.canvas.backgroundImage) {
|
||||
// 删除背景之外的对象
|
||||
canvasFabricVue.value.canvas.remove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
canvasFabricVue.value.canvas.renderAll();
|
||||
}
|
||||
if(canvas1FabricVue.value){
|
||||
const objects = canvas1FabricVue.value.canvas.getObjects();
|
||||
objects.forEach((obj) => {
|
||||
// 检查对象是否是背景
|
||||
if (obj !== canvas1FabricVue.value.canvas.backgroundImage) {
|
||||
// 删除背景之外的对象
|
||||
canvas1FabricVue.value.canvas.remove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
canvas1FabricVue.value.canvas.renderAll();
|
||||
}
|
||||
}
|
||||
const watchToolState=()=>{
|
||||
if(toolState.showBoardAll){
|
||||
setTimeout(() => {
|
||||
toolState.showBoardAll=false
|
||||
}, 200);
|
||||
}
|
||||
// 加载工具
|
||||
handleMode(toolState.model)
|
||||
|
||||
}
|
||||
defineExpose({
|
||||
initPdf,
|
||||
initPdfone
|
||||
initPdfone,
|
||||
savaDataStore
|
||||
})
|
||||
watchEffect(() => {
|
||||
setTimeout(() => {
|
||||
console.log(toolState,'监听')
|
||||
|
||||
}, 300)
|
||||
if(toolState.isPdfWin){
|
||||
// if(toolState.isToolWin){
|
||||
// ispointer.value=false
|
||||
// }else{
|
||||
// ispointer.value=true
|
||||
// }
|
||||
watchToolState() //监听工具栏
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -204,6 +401,8 @@ defineExpose({
|
|||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
max-height: 100vh;
|
||||
}
|
||||
.pdfAdnFabric {
|
||||
position: relative;
|
||||
|
@ -214,4 +413,7 @@ defineExpose({
|
|||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
.ispointer {
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
|
@ -1,15 +1,9 @@
|
|||
pdfAdnFabric<template>
|
||||
<div class="canvasitem">
|
||||
<div class="pdfAdnFabric" id="pdfAdnFabric" >
|
||||
<!-- @touchmove="handleTouchMove"
|
||||
@touchend="handleTouchEnd"
|
||||
@mousedown="handleMouseDown"
|
||||
@mousemove="handleMouseMove"
|
||||
@mouseup="handleMouseUp" -->
|
||||
<div :class="ispointer ? 'ispointer' : ''">
|
||||
<canvas ref="fabriccanvas" />
|
||||
</div>
|
||||
<!-- style="pointer-events: none;" -->
|
||||
<div v-if="props.pdfObj.numberOfPdf === 2" :class="ispointer ? 'ispointer' : ''">
|
||||
<canvas ref="fabriccanvas1" />
|
||||
</div>
|
||||
|
@ -79,8 +73,6 @@ const renderPage = async (canvasobj) => {
|
|||
canvasContext: canvasobj.context,
|
||||
viewport: viewport
|
||||
}
|
||||
// console.log(renderContext,22222222222222222222)
|
||||
|
||||
page.render(renderContext).promise.then((res) => {
|
||||
const img = document.createElement('img')
|
||||
img.src = canvasobj.canvas.toDataURL('image/png')
|
||||
|
@ -93,7 +85,6 @@ const renderPage = async (canvasobj) => {
|
|||
if (canvasobj.index == 0) {
|
||||
canvasFabricVue.value.canvas.setWidth(screenWidth)
|
||||
canvasFabricVue.value.canvas.setHeight(screenHeight)
|
||||
// updateCanvasBackgroundImage(canvasFabricVue,img)
|
||||
displayData(canvasFabricVue, canvsStore, canvasobj, fabric, img)
|
||||
} else {
|
||||
canvas1FabricVue.value.canvas.setWidth(screenWidth)
|
||||
|
@ -106,25 +97,22 @@ const renderPage = async (canvasobj) => {
|
|||
}
|
||||
img.remove()
|
||||
}
|
||||
// 判断imgarr的JSONdata在canvsStore.pageArr有没有
|
||||
// canvsStore.pageArr.forEach((item) => {
|
||||
// if (item.page == canvasobj.page) {
|
||||
// imgarr.value.forEach((img) => {
|
||||
// if (img.page == canvasobj.page) {
|
||||
// img.JSONdata = item.JSONdata
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
})
|
||||
}
|
||||
// 保存数据
|
||||
const savaDataStore = () => {
|
||||
const savaDataStore = async (type) => {
|
||||
if(!toolState.isToolWin){
|
||||
toolState.isPdfWin=false
|
||||
toolState.showBoardAll=true //恢复默认值
|
||||
ipcRenderer.invoke('tool-sphere:reset') //重置tool状态
|
||||
ipcRenderer.send('open-PDF:minimize')
|
||||
toolState.isPdfWin = false
|
||||
await sleep(20) // 延时
|
||||
toolState.showBoardAll = true //恢复默认值
|
||||
await sleep(50) // 延时
|
||||
if(type=='rest'){
|
||||
// ipcRenderer.invoke('tool-sphere:reset') //重置tool状态-废弃
|
||||
ipcRenderer.send('open-PDF:close')
|
||||
}else{
|
||||
ipcRenderer.invoke('open-PDF:minimize')
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
imgarr.value.forEach((a) => {
|
||||
|
@ -155,13 +143,24 @@ const savaDataStore = () => {
|
|||
|
||||
}
|
||||
})
|
||||
Promise.all(promises).then(res=>{
|
||||
Promise.all(promises).then(async res=>{
|
||||
toolState.isPdfWin=false
|
||||
await sleep(20) // 延时
|
||||
toolState.showBoardAll=true //恢复默认值
|
||||
ipcRenderer.invoke('tool-sphere:reset') //重置tool状态
|
||||
ipcRenderer.send('open-PDF:minimize')
|
||||
await sleep(50) // 延时
|
||||
// ipcRenderer.send('open-PDF:minimize')
|
||||
if(type=='rest'){
|
||||
// ipcRenderer.invoke('tool-sphere:reset') //重置tool状态-废弃
|
||||
ipcRenderer.send('open-PDF:close')
|
||||
}else{
|
||||
ipcRenderer.invoke('open-PDF:minimize')
|
||||
}
|
||||
// ipcRenderer.send('open-PDF:close')
|
||||
|
||||
})
|
||||
}
|
||||
// 延时
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||
const updatePage = (canvasobj) => {
|
||||
renderPage(canvasobj)
|
||||
}
|
||||
|
@ -211,10 +210,7 @@ const initPdf = async (type = 'default') => {
|
|||
})
|
||||
}
|
||||
// 保存数据
|
||||
// savecanvsStore(imgarr, canvsStore)
|
||||
|
||||
if (props.pdfObj.numberOfPdf == 1) {
|
||||
// imgarr.value[0]
|
||||
canvasFabricVue.value.history.clean()
|
||||
} else {
|
||||
canvasFabricVue.value.history.clean()
|
||||
|
@ -393,8 +389,9 @@ defineExpose({
|
|||
savaDataStore
|
||||
})
|
||||
watchEffect(() => {
|
||||
console.log(toolState.model,'监听')
|
||||
watchToolState() //监听工具栏
|
||||
if(toolState.isPdfWin){
|
||||
watchToolState() //监听工具栏
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="500"
|
||||
<el-dialog v-model="model" append-to-body :show-close="false" width="500"
|
||||
top="25vh"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
|
@ -34,12 +34,14 @@
|
|||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { listEvaluation } from '@/api/subject'
|
||||
import { updateUserInfo } from '@/api/system/user'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const { userId, userName } = userStore.user
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
|
||||
const props = defineProps({
|
||||
loginData: {
|
||||
|
@ -48,17 +50,11 @@ const props = defineProps({
|
|||
return {}
|
||||
}
|
||||
},
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
})
|
||||
|
||||
const model = defineModel();
|
||||
const subjectLoading = ref(false)
|
||||
|
||||
// 定义要发送的emit事件
|
||||
const emit = defineEmits(['update:modelValue', 'onSuccess'])
|
||||
|
||||
// 默认学段 前端写死 参照web AIx
|
||||
const gradeList = ref([
|
||||
{
|
||||
label: '高中',
|
||||
|
@ -85,7 +81,6 @@ gradeVal.value = gradeList.value[0].value
|
|||
//学科列表数据
|
||||
const subjectList = ref([])
|
||||
const allSubject = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
//切换年级
|
||||
const changeGrade = ()=>{
|
||||
|
@ -98,8 +93,8 @@ const changeGrade = ()=>{
|
|||
// 默认选中第一个学科
|
||||
subjectVal.value = subjectList.value[0].itemtitle
|
||||
}
|
||||
// 获取学科数据
|
||||
|
||||
// 获取学科数据
|
||||
const getSubject = async ()=>{
|
||||
const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 })
|
||||
// 所有学科
|
||||
|
@ -119,7 +114,6 @@ const editUserInfo = async () =>{
|
|||
edustage: gradeVal.value,
|
||||
edusubject: subjectVal.value
|
||||
}
|
||||
|
||||
// 修改之后需要重新登录 查询用户信息,否则不登录 查询的用户信息是未修改之前的
|
||||
// 接口如此,我也不知道为啥要这样
|
||||
subjectLoading.value = true
|
||||
|
@ -128,14 +122,15 @@ const editUserInfo = async () =>{
|
|||
await updateUserInfo(data)
|
||||
await userStore.login(props.loginData)
|
||||
await userStore.getInfo()
|
||||
ElMessage.success('登录成功')
|
||||
model.value = false
|
||||
ipcRenderer && ipcRenderer.send('openMainWindow')
|
||||
} finally {
|
||||
subjectLoading.value = false
|
||||
}
|
||||
emit('onSuccess')
|
||||
}
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
dialogVisible.value = newVal
|
||||
watch(() => model.value, (newVal) => {
|
||||
if(newVal){
|
||||
getSubject()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,323 @@
|
|||
<template>
|
||||
<el-dialog v-model="model" center top="10vh" width="600px" :show-close="false" destroy-on-close append-to-body
|
||||
style="border-radius: 10px; padding: 10px 15px">
|
||||
<template #header>
|
||||
<div class="homerwork-header flex">
|
||||
<span>{{ title }}</span>
|
||||
<i class="iconfont icon-guanbi" @click="cloneDialog(ruleFormRef)"></i>
|
||||
</div>
|
||||
</template>
|
||||
<div v-loading="setLoading">
|
||||
<el-form :model="form" label-width="80px" ref="ruleFormRef" :rules="rules">
|
||||
<el-form-item label="班级" prop="grade">
|
||||
<el-scrollbar max-height="200px" style="width: 100%">
|
||||
<el-tree :props="defaultProps" :load="getLoad" node-key="id" highlight-current @check="handleCheckChange"
|
||||
lazy show-checkbox />
|
||||
</el-scrollbar>
|
||||
</el-form-item>
|
||||
<el-form-item label="选中学生" prop="student">
|
||||
<el-scrollbar max-height="200px">
|
||||
<el-tag v-for="(tag, index) in studentList" :key="tag.studentid" closable type="primary"
|
||||
@close="delStudent(index)">
|
||||
{{ tag.name }}
|
||||
</el-tag>
|
||||
</el-scrollbar>
|
||||
</el-form-item>
|
||||
<el-form-item label="完成要求" prop="feedback">
|
||||
<el-radio-group v-model="form.feedback">
|
||||
<el-radio value="必做" size="large">必做</el-radio>
|
||||
<el-radio value="选做" size="large">选做</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="截止时间" prop="deaddate">
|
||||
<el-date-picker v-model="form.deaddate" value-format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
|
||||
time-format="HH:mm" type="datetime" :clearable="false" placeholder="请选择截止时间" />
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐用时" prop="timelength">
|
||||
<el-input-number v-model="form.timelength" :min="1" :max="500" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click.stop="cloneDialog(ruleFormRef)">取消</el-button>
|
||||
<el-button type="primary" @click.stop="onSubmit(ruleFormRef)"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { listClassmain, listClassgroup } from '@/api/classManage/index'
|
||||
import { saveByClassWorkArray } from '@/api/teaching/classwork'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { uniqBy, groupBy } from 'lodash'
|
||||
|
||||
const model = defineModel({ type: Boolean, default: false })
|
||||
const props = defineProps({
|
||||
entpcourseid: {
|
||||
default: ''
|
||||
},
|
||||
row: {
|
||||
default: ''
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '布置作业'
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['on-close', 'on-success'])
|
||||
const ruleFormRef = ref('')
|
||||
// 配置项
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'label',
|
||||
isLeaf: 'leaf'
|
||||
}
|
||||
|
||||
// loading
|
||||
const setLoading = ref(false)
|
||||
// 用户信息
|
||||
const userInfo = useUserStore().user
|
||||
// 班级列表
|
||||
const gradeList = ref([])
|
||||
// 选中的学生列表
|
||||
const studentList = ref([])
|
||||
// 表单
|
||||
const form = reactive({
|
||||
feedback: '必做',
|
||||
deaddate: '',
|
||||
timelength: 1
|
||||
})
|
||||
// 表单校验
|
||||
const validateGrade = (rule, value, callback) => {
|
||||
if (studentList.value.length == 0) {
|
||||
callback(new Error('请勾选班级或者学生'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const validateStudent = (rule, value, callback) => {
|
||||
if (studentList.value.length == 0) {
|
||||
callback(new Error('学生不能为空'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const rules = reactive({
|
||||
grade: [{ validator: validateGrade, trigger: 'blur' }],
|
||||
student: [{ validator: validateStudent, trigger: 'blur' }]
|
||||
})
|
||||
|
||||
// 获取班级
|
||||
const getGradeList = async () => {
|
||||
let { rows } = await listClassmain({
|
||||
classuserid: userInfo.userId,
|
||||
pageSize: 100,
|
||||
status: 'open'
|
||||
})
|
||||
rows.forEach((item) => {
|
||||
item.label = item.caption
|
||||
item.level = 0
|
||||
item.leaf = false
|
||||
item.children = []
|
||||
item.classstudentlist = JSON.parse('[' + item.classstudentlist + ']')
|
||||
item.classstudentlist.forEach((el) => {
|
||||
el.classId = item.id
|
||||
})
|
||||
})
|
||||
return rows
|
||||
}
|
||||
// 获取节点下一级
|
||||
const getLoad = async (node, resolve) => {
|
||||
// 获取一级节点 班级
|
||||
if (node.level == 0) {
|
||||
gradeList.value = await getGradeList()
|
||||
resolve(gradeList.value)
|
||||
}
|
||||
// 获取二级节点 小组
|
||||
if (node.level == 1) {
|
||||
listClassgroup({ classid: node.key, orderby: 'orderidx', pageSize: 100 }).then((res) => {
|
||||
if (res.rows.length > 0) {
|
||||
let ary = []
|
||||
res.rows.forEach((item) => {
|
||||
if (item.parentid === 0) {
|
||||
//studentGroup 小组学生 为三级节点
|
||||
let studentGroup = JSON.parse('[' + item.studentlist + ']')
|
||||
studentGroup.forEach((el) => {
|
||||
el.label = el.name
|
||||
el.leaf = true
|
||||
el.level = 2
|
||||
el.id = el.studentid
|
||||
el.classId = item.classid
|
||||
})
|
||||
ary.push({
|
||||
label: item.groupname,
|
||||
leaf: false,
|
||||
...item,
|
||||
level: 1,
|
||||
// children 小组学生 三级节点 这样就不用再从接口拿
|
||||
children: studentGroup
|
||||
})
|
||||
}
|
||||
})
|
||||
resolve(ary)
|
||||
} else {
|
||||
// 班级下面没有小组 直接取学生
|
||||
let students = node.data.classstudentlist
|
||||
students.forEach((item) => {
|
||||
item.label = item.name
|
||||
item.level = 2
|
||||
item.leaf = true
|
||||
})
|
||||
resolve(students)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 三级节点 小组学生
|
||||
if (node.level == 2) {
|
||||
resolve(node.data.children)
|
||||
}
|
||||
}
|
||||
//节点勾选后触发 拿学生
|
||||
const handleCheckChange = (data, checked) => {
|
||||
studentList.value = []
|
||||
// 选中节点集合
|
||||
let checkNodes = checked.checkedNodes
|
||||
let ary = []
|
||||
checkNodes.forEach((item) => {
|
||||
// 一级节点 班级
|
||||
if (item.level == 0) {
|
||||
ary = [...ary, ...item.classstudentlist]
|
||||
}
|
||||
// 二级节点 班级下面的小组
|
||||
if (item.level == 1) {
|
||||
ary = [...ary, ...item.children]
|
||||
}
|
||||
// 三级节点 小组下面的学生
|
||||
if (item.level == 2) {
|
||||
ary = [...ary, item]
|
||||
}
|
||||
})
|
||||
studentList.value = uniqBy(ary, 'studentid')
|
||||
}
|
||||
// 删除学生
|
||||
const delStudent = (index) => {
|
||||
studentList.value.splice(index, 1)
|
||||
}
|
||||
|
||||
const onSubmit = (formEl) => {
|
||||
if (!formEl) return
|
||||
formEl.validate((valid) => {
|
||||
if (valid) {
|
||||
/**
|
||||
* 根据学生列表中的classId分班
|
||||
* studentList 为选中的所有学生 这些学生可能来自不同班级
|
||||
*/
|
||||
let gradeObj = groupBy(studentList.value, 'classId')
|
||||
// 处理要提交的参数
|
||||
let ary = []
|
||||
for (const value in gradeObj) {
|
||||
//这些参数 参照AIx web端 作业推送
|
||||
let obj = {
|
||||
id: 0,
|
||||
parentid: props.row.id,
|
||||
classid: value,
|
||||
classcourseid: 0,
|
||||
entpcourseid: props.entpcourseid,
|
||||
studentlist: JSON.stringify(gradeObj[value]),
|
||||
feedback: form.feedback,
|
||||
workkey: '',
|
||||
timelength: form.timelength,
|
||||
weights: 1,
|
||||
deaddate: form.deaddate,
|
||||
workdate: getCurrentDate(),
|
||||
uniquekey: props.row.uniquekey,
|
||||
entpcourseworklist: '[' + props.row.entpcourseworklist + ']',
|
||||
needMsgNotifine: 'false',
|
||||
msgkey: 'newclasswork',
|
||||
title: '作业任务',
|
||||
msgcontent: '',
|
||||
teachername: userInfo.nickName,
|
||||
unixstamp: new Date().getTime(),
|
||||
worktype: props.row.worktype
|
||||
}
|
||||
ary.push(obj)
|
||||
}
|
||||
setLoading.value = true
|
||||
saveByClassWorkArray({
|
||||
classworkarray: JSON.stringify(ary)
|
||||
})
|
||||
.then((res) => {
|
||||
setLoading.value = false
|
||||
ElMessage.success('操作成功')
|
||||
emit('on-success', res.data)
|
||||
cloneDialog(formEl)
|
||||
})
|
||||
.catch(() => {
|
||||
setLoading.value = false
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const expandedKeys = ref([])
|
||||
const checkedKeys = ref([])
|
||||
// 关闭弹窗
|
||||
const cloneDialog = (formEl) => {
|
||||
studentList.value = []
|
||||
checkedKeys.value = []
|
||||
expandedKeys.value = []
|
||||
formEl.resetFields()
|
||||
model.value = false
|
||||
}
|
||||
// 获取当前年月日
|
||||
const getCurrentDate = () => {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
let month = now.getMonth() + 1 // 月份是从0开始的,所以需要+1
|
||||
let day = now.getDate()
|
||||
if (month < 10) {
|
||||
month = '0' + month
|
||||
}
|
||||
if (day < 10) {
|
||||
day = '0' + day
|
||||
}
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 默认当前
|
||||
form.deaddate = getCurrentDate() + ' ' + '10:00:00'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.homerwork-header {
|
||||
justify-content: space-between;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
|
||||
.icon-guanbi {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.el-tag {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox) {
|
||||
transform: scale(1.3);
|
||||
}
|
||||
</style>
|
|
@ -11,6 +11,7 @@ let chapterId = null
|
|||
export const useGetHomework = async (node) => {
|
||||
/**
|
||||
* node
|
||||
* 左侧选择章节的节点数据
|
||||
*/
|
||||
if (!node) return
|
||||
curNode = node
|
||||
|
@ -26,7 +27,10 @@ export const useGetHomework = async (node) => {
|
|||
chapterId = rows[0].id
|
||||
}
|
||||
|
||||
return await getHomeWorkList()
|
||||
return new Promise(async (resolve) =>{
|
||||
const res = await getHomeWorkList()
|
||||
resolve({res,chapterId})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,514 @@
|
|||
export const isJson = (str) => {
|
||||
if (typeof str == 'string') {
|
||||
try {
|
||||
let obj = JSON.parse(str)
|
||||
if (typeof obj == 'object' && obj) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description processList 格式化试题
|
||||
* @param {*} row
|
||||
*/
|
||||
export const processList = (row) => {
|
||||
for (var i = 0; i < row.length; i++) {
|
||||
if (isJson(row[i].workanalysis)) {
|
||||
//1、先默认格式化 格式化各项内容(待优化, 后续界面显示的为format的值)
|
||||
row[i].titleFormat = row[i].title // 题目
|
||||
row[i].examdateFormat = row[i].examdate // ?考试日期 eg: 2024-07-11 14:39:27"
|
||||
row[i].workdescFormat = row[i].workdesc // 题目选项
|
||||
row[i].workanswerFormat = row[i].workanswer // 题目正确答案
|
||||
if (row[i].workanswerFormat == null || row[i].workanswerFormat == '') {
|
||||
row[i].workanswerFormat = '见试题解答内容'
|
||||
}
|
||||
|
||||
// workanalysis 解析内容(analyse:解答; method:分析; discuss:点评; )
|
||||
var jjj = JSON.parse(row[i].workanalysis)
|
||||
row[i].analyse = jjj.analyse
|
||||
row[i].method = jjj.method
|
||||
row[i].discuss = jjj.discuss
|
||||
//row[i].discusscollapse = false;
|
||||
if (row[i].examdate !== null && row[i].examdate !== undefined) {
|
||||
row[i].examdate = row[i].examdate.substring(0, 10)
|
||||
}
|
||||
|
||||
// 具体题型数据结构处理
|
||||
if (row[i].worktype == '复合题') {
|
||||
// 旧类型
|
||||
if (row[i].title.indexOf('!@#$%') !== -1) {
|
||||
// 1.选项解析替换
|
||||
const options = JSON.parse(row[i].workdesc)
|
||||
// 题目(背景材料+复合题目)
|
||||
const bjTitle = row[i].title.split('!@#$%')[0]
|
||||
const tmTitles = row[i].title.split('!@#$%').filter((it, ix) => ix > 0)
|
||||
// console.log(bjTitle,'背景标题');
|
||||
// console.log(tmTitles,'复合题目');
|
||||
let titls = []
|
||||
options.forEach((element, index1) => {
|
||||
const workDescArr = element.split('#&')
|
||||
let tmp = ''
|
||||
let j = 0
|
||||
for (; j < workDescArr.length; j++) {
|
||||
if (j % 2 == 0) {
|
||||
tmp += `<div style='width:80%;display:flex;'>`
|
||||
}
|
||||
const char = String.fromCharCode(65 + j)
|
||||
tmp += `<div style='display:flex;margin-left:2%;width:35%;overflow:hidden;text-overflow:ellipsis;font-size:0.9em;'>${char}.${workDescArr[j]}</div>`
|
||||
if (j % 2 == 1) {
|
||||
tmp += '</div>'
|
||||
}
|
||||
}
|
||||
// j此刻已自增1, 故当选项为单数时, 需要补充结束标签
|
||||
if (j % 2 == 1) {
|
||||
tmp += '</div>'
|
||||
}
|
||||
|
||||
// workDescArr为 [''] 表示为 判断题或者填空题,这里不需要选项
|
||||
if (workDescArr[0] != '') {
|
||||
titls.splice(index1, 1, tmp)
|
||||
} else {
|
||||
titls.splice(index1, 1, '')
|
||||
}
|
||||
})
|
||||
const s = []
|
||||
tmTitles.map((it, ix) => {
|
||||
s.push(it)
|
||||
titls.map((it2, ix2) => {
|
||||
if (ix == ix2) {
|
||||
s.push(it2)
|
||||
}
|
||||
})
|
||||
})
|
||||
// console.log(s,'?????????????????')
|
||||
|
||||
row[i].titleFormat = bjTitle + s.join('')
|
||||
row[i].workdescFormat = ''
|
||||
|
||||
//2.答案 - 数字转为ABCD
|
||||
const answerArr = JSON.parse(row[i].workanswer)
|
||||
let indexLabel = 1
|
||||
let arr = []
|
||||
answerArr.forEach((item) => {
|
||||
const arrTmp = item.answer.split('#&')
|
||||
let value = `(${indexLabel})`
|
||||
arrTmp.forEach((element, i) => {
|
||||
if (item.type == '单选题' || item.type == '多选题') {
|
||||
value += `${String.fromCharCode(65 + Number(element))}`
|
||||
}
|
||||
if (item.type == '判断题' || item.type == '填空题') {
|
||||
// 去除下 html标签
|
||||
value += `${element.replace(/<[^>]+>/g, '')}` + (i == arrTmp.length - 1 ? '' : '、')
|
||||
}
|
||||
if (item.type == '主观题') {
|
||||
if (element) {
|
||||
console.log(element, 'element')
|
||||
value += item.answer
|
||||
} else {
|
||||
value += '答案不唯一,请参考分析解答点评!'
|
||||
}
|
||||
}
|
||||
})
|
||||
arr.push(value)
|
||||
indexLabel++
|
||||
})
|
||||
const answer = arr.join('<br />')
|
||||
|
||||
row[i].workanswerFormat = answer
|
||||
} else {
|
||||
// 处理[题干显示] - 不再需要处理
|
||||
// row[i].titleFormat = row[i].title; // 仅占位提示
|
||||
|
||||
/**
|
||||
* 处理[选项显示] - 特殊结构
|
||||
* [
|
||||
* {type: '单选题', title: '题目1', options: ['ABC123','ABC123']},
|
||||
* {type: '多选题', title: '题目1', options: ['ABC123','ABC123']},
|
||||
* {type: '填空题', title: '题目1', options: []},
|
||||
* {type: '判断题', title: '题目1', options: []},
|
||||
* {type: '主观题', title: '题目1', options: []},
|
||||
* ]
|
||||
*/
|
||||
let workDescArr = JSON.parse(row[i].workdesc)
|
||||
let workDescHtml = `<div style='width:80%;display:flex;>`
|
||||
workDescArr.map((item, index) => {
|
||||
if (item.type == '单选题' || item.type == '多选题') {
|
||||
workDescHtml += `<div style='width:80%;display:flex;'>${index + 1}. ${item.title}</div>`
|
||||
let tmp = ''
|
||||
let j = 0
|
||||
let optionsArr = item.options
|
||||
for (; j < optionsArr.length; j++) {
|
||||
if (j % 2 == 0) {
|
||||
tmp += `<div style='width:80%;display:flex;'>`
|
||||
}
|
||||
const char = String.fromCharCode(65 + j)
|
||||
tmp += `<div style='display:flex;margin-left: 2%; width: 36%'>${char}.${optionsArr[j]}</div>`
|
||||
if (j % 2 == 1) {
|
||||
tmp += '</div>'
|
||||
}
|
||||
}
|
||||
// j此刻已自增1, 故当选项为单数时, 需要补充结束标签
|
||||
if (j % 2 == 1) {
|
||||
tmp += '</div>'
|
||||
}
|
||||
|
||||
workDescHtml += tmp
|
||||
} else if (item.type == '填空题' || item.type == '判断题' || item.type == '主观题') {
|
||||
workDescHtml += `<div style='width:80%;display:flex;'>${index + 1}. ${item.title}</div>`
|
||||
}
|
||||
})
|
||||
workDescHtml += '</div>'
|
||||
row[i].workdescFormat = workDescHtml
|
||||
|
||||
/**
|
||||
* 处理[答案显示] - 特殊结构
|
||||
* [
|
||||
* {type: '单选题', answer: ['0']},
|
||||
* {type: '多选题', answer: ['0','1']},
|
||||
* {type: '填空题', answer: ['填空1','填空2']},
|
||||
* {type: '判断题', answer: ['0'/'1']},
|
||||
* {type: '主观题', answer: [xxxx]},
|
||||
* ]
|
||||
*/
|
||||
let workAnswerArr = JSON.parse(row[i].workanswer)
|
||||
let workAnswerHtml = ``
|
||||
workAnswerArr.map((item, index) => {
|
||||
const answerArr = item.answer //JSON.parse(item.answer);
|
||||
if (item.type == '单选题' || item.type == '多选题') {
|
||||
const answer = answerArr
|
||||
.map((item) => {
|
||||
return String.fromCharCode(65 + Number(item))
|
||||
})
|
||||
.join('')
|
||||
workAnswerHtml += `<div style='display:flex;'>${index + 1}. ${answer}</div>`
|
||||
} else if (item.type == '填空题') {
|
||||
const answer = answerArr.join('、')
|
||||
workAnswerHtml += `<div style='display:flex;'>${index + 1}. ${answer}</div>`
|
||||
} else if (item.type == '判断题') {
|
||||
const answer = answerArr
|
||||
.map((item) => {
|
||||
return item === '1' ? '正确' : '错误'
|
||||
})
|
||||
.join('、')
|
||||
workAnswerHtml += `<div style='display:flex;'>${index + 1}. ${answer}</div>`
|
||||
} else if (item.type == '主观题') {
|
||||
// 复合题里面的主观题只有一个答案,或没填
|
||||
const answer = answerArr.join('、')
|
||||
if (answerArr[0]) {
|
||||
workAnswerHtml += `<div style='display:flex;'>${index + 1}. ${answer}</div>`
|
||||
} else {
|
||||
workAnswerHtml += `<div style='display:flex;'>${index + 1}. ${answer}答案不唯一,请参考分析解答点评!</div>`
|
||||
}
|
||||
}
|
||||
})
|
||||
row[i].workanswerFormat = workAnswerHtml
|
||||
}
|
||||
} else if (
|
||||
row[i].worktype == '主观题' ||
|
||||
(row[i].worktype !== '单选题' &&
|
||||
row[i].worktype !== '多选题' &&
|
||||
row[i].worktype !== '填空题' &&
|
||||
row[i].worktype !== '判断题')
|
||||
) {
|
||||
// 处理[选项显示] - 主观题中无选项, 故置空
|
||||
row[i].workdescFormat = ''
|
||||
row[i].workanswerFormat = ''
|
||||
// 答案处理- eg: "\"不唯一的答案,参考\""
|
||||
if (row[i].workanswer && row[i].workanswer != '') {
|
||||
row[i].workanswerFormat = JSON.parse(row[i].workanswer)
|
||||
}
|
||||
} else {
|
||||
// 单选题|多选题|填空题|判断题|主观题?(待确认是否归在这里)
|
||||
// 通用选项结构 ['ABC123','ABC123'] | ['ABC123','ABC123'] | [](填空题无选项) | [](判断题无选项)
|
||||
let workDescArr = []
|
||||
if (
|
||||
row[i].workdesc.charAt(0) === '[' &&
|
||||
row[i].workdesc.charAt(row[i].workdesc.length - 1) === ']'
|
||||
) {
|
||||
//123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符
|
||||
workDescArr = JSON.parse(row[i].workdesc)
|
||||
} else if (row[i].workdesc.indexOf('#&') !== -1) {
|
||||
workDescArr = row[i].workdesc.split('#&')
|
||||
} else if (row[i].workdesc.indexOf(',') !== -1) {
|
||||
workDescArr = row[i].workdesc.split(',')
|
||||
} else {
|
||||
// 单字符串直接添加至空数组(待考虑确认)
|
||||
workDescArr.push(row[i].workdesc)
|
||||
}
|
||||
|
||||
// 单选题|多选题|填空题|判断题|主观题?(待确认是否归在这里)
|
||||
// 通用答案结构 ['0'] | ['0','1'] | ['填空1','填空2'] | ['0'/'1']
|
||||
let workAnswerArr = []
|
||||
if (
|
||||
row[i].workanswer.charAt(0) === '[' &&
|
||||
row[i].workanswer.charAt(row[i].workanswer.length - 1) === ']'
|
||||
) {
|
||||
// 123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符
|
||||
workAnswerArr = JSON.parse(row[i].workanswer)
|
||||
} else if (row[i].workanswer.indexOf('#&') !== -1) {
|
||||
workAnswerArr = row[i].workanswer.split('#&')
|
||||
} else if (row[i].workanswer.indexOf(',') !== -1) {
|
||||
workAnswerArr = row[i].workanswer.split(',')
|
||||
} else {
|
||||
// 单字符串直接添加至空数组(待考虑确认)
|
||||
workAnswerArr.push(row[i].workanswer)
|
||||
}
|
||||
|
||||
// 具体题型处理
|
||||
if (row[i].worktype == '单选题' || row[i].worktype == '多选题') {
|
||||
// 处理[选项显示] - 拼接ABCD首序号
|
||||
let tmp = ''
|
||||
let j = 0
|
||||
for (; j < workDescArr.length; j++) {
|
||||
if (j % 2 == 0) {
|
||||
tmp += `<div style='width:80%;display:flex;'>`
|
||||
}
|
||||
const char = String.fromCharCode(65 + j)
|
||||
tmp += `<div style='display:flex;margin-left: 2%; width: 36%'>${char}.${workDescArr[j]}</div>`
|
||||
if (j % 2 == 1) {
|
||||
tmp += '</div>'
|
||||
}
|
||||
}
|
||||
if (j % 2 == 0) {
|
||||
tmp += '</div>'
|
||||
}
|
||||
row[i].workdescFormat = tmp
|
||||
|
||||
// 处理[答案显示] - 转换ABCD
|
||||
let arr2Char = workAnswerArr
|
||||
.map((item) => {
|
||||
return String.fromCharCode(65 + Number(item))
|
||||
})
|
||||
.join('')
|
||||
row[i].workanswerFormat = arr2Char
|
||||
} else if (row[i].worktype == '填空题') {
|
||||
// 处理[选项显示] - 填空题中无选项, 故置空
|
||||
row[i].workdescFormat = ''
|
||||
|
||||
// 处理[答案显示] - 逗号连接
|
||||
row[i].workanswerFormat = workAnswerArr.join('、')
|
||||
} else if (row[i].worktype == '判断题') {
|
||||
// 处理[选项显示] - 判断题中无选项, 故置空
|
||||
row[i].workdescFormat = ''
|
||||
|
||||
// 处理[答案显示] - 1-正常 0-错误
|
||||
const answer = workAnswerArr
|
||||
.map((item) => {
|
||||
return item === '1' ? '正确' : '错误'
|
||||
})
|
||||
.join('、')
|
||||
row[i].workanswerFormat = answer
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//2、处理单选题
|
||||
if(row[i].worktype == '单选题' || row[i].worktype == '多选题' ){
|
||||
//1.选项前增加ABCD workdesc: "①②#&①③#&②④#&③④" || "<div>为了活着</div>#&<div>为了填报肚子</div>#&<div>为了吃饭而吃饭</div>"
|
||||
let workDescArr = [];
|
||||
if(row[i].workdesc.indexOf('[')!==-1 && row[i].workdesc.indexOf(']')!==-1) {
|
||||
//123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符
|
||||
workDescArr = JSON.parse(row[i].workdesc);
|
||||
}
|
||||
else if(row[i].workdesc.indexOf('#&')) {
|
||||
workDescArr = row[i].workdesc.split('#&');
|
||||
}
|
||||
else if(row[i].workdesc.indexOf(',')){
|
||||
workDescArr = row[i].workdesc.split(',');
|
||||
}
|
||||
else {
|
||||
// 待考虑
|
||||
workDescArr.push(item.workdesc)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//2.答案 - 数字转为ABCD
|
||||
if(row[i].worktype == '单选题') {
|
||||
const str2Char = String.fromCharCode(65+Number(row[i].workanswer));
|
||||
row[i].workanswerFormat = str2Char;
|
||||
} else if (row[i].worktype == '多选题') {
|
||||
const answerArr = row[i].workanswer.split('#&');
|
||||
let arr2Char = '';
|
||||
for(let k=0; k<answerArr.length; k++){
|
||||
arr2Char += String.fromCharCode(65+Number(answerArr[k]));
|
||||
}
|
||||
row[i].workanswerFormat = arr2Char;
|
||||
}
|
||||
}
|
||||
else if(row[i].worktype == '填空题') {
|
||||
// console.log(row[i].workanswer.replace(/<[^>]*>/g, "").split('#&'),'????')
|
||||
// 填空题答案
|
||||
row[i].workanswerFormat = row[i].workanswer.replace(/#&/g,", ");
|
||||
// 填空选项不需要展示,
|
||||
row[i].workdescFormat = '';
|
||||
}
|
||||
else if(row[i].worktype == '判断题'){
|
||||
// console.log(row[i].workanswer.replace(/<[^>]*>/g, "").split('#&'),'????')
|
||||
// 判断题答案
|
||||
row[i].workanswerFormat = row[i].workanswer.replace(/#&/g,", ");
|
||||
// 判断选项不需要展示,
|
||||
row[i].workdescFormat = '';
|
||||
}
|
||||
else if(row[i].worktype == '复合题') {
|
||||
// 1.选项解析替换
|
||||
const options = JSON.parse(row[i].workdesc);
|
||||
// 题目(背景材料+复合题目)
|
||||
const bjTitle = row[i].title.split('!@#$%')[0];
|
||||
const tmTitles = row[i].title.split('!@#$%').filter((it,ix)=>ix>0);
|
||||
// console.log(bjTitle,'背景标题');
|
||||
// console.log(tmTitles,'复合题目');
|
||||
let titls = [];
|
||||
options.forEach((element,index1) => {
|
||||
const workDescArr = element.split('#&');
|
||||
let tmp = '';
|
||||
let j=0;
|
||||
for(; j<jsonArr.length; j++){
|
||||
if(j%2 == 0){
|
||||
tmp += `<div style='width:80%;display:flex;'>`;
|
||||
}
|
||||
const char = String.fromCharCode(65+j);
|
||||
tmp += `<div style='display:flex;margin-left: 2%; width: 36%'>${char}.${jsonArr[j]}</div>`;
|
||||
if(j%2 == 1){
|
||||
tmp += '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if(j%2== 0){
|
||||
tmp += '</div>';
|
||||
}
|
||||
workdesc = tmp;
|
||||
}
|
||||
|
||||
row[i].workdescFormat = workdesc; // 题目选项
|
||||
|
||||
|
||||
// 答案处理
|
||||
let workanswer = '';
|
||||
if(row[i].workanswer && row[i].workanswer != '') {
|
||||
// 因答案内容存在多种格式: 1.["123","1234"] 2.123#&1234 3.123
|
||||
if(row[i].workanswer.indexOf('[')!==-1 && row[i].workanswer.indexOf(']')!==-1) {
|
||||
//123会直接被转换, 且不是数组对象, 故手动判断是否有[和]两个字符
|
||||
let json = JSON.parse(row[i].workanswer);
|
||||
// 单选、多选 需要 数字转为ABCD
|
||||
if(row[i].worktype == '单选题') {
|
||||
const str2Char = String.fromCharCode(65+Number(json[0]));
|
||||
workanswer = str2Char;
|
||||
} else if (row[i].worktype == '多选题') {
|
||||
// const answerArr = row[i].workanswer.split('#&');
|
||||
let arr2Char = '';
|
||||
for(let k=0; k<json.length; k++){
|
||||
arr2Char += String.fromCharCode(65+Number(json[k]));
|
||||
}
|
||||
workanswer = arr2Char;
|
||||
} else if(row[i].worktype == '主观题' ) {
|
||||
let arr2Char = '';
|
||||
for(let k=0; k<json.length; k++){
|
||||
const itemArr = json[k];
|
||||
arr2Char += '('+ (parseInt(k) + 1) +')'+ itemArr.join('、')+ '<br />';
|
||||
}
|
||||
workanswer = arr2Char;
|
||||
row[i].titleFormat = row[i].titleFormat.replace(/!@#\$%/g, '');
|
||||
} else {
|
||||
workanswer = json.join('、');
|
||||
}
|
||||
} else if(row[i].workanswer.indexOf('#&')) {
|
||||
// 意味着多个答案或者填空内容
|
||||
let workanswerList = row[i].workanswer.split('#&');
|
||||
if(row[i].worktype == '多选题') {
|
||||
// 数字转为ABCD
|
||||
let arr2Char = '';
|
||||
for(let k=0; k<workanswerList.length; k++){
|
||||
arr2Char += String.fromCharCode(65+Number(workanswerList[k]));
|
||||
}
|
||||
workanswer = arr2Char;
|
||||
}else{
|
||||
workanswer = workanswerList.join('、');
|
||||
}
|
||||
} else if(row[i].workanswer.indexOf(',')){
|
||||
// 意味这同样多个答案或者填空内容
|
||||
let workanswerList = row[i].workanswer.split(',');
|
||||
if(row[i].worktype == '多选题') {
|
||||
// 数字转为ABCD
|
||||
let arr2Char = '';
|
||||
for(let k=0; k<workanswerList.length; k++){
|
||||
arr2Char += String.fromCharCode(65+Number(workanswerList[k]));
|
||||
}
|
||||
workanswer = arr2Char;
|
||||
}else{
|
||||
workanswer = workanswerList.join('、');
|
||||
}
|
||||
} else {
|
||||
// 待考虑
|
||||
workanswer = row[i].workanswer;
|
||||
}
|
||||
}
|
||||
|
||||
row[i].workanswerFormat = workanswer; // 题目正确答案
|
||||
|
||||
|
||||
//2.答案 - 数字转为ABCD
|
||||
const answerArr = JSON.parse(row[i].workanswer);
|
||||
let indexLabel = 1;
|
||||
let arr = [];
|
||||
answerArr.forEach(item => {
|
||||
const arrTmp = item.answer.split('#&');
|
||||
let value = `(${indexLabel})`;
|
||||
arrTmp.forEach((element,i) => {
|
||||
if(item.type == '单选题' || item.type == '多选题'){
|
||||
value += `${String.fromCharCode(65+Number(element))}`;
|
||||
}
|
||||
if(item.type == '判断题' || item.type == '填空题'){
|
||||
// 去除下 html标签
|
||||
value += `${element.replace(/<[^>]+>/g, '')}`+ (i==arrTmp.length-1?'':'、');
|
||||
}
|
||||
})
|
||||
arr.push(value);
|
||||
indexLabel++;
|
||||
})
|
||||
const answer = arr.join('<br />');
|
||||
|
||||
row[i].workanswerFormat = answer;
|
||||
}
|
||||
else if(row[i].worktype == '主观题') {
|
||||
// 1.选项解析替换---主观题没选项
|
||||
// 题目(背景材料+主观题目)
|
||||
const bjTitle = row[i].title.split('!@#$%')[0];
|
||||
const tmTitles = row[i].title.split('!@#$%').filter((it,ix)=>ix>0);
|
||||
// console.log(bjTitle,'背景标题');
|
||||
// console.log(tmTitles,'主观题目');
|
||||
let titls = [];
|
||||
const s = [];
|
||||
tmTitles.map((it,ix)=>{
|
||||
s.push(it);
|
||||
})
|
||||
// console.log(s,'?????????????????')
|
||||
|
||||
row[i].titleFormat = bjTitle + s.join('');
|
||||
// 填空选项不需要展示,
|
||||
row[i].workdescFormat = '';
|
||||
|
||||
//2.答案
|
||||
// 填空题答案
|
||||
const workanswerList = JSON.parse(row[i].workanswer);
|
||||
let tmp='';
|
||||
workanswerList&&workanswerList.map((item,index)=>{
|
||||
tmp += '<div>'+(index+1)+'.'+item.replace(/#&/g, ',')+'</div>';
|
||||
})
|
||||
row[i].workanswerFormat = tmp;
|
||||
|
||||
}
|
||||
else {
|
||||
//处理答案
|
||||
row[i].workanswerFormat = '见试题解答内容';
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
class="flex"
|
||||
:style="{'color' : item.color}"
|
||||
:class="currentRoute === item.url ? 'active-li' : ''"
|
||||
@click="handleOutLink(item.url,item.type)"
|
||||
@click="handleOutLink(item.url,item.type, item.name)"
|
||||
>
|
||||
<i :class="item.img"></i>
|
||||
<span class="text">{{ item.name }}</span>
|
||||
|
@ -29,7 +29,7 @@
|
|||
@command="handleCommand"
|
||||
>
|
||||
<div class="avatar-wrapper">
|
||||
<img :src="userStore.user.avatar" class="user-avatar" style="float: left" />
|
||||
<img :src="dev_api + userStore.user.avatar" class="user-avatar" style="float: left" />
|
||||
<div style="margin-top: 18px; font-size: 0.8em">{{ userStore.user.nickName }}</div>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
|
@ -37,6 +37,7 @@
|
|||
<el-dropdown-item @click="changePage('/profile')">个人中心</el-dropdown-item>
|
||||
<el-dropdown-item @click="changePage('/classReserv')">课程预约</el-dropdown-item>
|
||||
<el-dropdown-item @click="changePage('/class')">班级中心</el-dropdown-item>
|
||||
<el-dropdown-item @click="changePage('/classTask')">作业批改</el-dropdown-item>
|
||||
<el-dropdown-item divided command="logout">
|
||||
<span>退出登录</span>
|
||||
</el-dropdown-item>
|
||||
|
@ -57,13 +58,15 @@ import WindowTools from '@/components/window-tools/index.vue'
|
|||
import useUserStore from '@/store/modules/user'
|
||||
import routerStore from '@/store/modules/route'
|
||||
import outLink from '@/utils/linkConfig'
|
||||
|
||||
const routeHeader = routerStore()
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const currentRoute = ref('')
|
||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||
|
||||
const handleOutLink = (path, type) => {
|
||||
const handleOutLink = (path, type, name) => {
|
||||
if (!path) return
|
||||
if (type === 'hash') {
|
||||
router.push(path)
|
||||
|
@ -72,6 +75,11 @@ const handleOutLink = (path, type) => {
|
|||
let configObj = outLink().getBaseData()
|
||||
let fullPath = configObj.fullPath + path
|
||||
fullPath = fullPath.replaceAll('//', '/')
|
||||
const { levelFirstId, levelSecondId } = JSON.parse(localStorage.getItem('unitId'))
|
||||
let unitId = levelSecondId ? levelSecondId :levelFirstId
|
||||
if(name == '教材分析' || name == '高考研究'){
|
||||
fullPath += `?unitId=${unitId}`
|
||||
}
|
||||
// 通知主进程
|
||||
ipcRenderer.send('openWindow', {
|
||||
key: path,
|
||||
|
|
|
@ -12,10 +12,14 @@ import 'virtual:windi.css'
|
|||
import { store } from '@/store'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import log from 'electron-log/renderer' // 渲染进程日志-文件记录
|
||||
|
||||
if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印到日志文件
|
||||
Object.assign(console, log.functions) // 渲染进程日志-控制台替换
|
||||
}
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
|
||||
app.use(router)
|
||||
.use(store)
|
||||
.use(ElementPlus, { locale: zhLocale }).mount('#app')
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,420 @@
|
|||
/**
|
||||
* @description im 事件监听
|
||||
* @author zdg
|
||||
* @date 2023-07-07
|
||||
*/
|
||||
// @ts-ignore
|
||||
const API = window?.api || {}
|
||||
const timRenderInstance = API?.getTimRender?.() || {}
|
||||
|
||||
// im 事件监听
|
||||
export class IMListeners {
|
||||
// 初始化监听
|
||||
static initListeners(callback) {
|
||||
/**
|
||||
* 注销消息监听事件
|
||||
*/
|
||||
timRenderInstance.TIMRemoveRecvNewMsgCallback()
|
||||
/**
|
||||
* @brief 增加接收新消息回调
|
||||
* @param cb 新消息回调函数,请参考[TIMRecvNewMsgCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 如果用户是登录状态,ImSDK收到新消息会通过此接口设置的回调抛出,另外需要注意,抛出的消息不一定是未读的消息,
|
||||
* 只是本地曾经没有过的消息(例如在另外一个终端已读,拉取最近联系人消息时可以获取会话最后一条消息,如果本地没有,会通过此方法抛出)。
|
||||
* 在用户登录之后,ImSDK会拉取离线消息,为了不漏掉消息通知,需要在登录之前注册新消息通知。
|
||||
*/
|
||||
timRenderInstance.TIMAddRecvNewMsgCallback({
|
||||
callback:(args)=>{
|
||||
callback({
|
||||
type: 'TIMAddRecvNewMsgCallback',
|
||||
data: JSON.parse(args[0])
|
||||
})
|
||||
},
|
||||
user_data: "test"
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.3 设置消息已读回执回调
|
||||
* @param cb 消息已读回执回调,请参考[TIMMsgReadedReceiptCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 发送方发送消息,接收方调用接口[TIMMsgReportReaded]()上报该消息已读,发送方ImSDK会通过此接口设置的回调抛出。
|
||||
*/
|
||||
timRenderInstance.TIMSetMsgReadedReceiptCallback({
|
||||
callback:(args)=>{
|
||||
callback({
|
||||
type: 'TIMSetMsgReadedReceiptCallback',
|
||||
data: JSON.parse(args[0])
|
||||
})
|
||||
},
|
||||
user_data: "test"
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.4 设置接收的消息被撤回回调
|
||||
* @param cb 消息撤回通知回调,请参考[TIMMsgRevokeCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 发送方发送消息,接收方收到消息。此时发送方调用接口[TIMMsgRevoke]()撤回该消息,接收方的ImSDK会通过此接口设置的回调抛出。
|
||||
*/
|
||||
timRenderInstance.TIMSetMsgRevokeCallback({
|
||||
callback:(args)=>{
|
||||
callback({
|
||||
type: 'TIMSetMsgRevokeCallback',
|
||||
data: JSON.parse(args[0])
|
||||
});
|
||||
},
|
||||
user_data: "test"
|
||||
})
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.5 设置消息内元素相关文件上传进度回调
|
||||
* @param cb 文件上传进度回调,请参考[TIMMsgElemUploadProgressCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 设置消息元素上传进度回调。当消息内包含图片、声音、文件、视频元素时,ImSDK会上传这些文件,并触发此接口设置的回调,用户可以根据回调感知上传的进度
|
||||
*/
|
||||
timRenderInstance.TIMSetMsgElemUploadProgressCallback({
|
||||
callback:(args)=>{
|
||||
try{
|
||||
const [message, index, cur_size, total_size, user_data] = JSON.parse(args)
|
||||
callback({
|
||||
type: 'TIMSetMsgElemUploadProgressCallback',
|
||||
data: {
|
||||
message: JSON.parse(message),
|
||||
index,
|
||||
cur_size,
|
||||
total_size,
|
||||
user_data
|
||||
}
|
||||
})
|
||||
}catch(err){
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
user_data: "test"
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 1.6 设置群组系统消息回调
|
||||
* @param cb 群消息回调,请参考[TIMGroupTipsEventCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 群组系统消息事件包括 加入群、退出群、踢出群、设置管理员、取消管理员、群资料变更、群成员资料变更。此消息是针对所有群组成员下发的
|
||||
*/
|
||||
timRenderInstance.TIMSetGroupTipsEventCallback({
|
||||
callback:(args)=>{
|
||||
callback({
|
||||
type: 'TIMSetGroupTipsEventCallback',
|
||||
data: JSON.parse(args[0])
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.7 设置群组属性变更回调
|
||||
* @param cb 群组属性变更回调,请参考[TIMGroupAttributeChangedCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 某个已加入的群的属性被修改了,会返回所在群组的所有属性(该群所有的成员都能收到)
|
||||
*/
|
||||
timRenderInstance.TIMSetGroupAttributeChangedCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetGroupAttributeChangedCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.8 设置会话事件回调
|
||||
* @param cb 会话事件回调,请参考[TIMConvEventCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* > 会话事件包括:
|
||||
* >> 会话新增
|
||||
* >> 会话删除
|
||||
* >> 会话更新。
|
||||
* >> 会话开始
|
||||
* >> 会话结束
|
||||
* > 任何产生一个新会话的操作都会触发会话新增事件,例如调用接口[TIMConvCreate]()创建会话,接收到未知会话的第一条消息等。
|
||||
* 任何已有会话变化的操作都会触发会话更新事件,例如收到会话新消息,消息撤回,已读上报等。
|
||||
* 调用接口[TIMConvDelete]()删除会话成功时会触发会话删除事件。
|
||||
*/
|
||||
timRenderInstance.TIMSetConvEventCallback({
|
||||
callback:(args)=>{
|
||||
callback({
|
||||
type: 'TIMSetConvEventCallback',
|
||||
data: {
|
||||
type:args[0],
|
||||
data:args[1]!=="" ? JSON.parse(args[1]) : []
|
||||
}
|
||||
})
|
||||
},
|
||||
user_data:"TIMSetConvEventCallback"
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 1.9 设置会话未读消息总数变更的回调
|
||||
* @param cb 会话未读消息总数变更的回调,请参考[TIMConvTotalUnreadMessageCountChangedCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
*/
|
||||
timRenderInstance.TIMSetConvTotalUnreadMessageCountChangedCallback({
|
||||
callback:(args)=>{
|
||||
callback({
|
||||
type: 'TIMSetConvTotalUnreadMessageCountChangedCallback',
|
||||
data: args[0]
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.10 设置网络连接状态监听回调
|
||||
* @param cb 连接事件回调,请参考[TIMNetworkStatusListenerCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* > 当调用接口 [TIMInit]() 时,ImSDK会去连接云后台。此接口设置的回调用于监听网络连接的状态。
|
||||
* > 网络连接状态包含四个:正在连接、连接失败、连接成功、已连接。这里的网络事件不表示用户本地网络状态,仅指明ImSDK是否与即时通信IM云Server连接状态。
|
||||
* > 可选设置,如果要用户感知是否已经连接服务器,需要设置此回调,用于通知调用者跟通讯后台链接的连接和断开事件,另外,如果断开网络,等网络恢复后会自动重连,自动拉取消息通知用户,用户无需关心网络状态,仅作通知之用
|
||||
* > 只要用户处于登录状态,ImSDK内部会进行断网重连,用户无需关心。
|
||||
*/
|
||||
timRenderInstance.TIMSetNetworkStatusListenerCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetNetworkStatusListenerCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 1.11 设置被踢下线通知回调
|
||||
* @param cb 踢下线回调,请参考[TIMKickedOfflineCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* > 用户如果在其他终端登录,会被踢下线,这时会收到用户被踢下线的通知,出现这种情况常规的做法是提示用户进行操作(退出,或者再次把对方踢下线)。
|
||||
* > 用户如果在离线状态下被踢,下次登录将会失败,可以给用户一个非常强的提醒(登录错误码ERR_IMSDK_KICKED_BY_OTHERS:6208),开发者也可以选择忽略这次错误,再次登录即可。
|
||||
* > 用户在线情况下的互踢情况:
|
||||
* + 用户在设备1登录,保持在线状态下,该用户又在设备2登录,这时用户会在设备1上强制下线,收到 TIMKickedOfflineCallback 回调。
|
||||
* 用户在设备1上收到回调后,提示用户,可继续调用login上线,强制设备2下线。这里是在线情况下互踢过程。
|
||||
* > 用户离线状态互踢:
|
||||
* + 用户在设备1登录,没有进行logout情况下进程退出。该用户在设备2登录,此时由于用户不在线,无法感知此事件,
|
||||
* 为了显式提醒用户,避免无感知的互踢,用户在设备1重新登录时,会返回(ERR_IMSDK_KICKED_BY_OTHERS:6208)错误码,表明之前被踢,是否需要把对方踢下线。
|
||||
* 如果需要,则再次调用login强制上线,设备2的登录的实例将会收到 TIMKickedOfflineCallback 回调。
|
||||
*/
|
||||
timRenderInstance.TIMSetKickedOfflineCallback({
|
||||
callback: (...args) => {
|
||||
callback({
|
||||
type: 'TIMSetKickedOfflineCallback',
|
||||
data: args
|
||||
});
|
||||
},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.12 设置票据过期回调
|
||||
* @param cb 票据过期回调,请参考[TIMUserSigExpiredCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 用户票据,可能会存在过期的情况,如果用户票据过期,此接口设置的回调会调用。
|
||||
* [TIMLogin]()也将会返回70001错误码。开发者可根据错误码或者票据过期回调进行票据更换
|
||||
*/
|
||||
timRenderInstance.TIMSetUserSigExpiredCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetUserSigExpiredCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.13 设置添加好友的回调
|
||||
* @param cb 添加好友回调,请参考[TIMOnAddFriendCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 此回调为了多终端同步。例如A设备、B设备都登录了同一帐号的ImSDK,A设备添加了好友,B设备ImSDK会收到添加好友的推送,ImSDK通过此回调告知开发者。
|
||||
*/
|
||||
timRenderInstance.TIMSetOnAddFriendCallback({
|
||||
callback: (...args) => {
|
||||
console.log('=====添加好友=====', args)
|
||||
callback({ type: 'TIMSetOnAddFriendCallback', data: args })
|
||||
},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.14 设置删除好友的回调
|
||||
* @param cb 删除好友回调,请参考[TIMOnDeleteFriendCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 此回调为了多终端同步。例如A设备、B设备都登录了同一帐号的ImSDK,A设备删除了好友,B设备ImSDK会收到删除好友的推送,ImSDK通过此回调告知开发者。
|
||||
*/
|
||||
timRenderInstance.TIMSetOnDeleteFriendCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetOnDeleteFriendCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 1.15 设置更新好友资料的回调
|
||||
* @param cb 更新好友资料回调,请参考[TIMUpdateFriendProfileCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 此回调为了多终端同步。例如A设备、B设备都登录了同一帐号的ImSDK,A设备更新了好友资料,B设备ImSDK会收到更新好友资料的推送,ImSDK通过此回调告知开发者。
|
||||
*/
|
||||
timRenderInstance.TIMSetUpdateFriendProfileCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetUpdateFriendProfileCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.16 设置好友添加请求的回调
|
||||
* @param cb 好友添加请求回调,请参考[TIMFriendAddRequestCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 当前登入用户设置添加好友需要确认时,如果有用户请求加当前登入用户为好友,会收到好友添加请求的回调,ImSDK通过此回调告知开发者。如果多终端登入同一帐号,每个终端都会收到这个回调。
|
||||
*/
|
||||
timRenderInstance.TIMSetFriendAddRequestCallback({
|
||||
callback: (...args) => {
|
||||
console.log('=====添加好友请求=====', JSON.parse(args[0][0]));
|
||||
callback({
|
||||
type: 'TIMSetFriendAddRequestCallback',
|
||||
data: JSON.parse(args[0][0])
|
||||
})
|
||||
},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.17 设置好友申请删除的回调
|
||||
* @param cb 好友申请删除回调,请参考[TIMFriendApplicationListDeletedCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 1. 主动删除好友申请
|
||||
* 2. 拒绝好友申请
|
||||
* 3. 同意好友申请
|
||||
* 4. 申请加别人好友被拒绝
|
||||
*/
|
||||
timRenderInstance.TIMSetFriendApplicationListDeletedCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetFriendApplicationListDeletedCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 1.18 设置好友申请已读的回调
|
||||
* @param cb 好友申请已读回调,请参考[TIMFriendApplicationListReadCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* 如果调用 setFriendApplicationRead 设置好友申请列表已读,会收到这个回调(主要用于多端同步)
|
||||
*/
|
||||
|
||||
timRenderInstance.TIMSetFriendApplicationListReadCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetFriendApplicationListReadCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.19 设置黑名单新增的回调
|
||||
* @param cb 黑名单新增的回调,请参考[TIMFriendBlackListAddedCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
*/
|
||||
timRenderInstance.TIMSetFriendBlackListAddedCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetFriendBlackListAddedCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 1.20 设置黑名单删除的回调
|
||||
* @param cb 黑名单删除的回调,请参考[TIMFriendBlackListDeletedCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
*/
|
||||
timRenderInstance.TIMSetFriendBlackListDeletedCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetFriendBlackListDeletedCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @brief 1.22 设置消息在云端被修改后回传回来的消息更新通知回调
|
||||
* @param cb 消息更新回调,请参考[TIMMsgUpdateCallback](TIMCloudCallback.h)
|
||||
* @param user_data 用户自定义数据,ImSDK只负责传回给回调函数cb,不做任何处理
|
||||
*
|
||||
* @note
|
||||
* > 当您发送的消息在服务端被修改后,ImSDK会通过该回调通知给您
|
||||
* > 您可以在您自己的服务器上拦截所有即时通信IM消息 [发单聊消息之前回调](https://cloud.tencent.com/document/product/269/1632)
|
||||
* > 设置成功之后,即时通信IM服务器会将您的用户发送的每条消息都同步地通知给您的业务服务器。
|
||||
* > 您的业务服务器可以对该条消息进行修改(例如过滤敏感词),如果您的服务器对消息进行了修改,ImSDK就会通过此回调通知您。
|
||||
*/
|
||||
timRenderInstance.TIMSetMsgUpdateCallback({
|
||||
callback: (...args) => {callback({ type: 'TIMSetMsgUpdateCallback', data: args })},
|
||||
userData: ""
|
||||
})
|
||||
timRenderInstance.TIMOnInvited({
|
||||
callback:(data)=>{
|
||||
callback({
|
||||
type: 'TIMOnInvited',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
})
|
||||
timRenderInstance.TIMOnRejected({
|
||||
callback:(data)=>{
|
||||
callback({
|
||||
type: 'TIMOnRejected',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
})
|
||||
timRenderInstance.TIMOnAccepted({
|
||||
callback:(data)=>{
|
||||
callback({
|
||||
type: 'TIMOnAccepted',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
})
|
||||
timRenderInstance.TIMOnCancelled({
|
||||
callback:(data)=>{
|
||||
callback({
|
||||
type: 'TIMOnCancelled',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
timRenderInstance.TIMOnTimeout({
|
||||
callback:(data)=>{
|
||||
callback({
|
||||
type: 'TIMOnTimeout',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default { timRenderInstance, initListeners: IMListeners.initListeners }
|
|
@ -0,0 +1,341 @@
|
|||
/**
|
||||
* @description imChat 腾讯-即时通讯(无ui)
|
||||
* 文档地址:https://cloud.tencent.com/document/product/269/75285
|
||||
* 文档地址:https://cloud.tencent.com/document/product/269/63007 (electron)
|
||||
* @author: zdg
|
||||
* @date 2023-07-03
|
||||
*/
|
||||
// const TimRender = require('im_electron_sdk/dist/render')
|
||||
import * as TYPES from './enumbers' // sdk相关枚举
|
||||
import MsgEnum from './msgEnum' // 消息相关枚举(自定义)
|
||||
import IMListeners from './imLiseners' // im消息-监听器
|
||||
// @ts-ignore
|
||||
const API = window.api
|
||||
// TIM生成签名
|
||||
// import * as GenerateUserSig from './userSig' // 引入签名生成器
|
||||
const isDev = process.env.NODE_ENV == 'development' // 环境
|
||||
export class ImChat {
|
||||
timChat // imChat对象
|
||||
SDKAppID // sdkID
|
||||
secretKey // key
|
||||
userID // 用户id
|
||||
timGroupId // 群组id
|
||||
userSig // 签名
|
||||
status = { // 状态
|
||||
isLogin: false, // 是否登录
|
||||
isConnect: false, // 是否连接
|
||||
}
|
||||
defOption = { // 默认配置
|
||||
// 日志等级-全量日志
|
||||
log_level: TYPES.TIMLogLevel.kTIMLog_Off,
|
||||
// 群组类型-会议群(Meeting),成员上限 6000 人
|
||||
group_type: TYPES.TIMGroupType.kTIMGroup_ChatRoom,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 构造函数
|
||||
* @param {number} SDKAppID
|
||||
* @param {string} userSig
|
||||
* @param {string} userID
|
||||
* @param {boolean} isInit
|
||||
*/
|
||||
constructor(SDKAppID, userSig, userID, isInit) {
|
||||
this.SDKAppID = SDKAppID
|
||||
this.userSig = userSig
|
||||
this.userID = userID
|
||||
// window.test = this
|
||||
if (isInit) this.init()
|
||||
}
|
||||
// 设置配置
|
||||
async setConfig() {
|
||||
const log_level = TYPES.TIMLogLevel.kTIMLog_Error
|
||||
await this.timChat.TIMSetConfig({ // TIMSetConfigParam
|
||||
json_config: { // JSONCongfig
|
||||
set_config_log_level: log_level,
|
||||
set_config_callback_log_level: log_level,
|
||||
set_config_is_log_output_console: true,
|
||||
// set_config_user_config: { // 用户配置
|
||||
// user_config_is_read_receipt: true, // true表示要收已读回执事件
|
||||
// user_config_is_sync_report: true, // true表示服务端要删掉已读状态
|
||||
// user_config_is_ignore_grouptips_unread: true, // true表示群tips不计入群消息已读计数
|
||||
// user_config_is_is_disable_storage: false, // 是否禁用本地数据库,true表示禁用,false表示不禁用。默认是false
|
||||
// user_config_group_getinfo_option // 获取群组信息默认选项
|
||||
// user_config_group_member_getinfo_option // 获取群组成员信息默认选项
|
||||
// },
|
||||
// set_config_user_define_data // 自定义数据,如果需要,初始化前设置
|
||||
},
|
||||
user_data: '',
|
||||
})
|
||||
// 日志监听
|
||||
this.timChat.TIMSetLogCallback({
|
||||
callback: data => {
|
||||
this.setConsole('%cchat-log ', data[1])
|
||||
},
|
||||
user_data: ''
|
||||
})
|
||||
}
|
||||
// 初始化-imChat
|
||||
init() {
|
||||
return new Promise(async(resolve, reject) => {
|
||||
try {
|
||||
if(!API) reject('preload api获取失败, 初始化-未完成')
|
||||
// this.timChat = await API.getTimRender()
|
||||
this.timChat = IMListeners.timRenderInstance
|
||||
const code = await this.timChat.TIMInit()
|
||||
if (code == 0) { // 初始化成功
|
||||
this.setConsole('%cim-chat: init', '初始化成功')
|
||||
this.status.isConnect = true
|
||||
this.setConfig() // 设置日志级别
|
||||
resolve(this)
|
||||
} else { // 失败:具体请看code
|
||||
console.error('[im-chat]:初始化失败', code)
|
||||
reject(code)
|
||||
}
|
||||
} catch (error) {reject(error)}
|
||||
})
|
||||
}
|
||||
// 生成签名
|
||||
genTestUserSig() {
|
||||
// const options = {
|
||||
// SDKAppID: this.SDKAppID,
|
||||
// secretKey: this.secretKey,
|
||||
// userID: this.userID,
|
||||
// }
|
||||
// const { userSig } = GenerateUserSig.genTestUserSig(options)
|
||||
// this.userSig = userSig
|
||||
}
|
||||
/**
|
||||
* @description 监听消息
|
||||
* @param {Function} callback
|
||||
*/
|
||||
watch(callback) {
|
||||
// // 先移除监听
|
||||
// this.timChat.TIMRemoveRecvNewMsgCallback()
|
||||
// // 消息监听
|
||||
// this.timChat.TIMAddRecvNewMsgCallback({
|
||||
// callback, user_data: this.toStr('msg')
|
||||
// })
|
||||
// // 群消息监听
|
||||
// // 群组系统消息事件包括 加入群、退出群、踢出群、设置管理员、取消管理员、群资料变更、群成员资料变更。此消息是针对所有群组成员下发的
|
||||
// this.timChat.TIMSetGroupTipsEventCallback({
|
||||
// // callback, user_data: this.toStr('msg-group')
|
||||
// callback: (data) => {
|
||||
// // console.log('群消息', group_tips_event)
|
||||
// this.setConsole('%c群消息', data)
|
||||
// },
|
||||
// })
|
||||
if (this.timChat && this.status.isConnect) { // 连接成功允许监听
|
||||
this.setConsole('%cim-chat: watch', '监听成功')
|
||||
IMListeners.initListeners(callback)
|
||||
} else {
|
||||
this.setConsole('%cim-chat: watch', '监听失败, 未连接')
|
||||
}
|
||||
}
|
||||
// 登录
|
||||
login() {
|
||||
const fn = async (resolve, reject) => {
|
||||
const option = {
|
||||
userID: this.userID,
|
||||
userSig: this.userSig,
|
||||
}
|
||||
// 获取登录状态
|
||||
// [1,2,3,4] | [已登陆,登录中,未登录,登出中]
|
||||
// console.log('登录', this)
|
||||
const status = await this.timChat.TIMGetLoginStatus()
|
||||
if (status == 3) { // 未登录
|
||||
const res = await this.timChat.TIMLogin(option)
|
||||
if (res && res.code == 0) {
|
||||
// console.log('登录成功', res)
|
||||
this.setConsole('%cim-chat: login', '登录成功')
|
||||
this.status.isLogin = true
|
||||
resolve({status:0, msg:'登录成功', data:res})
|
||||
} else reject(res)
|
||||
} else {
|
||||
if (status == 1) { // 已登录
|
||||
this.setConsole('%cim-chat: login', '已登录')
|
||||
resolve({status, msg:'已登录'})
|
||||
} else if (status == 2) { // 登录中
|
||||
this.setConsole('%cim-chat: login', '登录中')
|
||||
resolve({status, msg:'登录中'})
|
||||
} else if (status == 4) { // 登出中
|
||||
this.setConsole('%cim-chat: login', '登出中')
|
||||
resolve({status, msg:'登出中'})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return new Promise(fn)
|
||||
}
|
||||
// 登出
|
||||
logout() {
|
||||
if (!this.timChat) return
|
||||
return this.timChat.TIMLogout().then(res => {
|
||||
this.setConsole('%cim-chat: logout', '登出成功')
|
||||
this.status.isLogin = false
|
||||
this.timChat.TIMUninit() // 反初始化
|
||||
return res
|
||||
}).catch(error => {
|
||||
this.setConsole('%cim-chat: logout', '登出失败', error)
|
||||
return error
|
||||
})
|
||||
}
|
||||
/**
|
||||
* @description 创建群组 群名和初始成员 userID
|
||||
* @param {any} name
|
||||
* @param {any[]} memberList
|
||||
*/
|
||||
createGroup(name, memberList=[]) {
|
||||
if (!this.timChat) return
|
||||
if (!!this.timGroupId) return console.log('群组已存在')
|
||||
// 转换初始成员id,userID 转 group_member_info_identifier
|
||||
if (memberList && memberList.length) {
|
||||
memberList = memberList.map(o => ({group_member_info_identifier:o.userID}))
|
||||
}
|
||||
const option = { // CreateGroupParams
|
||||
params: { // GroupParams
|
||||
// create_group_param_group_name: 群组名称(必填)
|
||||
// create_group_param_group_id: 群组ID,不填时创建成功回调会返回一个后台分配的群ID
|
||||
// create_group_param_group_type 群组类型,默认为Public
|
||||
// create_group_param_group_member_array 群组初始成员数组
|
||||
// create_group_param_notification 群组公告
|
||||
// create_group_param_introduction 群组简介
|
||||
// create_group_param_face_url 群组头像URL
|
||||
// create_group_param_add_option 加群选项,默认为Any
|
||||
// create_group_param_max_member_num 群组最大成员数
|
||||
// create_group_param_custom_info 请参考自定义字段
|
||||
create_group_param_group_name: name,
|
||||
create_group_param_group_type: this.defOption.group_type,
|
||||
create_group_param_max_member_num: 200,
|
||||
create_group_param_group_member_array: memberList
|
||||
},
|
||||
data: '', // 用户自定义数据
|
||||
}
|
||||
// @TGS#3XVNI6ZOG
|
||||
return this.timChat.TIMGroupCreate(option).then(res => {
|
||||
if (res && res.code == 0) {
|
||||
this.setConsole('%c创建群组成功', res)
|
||||
const timGroupId = res?.json_param?.create_group_result_groupid
|
||||
if (!!timGroupId && timGroupId != 'undefined'){
|
||||
// this.setConsole('%c创建群组成功', timGroupId)
|
||||
this.timGroupId = timGroupId
|
||||
// this.setGroupMsgReceive()
|
||||
}
|
||||
}
|
||||
return res
|
||||
})
|
||||
}
|
||||
// 删除群组
|
||||
deleteGroup() {
|
||||
if (!this.timGroupId) return
|
||||
return this.timChat.TIMGroupDelete({
|
||||
groupId: this.timGroupId,
|
||||
data: '', // 用户自定义数据
|
||||
})
|
||||
}
|
||||
/**
|
||||
* @description 设置群消息接收
|
||||
* @param {string} timGroupId
|
||||
*/
|
||||
setGroupMsgReceive(timGroupId) {
|
||||
if (!this.timGroupId) this.timGroupId = timGroupId || ''
|
||||
if (!this.timGroupId) return console.log('timGroupId为空')
|
||||
return this.timChat.TIMMsgSetGroupReceiveMessageOpt({
|
||||
groupId: this.timGroupId,
|
||||
opt: TYPES.TIMReceiveMessageOpt.kTIMRecvMsgOpt_Receive,
|
||||
data: '', // 用户自定义数据
|
||||
})
|
||||
}
|
||||
// 获取群组列表
|
||||
getGroupList() {
|
||||
return this.timChat.getGroupList().then(res => {
|
||||
console.log('获取群组列表', res)
|
||||
return res
|
||||
}).catch(error => {
|
||||
console.log('获取群组列表失败', error)
|
||||
return error
|
||||
})
|
||||
}
|
||||
/**
|
||||
* @description 发送消息
|
||||
* @param {any} conv_id
|
||||
* @param {any} msg
|
||||
*/
|
||||
sendMsg(conv_id, msg) {
|
||||
if (!conv_id) return console.log('conv_id为空')
|
||||
if (typeof msg == 'object') msg = JSON.stringify(msg)
|
||||
const option = {
|
||||
conv_id,
|
||||
conv_type: TYPES.TIMConvType.kTIMConv_Group,
|
||||
params: {
|
||||
message_elem_array: [{
|
||||
elem_type: TYPES.TIMElemType.kTIMElem_Text,
|
||||
text_elem_content: msg
|
||||
}],
|
||||
// message_conv_id: conv_id,
|
||||
// message_conv_type: TYPES.TIMConvType.kTIMConv_Group,
|
||||
// message_sender: this.userID
|
||||
},
|
||||
user_data: '', // 用户自定义数据
|
||||
// callback: (data) => {}
|
||||
}
|
||||
// console.log('发送消息', option)
|
||||
this.setConsole('%cim-chat: 发送消息', option)
|
||||
return this.timChat.TIMMsgSendMessageV2(option)
|
||||
}
|
||||
/**
|
||||
* @description 发送群消息
|
||||
* @param {any} msg
|
||||
* @param {*} head
|
||||
* @param {*} type
|
||||
*/
|
||||
sendMsgGroup(msg, head, type) {
|
||||
const msgObj = this.getMsgObj(head, msg, type)
|
||||
// console.log('发送群消息', msgObj)
|
||||
return this.sendMsg(this.timGroupId, msgObj)
|
||||
}
|
||||
// 发送关闭(下课)消息
|
||||
sendMsgClosed(){
|
||||
const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课')
|
||||
return this.sendMsg(this.timGroupId, msg)
|
||||
}
|
||||
/**
|
||||
* @description 获取消息对象
|
||||
* @param {string} msgHead
|
||||
* @param {string} msg
|
||||
* @param {string} type
|
||||
* @param {string|number} sender
|
||||
*/
|
||||
getMsgObj(msgHead, msg, type, sender, option={}) {
|
||||
if (!msgHead) throw new Error('msgHead is required')
|
||||
if (!msg) throw new Error('msg is required')
|
||||
if (typeof msg === 'object') msg = JSON.stringify(msg)
|
||||
return {
|
||||
msgKey: msgHead,
|
||||
msgcontent: msg,
|
||||
msgType: type || MsgEnum.TYPES.TEACHER, // 默认为老师
|
||||
senduserid: sender ?? this.userID,
|
||||
...option
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description 设置控制台样式
|
||||
* @param {string} hearStr
|
||||
* @param {string[]} args
|
||||
*/
|
||||
setConsole(hearStr,...args) {
|
||||
const css = 'color: #fff;background-color:#2ccb92;padding:3px 5px;border-radius:3px;'
|
||||
const time = new Date().toLocaleTimeString()
|
||||
if (!hearStr) hearStr = '%c' + time
|
||||
console.log(hearStr, css, ...args)
|
||||
}
|
||||
/**
|
||||
* @description 获取数据字符串
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
toStr = (data) => {
|
||||
if (typeof data === 'string') data = {type: data}
|
||||
return JSON.stringify(data)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
* @description 消息枚举
|
||||
* @author zdg
|
||||
* @date 2021-07-05 14:07:01
|
||||
*/
|
||||
|
||||
export class MsgEnum {
|
||||
/**
|
||||
* @description: 消息类型
|
||||
*
|
||||
* | 名称 | 含义 | 值(enum) |
|
||||
* | ---- | ---- | ---- |
|
||||
* | SYSTEM | 系统消息 | system |
|
||||
* | TEACHER | 老师消息 | teacher |
|
||||
* | STUDENT | 学生消息 | student |
|
||||
* | NOTICE | 通知消息 | notice |
|
||||
*/
|
||||
static TYPES = {
|
||||
/** @desc: 系统消息 */
|
||||
SYSTEM: 'system',
|
||||
/** @desc: 老师消息 */
|
||||
TEACHER: 'teacher',
|
||||
/** @desc: 学生消息 */
|
||||
STUDENT: 'student',
|
||||
/** @desc: 通知消息 */
|
||||
NOTICE: 'notice'
|
||||
}
|
||||
/**
|
||||
* @description: 消息头-类型
|
||||
*
|
||||
* | 名称 | 含义 | 值(enum) |
|
||||
* | ---- | ---- | ---- |
|
||||
* | --- | 以下为旧定义-消息头 | --- |
|
||||
* | MSG_closed | 结束课程(下课) | closed |
|
||||
* | MSG_onlineStatus | 在线状态 | onlineStatus |
|
||||
* | MSG_pushQuizOfClassWorkdata2Public | 老师端:把选中的学生习题作业,推到大屏 | pushQuizOfClassWorkdata2Public |
|
||||
* | MSG_pushClassWorkdata2Public | 老师端:把选中的学生作业,推到大屏 | pushClassWorkdata2Public |
|
||||
* | MSG_shareStudentPresentdata2All | 把某个学生的展示成果数据推给全班所有学生 | shareStudentPresentdata2All |
|
||||
* | MSG_pushStudentPresentdata2Public | 老师端:课堂展示活动,把选中的学生展示数据,推到大屏 | pushStudentPresentdata2Public |
|
||||
* | MSG_pushClassWorkPresentList2Public | 老师端:课堂展示活动,任务列表,推到大屏 | pushClassWorkPresentList2Public |
|
||||
* | MSG_activePageType | 课标研读-分页切换 | activePageType |
|
||||
* | MSG_slideFlapping | 幻灯片-切换 | slideFlapping |
|
||||
* | MSG_anmationclick | 幻灯片-动画切换 | anmationclick |
|
||||
* | MSG_classcourseopen | 群组创建成功 | classcourseopen |
|
||||
* | MSG_classquizfeedback | 学生的测练结果反馈 | classquizfeedback |
|
||||
* | MSG_classtaskfeedback | 老师端:接收到学生反馈消息-课堂测练中的其他任务 | classtaskfeedback |
|
||||
* | MSG_studentfeedback | 老师端:学生反馈的消息,具体要看其中的feedbackkey,类别较繁杂 | studentfeedback |
|
||||
* | MSG_studentfeedbackcancel | 老师端:学生反馈的消息取消,如取消学会了,取消困惑 | studentfeedbackcancel |
|
||||
* | MSG_classshowdata | 学生提交的课堂展示数据-要在老师端显示,再由老师选择推送到公屏上 | classshowdata |
|
||||
* | MSG_classWorkOfPresentDataUpdate | 学生在公屏上展示并完善后,保存后,老师端要更新 | classWorkOfPresentDataUpdate |
|
||||
* | MSG_classlecturePagesrc | 课堂讲授活动,选择不同的内容 | classlecturePagesrc |
|
||||
* | --- | 以下为新定义-消息头 | --- |
|
||||
* | MSG_0001 | 点赞 | 0x0001 |
|
||||
* | MSG_0002 | xx | 0x0002 |
|
||||
* | MSG_0003 | xx | 0x0003 |
|
||||
*/
|
||||
static HEADS = {
|
||||
// === 旧定义-消息头(兼容以前) ===
|
||||
/** @desc: 结束课程(下课) */
|
||||
MSG_closed : 'closed',
|
||||
/** @desc: 在线状态 */
|
||||
MSG_onlineStatus : 'onlineStatus',
|
||||
/** @desc: 老师端:把选中的学生习题作业,推到大屏 */
|
||||
MSG_pushQuizOfClassWorkdata2Public : 'pushQuizOfClassWorkdata2Public',
|
||||
/** @desc: 老师端:把选中的学生作业,推到大屏 */
|
||||
MSG_pushClassWorkdata2Public : 'pushClassWorkdata2Public',
|
||||
/** @desc: 把某个学生的展示成果数据推给全班所有学生 */
|
||||
MSG_shareStudentPresentdata2All : 'shareStudentPresentdata2All',
|
||||
/** @desc: 老师端:课堂展示活动,把选中的学生展示数据,推到大屏 */
|
||||
MSG_pushStudentPresentdata2Public : 'pushStudentPresentdata2Public',
|
||||
/** @desc: 老师端:课堂展示活动,任务列表,推到大屏 */
|
||||
MSG_pushClassWorkPresentList2Public : 'pushClassWorkPresentList2Public',
|
||||
/** @desc: 课标研读-分页切换 */
|
||||
MSG_activePageType : 'activePageType',
|
||||
/** @desc: 幻灯片-切换 */
|
||||
MSG_slideFlapping : 'slideFlapping',
|
||||
/** @desc: 幻灯片-动画切换 */
|
||||
MSG_anmationclick : 'anmationclick',
|
||||
/** @desc: 群组创建成功 */
|
||||
MSG_classcourseopen : 'classcourseopen',
|
||||
/** @desc: 学生的测练结果反馈 */
|
||||
MSG_classquizfeedback : 'classquizfeedback',
|
||||
/** @desc: 老师端:接收到学生反馈消息-课堂测练中的其他任务 */
|
||||
MSG_classtaskfeedback : 'classtaskfeedback',
|
||||
/** @desc: 老师端:学生反馈的消息,具体要看其中的feedbackkey,类别较繁杂 */
|
||||
MSG_studentfeedback : 'studentfeedback',
|
||||
/** @desc: 老师端:学生反馈的消息取消,如取消学会了,取消困惑 */
|
||||
MSG_studentfeedbackcancel : 'studentfeedbackcancel',
|
||||
/** @desc: 学生提交的课堂展示数据-要在老师端显示,再由老师选择推送到公屏上 */
|
||||
MSG_classshowdata : 'classshowdata',
|
||||
/** @desc: 学生在公屏上展示并完善后,保存后,老师端要更新 */
|
||||
MSG_classWorkOfPresentDataUpdate : 'classWorkOfPresentDataUpdate',
|
||||
/** @desc: 课堂讲授活动,选择不同的内容 */
|
||||
MSG_classlecturePagesrc : 'classlecturePagesrc',
|
||||
// === 新定义-消息头 ===
|
||||
/** @desc: 点赞 */
|
||||
MSG_0001: 0x0001,
|
||||
/** @desc: 疑惑 */
|
||||
MSG_0002: 0x0002,
|
||||
MSG_0003: 0x0003,
|
||||
MSG_0004: 0x0004,
|
||||
MSG_0005: 0x0005,
|
||||
MSG_0006: 0x0006,
|
||||
MSG_0007: 0x0007,
|
||||
MSG_0008: 0x0008,
|
||||
MSG_0009: 0x0009,
|
||||
MSG_0010: 0x000a,
|
||||
MSG_0011: 0x000b,
|
||||
MSG_0012: 0x000c,
|
||||
MSG_0013: 0x000d,
|
||||
MSG_0014: 0x000e,
|
||||
MSG_0015: 0x000f,
|
||||
/** @desc: 作业推送 */
|
||||
MSG_0016: 0x0010,
|
||||
MSG_0017: 0x0011,
|
||||
MSG_0018: 0x0012,
|
||||
MSG_0019: 0x0013,
|
||||
MSG_0020: 0x0014,
|
||||
MSG_0021: 0x0015,
|
||||
MSG_0022: 0x0016,
|
||||
MSG_0023: 0x0017,
|
||||
MSG_0024: 0x0018,
|
||||
MSG_0025: 0x0019,
|
||||
MSG_0026: 0x001a,
|
||||
MSG_0027: 0x001b,
|
||||
MSG_0028: 0x001c,
|
||||
MSG_0029: 0x001d,
|
||||
MSG_0030: 0x001e,
|
||||
MSG_0031: 0x001f,
|
||||
MSG_0032: 0x0020,
|
||||
MSG_0033: 0x0021,
|
||||
MSG_0034: 0x0022,
|
||||
MSG_0035: 0x0023,
|
||||
}
|
||||
}
|
||||
|
||||
export { MsgEnum as default }
|
|
@ -3,34 +3,114 @@
|
|||
*/
|
||||
const isNode = typeof require !== 'undefined' // 是否支持node函数
|
||||
const { ipcRenderer } = isNode?require('electron'):{} // app使用
|
||||
import { sessionStore } from '@/utils/store'
|
||||
// import { diff } from 'jsondiffpatch'
|
||||
// const Remote = isNode?require('@electron/remote'):{} // 远程模块
|
||||
|
||||
export function shareStorePlugin({store}) {
|
||||
store.$subscribe(() => { // 自动同步
|
||||
store.$subscribe((mutation, state) => { // 自动同步
|
||||
// mutation 变量包含了变化前后的状态
|
||||
// mutation.events: key newValue target oldValue oldTarget
|
||||
// state 是变化后的状态
|
||||
// console.log('store.$subscribe', mutation, state, store)
|
||||
// 在存储变化的时候执行
|
||||
const storeName = store.$id
|
||||
// const storeName = store.$id
|
||||
const storeName = mutation.storeId
|
||||
// 用于多窗口共享(需要共享的状态名称)
|
||||
const names = ['tool']
|
||||
if (names.includes(storeName)) stateSync(store) // 需要同步
|
||||
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
|
||||
stateSyncWatch(storeName, state) // 需要同步
|
||||
}
|
||||
})
|
||||
|
||||
// 暴露方法-手动同步
|
||||
store.stateSync = () => stateSync(store)
|
||||
store.stateSync = (storeName, key, value) => {
|
||||
const state = store.$state
|
||||
if (!storeName && !!key && !!value) stateSync(storeName, key, value, state)
|
||||
else stateSyncAll(store, state)
|
||||
}
|
||||
// 暴露方法-发送当前状态-新窗口
|
||||
store.stateSyncInit = wid => stateSyncInit(wid, store)
|
||||
// 监听主线程消息-同步数据
|
||||
stateChange(store)
|
||||
}
|
||||
// 同步数据-发送给主线程
|
||||
function stateSync(store) {
|
||||
|
||||
// 同步数据-发送给主线程-单独
|
||||
function stateSync(storeName, key, value, state) {
|
||||
// console.log('state-change', storeName, key, value)
|
||||
try {
|
||||
const { data, keystr } = filterByKey(state, key, value)
|
||||
const jsonStr = JSON.stringify(data) // 从新组装-json数据
|
||||
// 更新本地数据-session
|
||||
sessionStore.set(keystr, value)
|
||||
// 通知主线程更新
|
||||
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
|
||||
// console.log('======',keystr, jsonStr )
|
||||
} catch (error) {
|
||||
console.log('state-change-error', error)
|
||||
}
|
||||
}
|
||||
// 同步数据-发送给主线程-单独($subscribe-监听使用)
|
||||
function stateSyncWatch(storeName, newState) {
|
||||
const oldState = sessionStore.store // 旧数据
|
||||
const diffData = findDifferences(oldState, newState)
|
||||
// console.log('state-change-diffData', diffData)
|
||||
try {
|
||||
for(const key in diffData) {
|
||||
const value = diffData[key]
|
||||
const newValue = {} // 重新组装pinia需要的数据 {a:{b:1}} 这种
|
||||
const keyArr = key.split('.') || []
|
||||
keyArr.reduce((o,c,i)=>{o[c] = i === keyArr.length-1 ? value : {};return o[c]}, newValue)
|
||||
const jsonStr = JSON.stringify(newValue) // 从新组装-json数据
|
||||
// // 更新本地数据-session
|
||||
sessionStore.set(key, value)
|
||||
// // 通知主线程更新
|
||||
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
|
||||
// console.log('======',key, value, jsonStr )
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('state-change-error', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 同步数据-发送给主线程-全量更新
|
||||
function stateSyncAll(store) {
|
||||
const storeName = store.$id
|
||||
const jsonStr = JSON.stringify(store.$state)
|
||||
console.log('state-change', jsonStr, storeName)
|
||||
const jsonStr = circularSafeStringify(store.$state)
|
||||
// 通知主线程更新
|
||||
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
|
||||
}
|
||||
|
||||
// 发送当前数据状态
|
||||
function stateSyncInit(wid, store) {
|
||||
const storeName = store.$id
|
||||
const curJson = JSON.stringify(store.$state) // 当前数据
|
||||
// 发送同步数据给新窗口-更新状态
|
||||
ipcRenderer.invoke('pinia-state-init', wid, storeName, curJson)
|
||||
}
|
||||
|
||||
// 监听session数据变化
|
||||
function sessionWatch(store) {
|
||||
const unsubscribe = sessionStore.onDidAnyChange((newV, oldV) => {
|
||||
if (newV !== oldV) {
|
||||
console.log('session-change', newV, oldV)
|
||||
// 通知主线程更新
|
||||
// ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
|
||||
}
|
||||
})
|
||||
// unsubscribe() 取消监听
|
||||
}
|
||||
|
||||
// 同步数据-接收主线程消息
|
||||
function stateChange(store) {
|
||||
const storeName = store.$id
|
||||
ipcRenderer?.on('pinia-state-set', (e, sName, jsonStr) => {
|
||||
if (sName == storeName) { // 更新对应数据
|
||||
// console.log('state-set', jsonStr, sName)
|
||||
const curJson = JSON.stringify(store.$state) // 当前数据
|
||||
console.log('state-set', jsonStr, sName)
|
||||
const curJson = circularSafeStringify(store.$state) // 当前数据
|
||||
const isUp = curJson != jsonStr // 不同的时候才写入,不然会导致触发数据变化监听,导致死循环
|
||||
if (!isUp) return
|
||||
const stateJson = JSON.parse(jsonStr) // 新数据
|
||||
|
@ -41,3 +121,87 @@ function stateChange(store) {
|
|||
}
|
||||
})
|
||||
}
|
||||
//解决JSON.stringify嵌套循环产生的bug
|
||||
const circularSafeStringify = (obj) => {
|
||||
const cache = new Set();
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (cache.has(value)) {
|
||||
// 当前对象已经存在于缓存中,说明存在循环引用,返回占位符或其他处理方式
|
||||
return "[Circular Reference]";
|
||||
}
|
||||
cache.add(value);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
// 过滤对象
|
||||
const filterByKey = (obj, key, value) => {
|
||||
let res = { data:{}, keystr:'' }
|
||||
for (let k in obj) {
|
||||
if (obj.hasOwnProperty(k)) {
|
||||
const isEqual = JSON.stringify(obj[k]) === JSON.stringify(value) // 值是否相同
|
||||
if (k === key && isEqual) {
|
||||
// 如果匹配,则添加到新对象中
|
||||
res.data[k] = obj[k];
|
||||
res.keystr = k;
|
||||
} else {
|
||||
if (obj[k] !== null && typeof obj[k] === 'object') {
|
||||
// 如果是对象,则递归处理
|
||||
const {data, keystr} = filterByKey(obj[k], key, value)
|
||||
if(!!keystr) {
|
||||
res.data[k] = data
|
||||
res.keystr = `${k}.${keystr}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// 获取对象值
|
||||
const getObjValue = (obj, key) => {
|
||||
|
||||
}
|
||||
|
||||
// 找出两个对象之间的差异
|
||||
const findDifferences = (obj1, obj2) => {
|
||||
const differences = {};
|
||||
function compareObjects(o1, o2, path = '') {
|
||||
for (const key in o1) {
|
||||
if (o1.hasOwnProperty(key)) {
|
||||
const newPath = path ? `${path}.${key}` : key;
|
||||
if (o2.hasOwnProperty(key)) {
|
||||
const v1 = toJsonStr(o1[key])
|
||||
const v2 = toJsonStr(o2[key])
|
||||
if (typeof o1[key] === 'object' && typeof o2[key] === 'object' && !Array.isArray(o1[key])) {
|
||||
compareObjects(o1[key], o2[key], newPath);
|
||||
} else if (v1 !== v2) {
|
||||
differences[newPath] = o2[key];
|
||||
}
|
||||
} else {
|
||||
differences[newPath] = o2[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const key in o2) {
|
||||
if (o2.hasOwnProperty(key) && !o1.hasOwnProperty(key)) {
|
||||
const newPath = path ? `${path}.${key}` : key;
|
||||
differences[newPath] = o2[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compareObjects(objClone(obj1), objClone(obj2));
|
||||
// 特殊处理
|
||||
|
||||
|
||||
return differences;
|
||||
}
|
||||
// 对象克隆
|
||||
const objClone = (obj) => JSON.parse(JSON.stringify(obj))
|
||||
// 转换为json
|
||||
const toJsonStr = (obj) => JSON.stringify(obj)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* @Author: 苦逼程序猿
|
||||
* @Date: 2024-09-06 16:15:32
|
||||
* @Warning: 千行代码,Bug露锋芒。
|
||||
*/
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
|
||||
import Layout from '../layout/index.vue'
|
||||
|
@ -57,6 +62,12 @@ export const constantRoutes = [
|
|||
name: 'class',
|
||||
meta: {title: '班级中心'},
|
||||
},
|
||||
{
|
||||
path: '/classTask',
|
||||
component: () => import('@/views/classTask/classTask.vue'),
|
||||
name: 'class',
|
||||
meta: {title: '作业批改'},
|
||||
},
|
||||
]
|
||||
},
|
||||
...toolRouters
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { defineStore } from 'pinia'
|
||||
|
||||
const useThirdStore = defineStore('third', {
|
||||
state: () => ({
|
||||
activeGrade:'',
|
||||
gradeName:'',
|
||||
subjectName:'',
|
||||
textbookVersionId:''
|
||||
}),
|
||||
actions: {
|
||||
// 登录
|
||||
getSelectBookInfo(params){
|
||||
this.activeGrade = params.activeGrade
|
||||
this.gradeName = params.gradeName
|
||||
this.subjectName = params.subjectName
|
||||
this.textbookVersionId = params.textbookVersionId
|
||||
}
|
||||
|
||||
},
|
||||
persist: true
|
||||
})
|
||||
|
||||
export default useThirdStore
|
|
@ -2,6 +2,12 @@
|
|||
* 工具类-窗口-状态管理
|
||||
*/
|
||||
import { defineStore } from 'pinia'
|
||||
import { sessionStore } from '@/utils/tool'
|
||||
|
||||
// 默认数据
|
||||
const defData = sessionStore.store || {}
|
||||
// 延时
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||
|
||||
export const useToolState = defineStore('tool', {
|
||||
state: () => ({
|
||||
|
@ -10,10 +16,18 @@ export const useToolState = defineStore('tool', {
|
|||
isPdfWin: false, // pdf窗口是否打开
|
||||
isToolWin: false, // 工具窗口是否打开
|
||||
curSubjectNode: {
|
||||
data: {}, // 当前教材节点 (包含当前教材 单元)
|
||||
data: {}, // 当前教材节点 (包含当前教材 单元)
|
||||
querySearch: {} // 查询资源所需参数
|
||||
}
|
||||
},
|
||||
...defData // 默认数据-覆盖上面的配置(不要删除, 会导致新窗口-获取状态失败)
|
||||
}),
|
||||
actions: {
|
||||
async resetDef() { // 重置数据-下课
|
||||
this.model = 'select' // 悬浮球-当前模式
|
||||
await sleep(20) // 休眠20ms
|
||||
this.showBoardAll = false // 全屏画板-是否显示
|
||||
await sleep(20) // 休眠20ms
|
||||
this.isToolWin = false // 工具窗口是否打开
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -37,7 +37,7 @@ const useUserStore = defineStore('user', {
|
|||
return new Promise((resolve, reject) => {
|
||||
getInfo()
|
||||
.then((res) => {
|
||||
res.user.avatar = import.meta.env.VITE_APP_BASE_API + res.user.avatar
|
||||
// res.user.avatar = import.meta.env.VITE_APP_BASE_API + res.user.avatar
|
||||
const user = res.user
|
||||
this.user = user
|
||||
const avatar = user.avatar == '' || user.avatar == null ? defAva : user.avatar
|
||||
|
|
|
@ -76,3 +76,61 @@ export const toTimeText = (timeStamp, simple) => {
|
|||
}
|
||||
return timeText
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns 当前年-月-日
|
||||
*/
|
||||
export const getCurrentTime = (format)=> {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = now.getDate().toString().padStart(2, '0');
|
||||
const hours = now.getHours().toString().padStart(2, '0');
|
||||
const minutes = now.getMinutes().toString().padStart(2, '0');
|
||||
if(format == 'YYYY-MM-DD'){
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
if(format == 'HH:mm'){
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {number} m 指定时间
|
||||
* @returns 指定时间之后的 小时:分钟
|
||||
*/
|
||||
export const getAfterMinutes = (m) => {
|
||||
const now = new Date();
|
||||
const afterMinutes = new Date(now.getTime() + m * 60 * 1000);
|
||||
let hours = afterMinutes.getHours();
|
||||
hours = hours < 10 ? ('0' + hours) : hours
|
||||
let minutes = afterMinutes.getMinutes();
|
||||
minutes = minutes < 10 ? ('0' + minutes) : minutes
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格时间格式化
|
||||
*/
|
||||
export function formatDate(cellValue) {
|
||||
if (cellValue == null || cellValue == "") return "";
|
||||
var date = new Date(cellValue)
|
||||
var year = date.getFullYear()
|
||||
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
||||
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
||||
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
||||
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
||||
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
||||
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
||||
}
|
||||
export function getTimeDate() {
|
||||
var date = new Date()
|
||||
var year = date.getFullYear()
|
||||
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
||||
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
||||
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
||||
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
||||
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
||||
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
||||
}
|
|
@ -7,7 +7,6 @@ export const hasPermission = (value, def = true) => {
|
|||
if (!value) {
|
||||
return def
|
||||
}
|
||||
|
||||
const allCodeList = useUserStore().roles
|
||||
// 如果不是数组,直接判断pinia里的权限数组有没有相同的元素即可
|
||||
if (!Array.isArray(value)) {
|
||||
|
|
|
@ -47,6 +47,12 @@ export default () => {
|
|||
data: { ...baseConfig() },
|
||||
fullPath: `${baseConfig().url}/platofai`
|
||||
},
|
||||
// 文件资源 布置作业
|
||||
filehomework: {
|
||||
data: { ...baseConfig() },
|
||||
|
||||
fullPath: `${baseConfig().url}/teaching/classtaskassign?titleName=作业布置`
|
||||
},
|
||||
|
||||
getBaseData: () => {
|
||||
return {
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
// 所有事件
|
||||
export function handleevent(canvas, imgarr, type = 'defalut') {
|
||||
// // 鼠标按下
|
||||
// canvas.on('mouse:down', function (e) {})
|
||||
// // // 监听鼠标移动事件
|
||||
// // canvas.on('mouse:move', (options) => {
|
||||
// // console.log('Mouse move event:', options);
|
||||
// // });
|
||||
|
||||
// // 监听鼠标释放事件
|
||||
// canvas.on('mouse:up', (options) => {
|
||||
// //判断是点击的哪一个
|
||||
// if (type == 'defalut') {
|
||||
// if (imgarr.value[0].index == 0) {
|
||||
// imgarr.value[0].JSONdata = canvas.toJSON()
|
||||
// }
|
||||
// if (imgarr.value[1]?.index == 0) {
|
||||
// imgarr.value[1].JSONdata = canvas.toJSON()
|
||||
// }
|
||||
// } else {
|
||||
// if (imgarr.value[0].index == 1) {
|
||||
// imgarr.value[0].JSONdata = canvas.toJSON()
|
||||
// }
|
||||
// if (imgarr.value[1]?.index == 1) {
|
||||
// imgarr.value[1].JSONdata = canvas.toJSON()
|
||||
// }
|
||||
// }
|
||||
// console.log(imgarr.value)
|
||||
|
||||
// })
|
||||
}
|
||||
// 保存数据
|
||||
export function savecanvsStore(imgarr, canvsStore) {
|
||||
// canvsStore.pageArr = mergeAndReplace(canvsStore.pageArr, imgarr.value)
|
||||
}
|
||||
// 重显数据
|
||||
export function displayData(canvas, canvsStore, canvasobj, fabric, img) {
|
||||
// // 初始化
|
||||
// if (!canvsStore.pageArr.length) {
|
||||
// fabric.Image.fromURL(img.src, (img) => {
|
||||
// img.set({
|
||||
// left: 0,
|
||||
// top: 0,
|
||||
// scaleX: canvas.value.width / img.width,
|
||||
// scaleY: canvas.value.height / img.height
|
||||
// })
|
||||
// canvas.value.setBackgroundImage(img, canvas.value.renderAll.bind(canvas.value))
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// canvsStore.pageArr.forEach((item) => {
|
||||
// //初始化
|
||||
// if (item.page == canvasobj.page) {
|
||||
// // canvas.value.clear() // 清除 Canvas
|
||||
// // console.log(item.JSONdata, '找到一样的数据')
|
||||
// canvas.value.loadFromJSON(item.JSONdata, () => {
|
||||
// // 在所有对象加载完成后重新渲染画布
|
||||
// canvas.value.renderAll.bind(canvas.value)
|
||||
// canvas.value.renderAll()
|
||||
// // requestAnimationFrame(() => {
|
||||
// // // 渲染所有对象
|
||||
|
||||
// // })
|
||||
// })
|
||||
// } else {
|
||||
// // 使用 requestAnimationFrame 来更新画布,确保在下一帧进行重绘
|
||||
// // // 清除 Canvas
|
||||
// canvas.value.clear()
|
||||
// requestAnimationFrame(function () {
|
||||
// fabric.Image.fromURL(img.src, (img) => {
|
||||
// img.set({
|
||||
// left: 0,
|
||||
// top: 0,
|
||||
// scaleX: canvas.value.width / img.width,
|
||||
// scaleY: canvas.value.height / img.height
|
||||
// })
|
||||
// canvas.value.setBackgroundImage(img, canvas.value.renderAll.bind(canvas.value))
|
||||
// })
|
||||
// // 渲染所有对象
|
||||
// canvas.value.renderAll.bind(canvas.value)
|
||||
// canvas.value.renderAll()
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
//page 一样替换
|
||||
const mergeAndReplace = (arr1, arr2) => {
|
||||
// // 用于存储替换后的数组
|
||||
// const resultArray = array1.map(item1 => {
|
||||
// // 在 array2 中查找 page 相同的对象
|
||||
// const replacement = array2.find(item2 => item2.page == item1.page);
|
||||
// // 如果找到替换对象,则返回替换对象,否则返回原对象
|
||||
// return replacement ? replacement : item1;
|
||||
// });
|
||||
|
||||
// // 将 array2 中 page 不在 array1 中的对象追加到结果数组中
|
||||
// array2.forEach(item2 => {
|
||||
// const existsInArray1 = array1.some(item1 => item1.page == item2.page);
|
||||
// if (!existsInArray1) {
|
||||
// resultArray.push(item2);
|
||||
// }
|
||||
// });
|
||||
|
||||
// return resultArray;
|
||||
|
||||
// 创建一个映射,将 arr2 中的对象按 page 属性存储
|
||||
let map = new Map(arr2.map((item) => [item.page, item]))
|
||||
|
||||
// 使用 map 替换 arr1 中相应 page 的对象,并添加 arr2 中的对象
|
||||
arr1 = arr1.map((item) => (map.has(item.page) ? map.get(item.page) : item))
|
||||
|
||||
// 将 map 中存在但 arr1 中不存在的对象添加到 arr1
|
||||
for (let [page, obj] of map) {
|
||||
if (!arr1.some((item) => item.page === page)) {
|
||||
arr1.push(obj)
|
||||
}
|
||||
}
|
||||
return arr1
|
||||
}
|
||||
|
||||
// 初始化数据
|
||||
export function initcanvasdata(canvas) {
|
||||
canvas.value.clear() // 清除 Canvas
|
||||
// 设置画布的背景色或其他属性
|
||||
canvas.value.backgroundColor = 'rgba(255, 255, 255, 1)' // 白色背景
|
||||
|
||||
// 使用 requestAnimationFrame 来更新画布,确保在下一帧进行重绘
|
||||
requestAnimationFrame(function () {
|
||||
// 渲染所有对象
|
||||
canvas.value.renderAll.bind(canvas.value)
|
||||
})
|
||||
}
|
|
@ -6,7 +6,11 @@ export const tabs = [
|
|||
{
|
||||
label: '校本资源',
|
||||
value: '校本'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '第三方资源',
|
||||
value: '第三方'
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
@ -67,3 +71,45 @@ export const resourceType = [
|
|||
value: '教案'
|
||||
}
|
||||
]
|
||||
// 年级划分
|
||||
export const gradeList = [
|
||||
{
|
||||
label:'小学',
|
||||
value:1
|
||||
},
|
||||
{
|
||||
label:'初中',
|
||||
value:2
|
||||
},
|
||||
{
|
||||
label:'高中',
|
||||
value:3
|
||||
},
|
||||
]
|
||||
//课件类别
|
||||
export const coursewareTypeList = [
|
||||
{
|
||||
label:'全部',
|
||||
value:''
|
||||
},
|
||||
{
|
||||
label:'课件',
|
||||
value:3
|
||||
},
|
||||
{
|
||||
label:'教案',
|
||||
value:8
|
||||
},
|
||||
{
|
||||
label:'试卷',
|
||||
value:7
|
||||
},
|
||||
{
|
||||
label:'学案',
|
||||
value:4
|
||||
},
|
||||
{
|
||||
label:'素材',
|
||||
value:6
|
||||
},
|
||||
]
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @description : 存储对象-本地存储 封装工具(渲染器)
|
||||
* @author : zdg
|
||||
* @date : 2024-09-03
|
||||
*/
|
||||
const isNode = typeof require !== 'undefined' // 是否支持node函数
|
||||
const Store = isNode?require('electron-store'):null // 持久化存储
|
||||
|
||||
// 暴露sessionStore存储对象
|
||||
export const sessionStore = Store ? new Store({
|
||||
name: 'session-store', // 存储文件名
|
||||
fileExtension: 'ini', // 文件后缀名
|
||||
encryptionKey: 'BvPLmgCC4DSIG0KkTec5' // 数据加密-防止用户直接改配置
|
||||
}) : {}
|
||||
|
||||
// 暴露localStore存储对象
|
||||
export const localStore = Store ? new Store({
|
||||
name: 'local-store', // 存储文件名
|
||||
fileExtension: 'ini', // 文件后缀名
|
||||
encryptionKey: '6CyoHQmUaPmLzvVsh' // 数据加密-防止用户直接改配置
|
||||
}) : {}
|
||||
|
||||
export default {
|
||||
sessionStore, localStore
|
||||
}
|
|
@ -6,17 +6,33 @@
|
|||
// Remote.app.getAppPath() E:\njys-work\AIx_Smarttalk\dist\win-unpacked\resources\app.asar
|
||||
// path.join(__dirname) 根目录 E:\njys-work\AIx_Smarttalk\dist\win-unpacked\resources\app.asar\out\renderer
|
||||
|
||||
const isNode = typeof require !== 'undefined' // 是否支持node函数
|
||||
const isNode = typeof require !== 'undefined' // 是否支持node函数
|
||||
const path = isNode?require('path'):{}
|
||||
const Remote = isNode?require('@electron/remote'):{}
|
||||
const { ipcRenderer } = isNode?require('electron'):window.electron || {}
|
||||
|
||||
const API = isNode?window.api:{} // preload-api
|
||||
import { useToolState } from '@/store/modules/tool' // 获取store状态
|
||||
// const Store = isNode?require('electron-store'):null // 持久化存储
|
||||
import store from './store'
|
||||
// 常用变量
|
||||
const BaseUrl = isNode?process.env['ELECTRON_RENDERER_URL']+'/#':''
|
||||
const isDev = isNode?process.env.NODE_ENV !== 'production':''
|
||||
|
||||
const appPath = isNode?Remote.app.getAppPath():'' // 应用目录
|
||||
|
||||
// 暴露Remote中的属性
|
||||
export const ipcMain = Remote?.ipcMain || {}
|
||||
|
||||
// 暴露sessionStore存储对象
|
||||
export const sessionStore = store.sessionStore
|
||||
|
||||
// 暴露localStore存储对象
|
||||
export const localStore = store.localStore
|
||||
|
||||
// 暴露Store存储对象
|
||||
export const Store = store
|
||||
// 延时
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||
/**
|
||||
* 获取静态资源,开发和生产环境
|
||||
* @param {*} url
|
||||
|
@ -82,38 +98,53 @@ export function ipcHandle(fn,key, cb) {
|
|||
* @param {*} data 参数
|
||||
* @returns
|
||||
*/
|
||||
let wins_tool = null
|
||||
let winPdf=null
|
||||
export const createWindow = async (type, data) => {
|
||||
if (!type) return console.error('createWindow: type is null')
|
||||
switch(type) {
|
||||
case 'tool-sphere': { // 创建-悬浮球
|
||||
if (wins_tool) return console.error('createWindow: win is have')
|
||||
if (!type) return console.error('createWindow: type is null')
|
||||
const option = data.option||{}
|
||||
const defOption = {
|
||||
frame: false, // 要创建无边框窗口
|
||||
resizable: false, // 禁止窗口大小缩放
|
||||
transparent: true, // 设置透明
|
||||
alwaysOnTop: true, // 窗口是否总是显示在其他窗口之前
|
||||
type: 'toolbar', // 创建的窗口类型为工具栏窗口
|
||||
// parent: mainWin, // 父窗口
|
||||
// autoClose: true, // 关闭窗口后自动关闭
|
||||
}
|
||||
data.isConsole = true // 是否开启控制台
|
||||
data.isWeb = false // 是否开启web安全
|
||||
data.option = {...defOption, ...option}
|
||||
const win = await toolWindow(data)
|
||||
win.type = type // 唯一标识
|
||||
win.show()
|
||||
win.setFullScreen(true) // 设置窗口为全屏
|
||||
win.setIgnoreMouseEvents(true, {forward: true}) // 忽略鼠标事件但是事件继续传递给窗口
|
||||
win.setAlwaysOnTop(true,'screen-saver') // 将窗口设置为顶层窗口
|
||||
win.setVisibleOnAllWorkspaces(true) // 如果窗口在所有工作区都可见
|
||||
// win.webContents.openDevTools() // 打开调试工具
|
||||
eventHandles(type, win) // 事件监听处理
|
||||
return win
|
||||
wins_tool = await toolWindow(data)
|
||||
wins_tool.type = type // 唯一标识
|
||||
wins_tool.show()
|
||||
wins_tool.setFullScreen(true) // 设置窗口为全屏
|
||||
wins_tool.setIgnoreMouseEvents(true, {forward: true}) // 忽略鼠标事件但是事件继续传递给窗口
|
||||
wins_tool.setAlwaysOnTop(true,'screen-saver') // 将窗口设置为顶层窗口
|
||||
wins_tool.setVisibleOnAllWorkspaces(true) // 如果窗口在所有工作区都可见
|
||||
// wins_tool.webContents.openDevTools() // 打开调试工具
|
||||
eventHandles(type, wins_tool) // 事件监听处理
|
||||
return wins_tool
|
||||
}
|
||||
case 'open-PDF': { //课本展示-pdf
|
||||
if(winPdf){ //判断是否已经打开
|
||||
if (winPdf.isMinimized()){
|
||||
winPdf.restore();
|
||||
} else{
|
||||
winPdf.focus();
|
||||
// toolState.isPdfWin=true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
const option = data.option||{}
|
||||
const defOption = {
|
||||
frame: false, // 要创建无边框窗口
|
||||
resizable: true, // 禁止窗口大小缩放
|
||||
alwaysOnTop: false, // 窗口是否总是显示在其他窗口之前
|
||||
resizable: true, // 禁止窗口大小缩放
|
||||
alwaysOnTop: false, // 窗口是否总是显示在其他窗口之前
|
||||
}
|
||||
data.isConsole = true // 是否开启控制台
|
||||
data.option = {...defOption, ...option}
|
||||
|
@ -123,6 +154,7 @@ export const createWindow = async (type, data) => {
|
|||
win.setFullScreen(true) // 设置窗口为全屏
|
||||
// win.webContents.openDevTools() // 打开调试工具
|
||||
eventHandles(type, win) // 事件监听处理
|
||||
winPdf=win
|
||||
break
|
||||
}
|
||||
default:
|
||||
|
@ -138,7 +170,7 @@ export const createWindow = async (type, data) => {
|
|||
* @author: zdg
|
||||
* @date 2021-07-05 14:07:01
|
||||
*/
|
||||
export function toolWindow({url, isConsole, option={}}) {
|
||||
export function toolWindow({url, isConsole, isWeb=true, option={}}) {
|
||||
// width = window.screen.width
|
||||
let width = option?.width || 800
|
||||
let height = option?.height || 600
|
||||
|
@ -149,31 +181,38 @@ export function toolWindow({url, isConsole, option={}}) {
|
|||
return new Promise((resolve) => {
|
||||
const config = {
|
||||
width, height,
|
||||
type: 'toolbar', // 创建的窗口类型为工具栏窗口
|
||||
icon: path.join(__dirname, '../../resources/logo2.ico'),
|
||||
icon: path.join(appPath, '/resources/logo2.ico'),
|
||||
webPreferences: {
|
||||
// preload: path.join(__dirname, '../preload/index.js'),
|
||||
preload: '@root/src/preload/index.js',
|
||||
preload: path.join(API.preloadPath, '/index.js'),
|
||||
sandbox: false,
|
||||
nodeIntegration: true, // nodeApi调用
|
||||
contextIsolation: false, // 沙箱取消
|
||||
// webSecurity: false // 跨域关闭
|
||||
devTools: true
|
||||
},
|
||||
...option
|
||||
}
|
||||
// 创建-新窗口
|
||||
let win = new Remote.BrowserWindow(config)
|
||||
if (!isDev) win.loadFile(urlAll,{hash: url}) // 加载文件
|
||||
else win.loadURL(urlAll) // 加载url
|
||||
win.once('ready-to-show', () => {resolve(win)})
|
||||
if (!isDev) win.loadFile(urlAll,{hash: url}) // 加载文件
|
||||
else win.loadURL(urlAll) // 加载url
|
||||
win.once('ready-to-show', () => { // 窗口加载完成
|
||||
resolve(win)
|
||||
})
|
||||
// 主窗口关闭事件
|
||||
mainWin.once('closed', () => { win.destroy()})
|
||||
// 内部监听器
|
||||
win.webContents.on('did-finish-load', () => {})
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
// setTimeout(() => {
|
||||
// toolState.stateSyncInit(win.id) // 同步状态
|
||||
// }, 200);
|
||||
})
|
||||
// 内部监听器-是否打印
|
||||
if (!!isConsole) {
|
||||
win.webContents.on('console-message', (e,leve,m,lin,s) => {
|
||||
console.log(`[${win.type}]`,m)
|
||||
if(m.startsWith('%c')){ // 特殊打印
|
||||
const arr = m.match(/(%c[^ ]+)(?:\s+(.*;))(.*)/)
|
||||
console.log(arr[1],arr[2],arr[3])
|
||||
} else console.log(`[${win.type}]`,m)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -184,16 +223,19 @@ export function toolWindow({url, isConsole, option={}}) {
|
|||
* @param {*} win 窗口对象
|
||||
*/
|
||||
const eventHandles = (type, win) => {
|
||||
const toolState = useToolState() // 获取store状态
|
||||
const winAll = Remote.BrowserWindow.getAllWindows()
|
||||
const mainWin = winAll.find(o => o.type == 'main') // 主窗口对象
|
||||
// 公共方法
|
||||
const publicMethods = ({onClosed}={}) => {
|
||||
// 监听主窗口-关闭事件
|
||||
mainWin.once('close', () => {win.destroy()})
|
||||
mainWin.once('close', () => {winPdf=null;win.destroy();})
|
||||
win.on('closed', () => {
|
||||
if(onClosed) onClosed() // 自定义关闭事件
|
||||
win = null
|
||||
wins_tool = null
|
||||
})
|
||||
|
||||
// 新窗口-创建事件(如:主进程加载远程服务)
|
||||
ipcRenderer.send('new-window', {id:win.id, type})
|
||||
}
|
||||
|
@ -209,28 +251,58 @@ const eventHandles = (type, win) => {
|
|||
const on = {
|
||||
onClosed: () => {
|
||||
Remote.ipcMain.removeHandler('tool-sphere:set:ignore', setIgnore)
|
||||
Remote.ipcMain.removeHandler('tool-sphere:reset')
|
||||
// Remote.ipcMain.removeHandler('tool-sphere:reset')
|
||||
// Remote.ipcMain.removeAllListeners() // 移除所有监听事件
|
||||
// 设置状态(再次设置-防止未设置到)
|
||||
if(toolState.isToolWin) toolState.isToolWin = false
|
||||
// sessionStore.set('isToolWin', false)
|
||||
}
|
||||
}
|
||||
publicMethods(on) // 加载公共方法
|
||||
break}
|
||||
case 'open-PDF': {
|
||||
// 最小化窗口 minimize()
|
||||
Remote.ipcMain.once('open-PDF:minimize', () => {win&&win.destroy()})
|
||||
publicMethods() // 加载公共方法
|
||||
Remote.ipcMain.handle('open-PDF:minimize', () => {
|
||||
// winPdf=null
|
||||
// win&&win.destroy()
|
||||
win&&win.minimize(); //缩小功能
|
||||
})
|
||||
// 关闭窗口
|
||||
Remote.ipcMain.once('open-PDF:close', () => {
|
||||
winPdf=null
|
||||
win&&win.destroy()
|
||||
})
|
||||
|
||||
// 监听窗口的激活事件
|
||||
win.on('focus', async () => {
|
||||
console.log('激活窗口')
|
||||
toolState.isPdfWin=true
|
||||
await sleep(20) // 延时
|
||||
toolState.showBoardAll=false //恢复默认值
|
||||
// await sleep(50) // 延时
|
||||
// 穿透开启
|
||||
if (toolState.isToolWin) ipcRenderer.invoke('tool-sphere:set:ignore', true)
|
||||
});
|
||||
const on = {
|
||||
onClosed: () => {
|
||||
Remote.ipcMain.removeHandler('open-PDF:minimize')
|
||||
// 设置状态(再次设置-防止未设置到)
|
||||
if(toolState.isPdfWin) toolState.isPdfWin = false
|
||||
}
|
||||
}
|
||||
publicMethods(on) // 加载公共方法
|
||||
break}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const taskHandles = () => {
|
||||
// // 设置任务栏上下文菜单
|
||||
// const contextMenu = new Remote.Menu()
|
||||
// contextMenu.append(new Remote.MenuItem({
|
||||
// label: '关闭',
|
||||
// click: () => {Remote.app.quit()}
|
||||
// }))
|
||||
}
|
||||
// const taskHandles = () => {
|
||||
// // 设置任务栏上下文菜单
|
||||
// const contextMenu = new Remote.Menu()
|
||||
// contextMenu.append(new Remote.MenuItem({
|
||||
// label: '关闭',
|
||||
// click: () => {Remote.app.quit()}
|
||||
// }))
|
||||
// }
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
<i class="iconfont icon-xiayiye"></i>
|
||||
<span class="texts">下一页</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="pdf-btn-right">
|
||||
<el-button @click="minimize" >最小化</el-button>
|
||||
<el-button @click="minimize('rest')" >关闭</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -40,10 +43,8 @@ import { getStaticUrl } from '@/utils/tool'
|
|||
const { ipcRenderer } = require('electron')
|
||||
import { getBookMarkById } from '@/api/eTextbook/index'
|
||||
import {useToolState} from '@/store/modules/tool'
|
||||
// const getStaticUrl=(url)=>{
|
||||
// return url
|
||||
// }
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = getStaticUrl('/lib/build/pdf.worker.mjs')
|
||||
|
||||
const toolState = useToolState();
|
||||
const route = useRoute();
|
||||
const isOnLoadShow = ref(false) //加载完毕显示
|
||||
|
@ -73,15 +74,11 @@ const navtopage = (type) => {
|
|||
if (pdfObj.numPages > numPagesTotal.value) return
|
||||
pdfCanvaslist.value.initPdf('rest')
|
||||
}
|
||||
// 最小化窗口
|
||||
const minimize = async () => {
|
||||
await pdfCanvaslist.value.savaDataStore()
|
||||
// toolState.isPdfWin=false
|
||||
// toolState.showBoardAll=true //恢复默认值
|
||||
// console.log(toolState.showBoardAll,"关闭")
|
||||
// // ipcRenderer.send('tool-sphere:reset') //重置tool状态
|
||||
// ipcRenderer.send('open-PDF:minimize')
|
||||
// 关闭窗口
|
||||
const minimize = async (type='minimize') => {
|
||||
await pdfCanvaslist.value.savaDataStore(type)
|
||||
}
|
||||
|
||||
const handleUpdate = (data) => {
|
||||
numPagesTotal.value = data
|
||||
if (numPagesTotal.value == 1) {
|
||||
|
@ -107,10 +104,16 @@ const switchPageMode = () => {
|
|||
}
|
||||
}
|
||||
onMounted(async () => {
|
||||
toolState.isPdfWin=true
|
||||
pdfObj.pdfUrl = getStaticUrl(route.query.path, 'user', 'selfFile', true)
|
||||
const isDev = process.env.NODE_ENV == 'development'
|
||||
// toolState.showBoardAll = false // 隐藏画板
|
||||
toolState.isPdfWin=true //设置打开pdf窗口
|
||||
if (isDev)
|
||||
pdfObj.pdfUrl = getStaticUrl('aaa.pdf', 'user', 'selfFile', true) //本地
|
||||
else
|
||||
pdfObj.pdfUrl = getStaticUrl(route.query.path, 'user', 'selfFile', true) //线上
|
||||
textbookId.value = route.query.textbookId
|
||||
pdfObj.bookId=textbookId.value
|
||||
//初始化获取接口数据
|
||||
getBookMarkById(textbookId.value).then(res=>{
|
||||
pdfObj.allPageData=getUniqueArrayByLastOccurrence(res.data)
|
||||
isOnLoadShow.value=true
|
||||
|
@ -143,7 +146,8 @@ const getUniqueArrayByLastOccurrence=(array)=> {
|
|||
flex-wrap: wrap;
|
||||
.pdf-btn {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
// right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
|
||||
border-radius: 5px 0 0 0;
|
||||
|
@ -168,5 +172,28 @@ const getUniqueArrayByLastOccurrence=(array)=> {
|
|||
}
|
||||
}
|
||||
}
|
||||
.pdf-btn-right{
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
|
||||
border-radius: 5px 0 0 0;
|
||||
button {
|
||||
margin-left: 0;
|
||||
border: none;
|
||||
font-size: 16px;
|
||||
// padding: 4px 7px;
|
||||
border-radius: 0;
|
||||
width: 80px;
|
||||
height: 70px;
|
||||
:deep(> span) {
|
||||
display: block !important;
|
||||
}
|
||||
.iconfont {
|
||||
font-size: 26px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -1,10 +1,10 @@
|
|||
<template>
|
||||
<el-card style="width: 100%;height: 100%">
|
||||
<template #header>
|
||||
<div class="card-header" style="text-align: left">
|
||||
<el-button type="primary" @click="addGroup">新建分组</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- <template #header>-->
|
||||
<!-- <div class="card-header" style="text-align: left">-->
|
||||
<!-- <el-button type="primary" @click="addGroup">新建分组</el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<template v-if="groupList.length > 0">
|
||||
<div style="font-size: 16px;font-weight: bold;color: #000;text-align: left;margin-bottom: 5px">可用分组</div>
|
||||
<div class="groupList">
|
||||
|
@ -108,7 +108,7 @@
|
|||
|
||||
<script setup>
|
||||
import {listClassmain, listClassuser, addClassgroup, listClassgroup, delClassgroup,getClassgroup,updateClassgroup} from '@/api/classManage/index'
|
||||
import {ref, onMounted, reactive, defineProps, watch} from 'vue'
|
||||
import {ref, onMounted, reactive, watch} from 'vue'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<template>
|
||||
<el-card style="width: 100%;height: 100%">
|
||||
<template #header>
|
||||
<div style="text-align: left">
|
||||
<el-button type="danger" @click="deleteClassRoom">删除班级</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- <template #header>-->
|
||||
<!-- <div style="text-align: left">-->
|
||||
<!-- <el-button type="danger" @click="deleteClassRoom">删除班级</el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<el-descriptions :column="1">
|
||||
<el-descriptions-item label="班级名称">{{ classInfo.caption }}</el-descriptions-item>
|
||||
<el-descriptions-item label="教师">
|
||||
|
@ -22,7 +22,7 @@
|
|||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
import { getClassmain,listClassuser,leaveClass} from '@/api/classManage/index'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import {reactive,onMounted,defineProps,nextTick,watch} from 'vue'
|
||||
import {reactive,onMounted,nextTick,watch} from 'vue'
|
||||
import delClassDemo from '@/store/modules/delClass'
|
||||
const props = defineProps({
|
||||
classId: {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
v-show="tabActive === '已结束'"
|
||||
:key="index"
|
||||
:item="item"
|
||||
@open-edit="reservDialog.openDialog(item)"
|
||||
@delete-reserv="deleteReserv(item)"
|
||||
></reserv-item>
|
||||
</div>
|
||||
<reserv ref="reservDialog"></reserv>
|
||||
|
@ -29,6 +31,7 @@ import { getSelfReserv } from '@/api/classManage'
|
|||
import ReservItem from '@/views/classManage/reserv-item.vue'
|
||||
import Reserv from '@/views/prepare/container/reserv.vue'
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import { sessionStore } from '@/utils/tool'
|
||||
const reservDialog = ref(null)
|
||||
const tabOptions = ref(['进行中', '已结束'])
|
||||
const tabActive = ref('进行中')
|
||||
|
@ -49,19 +52,27 @@ const doneDataList = computed(() => {
|
|||
return item.status === '已结束'
|
||||
})
|
||||
})
|
||||
// 获取数据
|
||||
const getData = () => {
|
||||
getSelfReserv().then((res) => {
|
||||
const list = res.data || []
|
||||
list.sort((a,b) => { if(a.status=='上课中') return -1; else return 0 })
|
||||
dataList.value = list
|
||||
})
|
||||
}
|
||||
const toolStore = useToolState()
|
||||
|
||||
watch(
|
||||
() => toolStore.isToolWin,
|
||||
(newD, oldD) => {
|
||||
getSelfReserv().then((res) => {
|
||||
dataList.value = [...res.data]
|
||||
})
|
||||
() => [dataList,toolStore.isToolWin],
|
||||
() => {
|
||||
console.log('====',toolStore)
|
||||
setTimeout(()=>{
|
||||
getData() // 加载数据
|
||||
},300)
|
||||
}
|
||||
)
|
||||
onMounted(() => {
|
||||
getSelfReserv().then((res) => {
|
||||
dataList.value = res.data
|
||||
})
|
||||
getData() // 加载数据
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
<div :style="{'max-height': (viewportHeight - 120) + 'px','overflow-y': 'auto'}">
|
||||
<Aside :menuItems="menuItems" :classList="classList" @handleSelect="handleSelect"></Aside>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button @click="addClass" type="primary" :icon="Plus" >新增班级</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 隐藏操作按钮-->
|
||||
<!-- <template #footer>-->
|
||||
<!-- <div>-->
|
||||
<!-- <el-button @click="addClass" type="primary" :icon="Plus" >新增班级</el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
</el-card>
|
||||
</el-aside>
|
||||
<el-main :style="{'min-height': (viewportHeight - 160) + 'px'}">
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="class-reserv-item-tool">
|
||||
<el-button v-if="item.status !== '已结束'" type="primary" @click="startClassR(item)"
|
||||
>上课</el-button
|
||||
<el-button v-if="item.status !== '已结束'" :disabled="toolStore.isToolWin" type="primary" @click="startClassR(item)"
|
||||
>{{item.status == '上课中'?'上课中':'上课'}}</el-button
|
||||
>
|
||||
<el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>
|
||||
<!-- <el-button v-if="item.status === '上课中'" type="info" @click="endClassR(item)"
|
||||
>下课</el-button
|
||||
>-->
|
||||
<el-button type="danger" @click="deleteReserv">删除</el-button>
|
||||
<el-button v-if="item.status!='上课中'" type="danger" @click="deleteReserv">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -46,6 +46,7 @@ const props = defineProps({
|
|||
}
|
||||
})
|
||||
const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
||||
const toolStore = useToolState() // 获取状态管理-tool
|
||||
const openEdit = () => {
|
||||
emit('openEdit', props.item)
|
||||
}
|
||||
|
@ -61,25 +62,27 @@ const deleteReserv = () => {
|
|||
})
|
||||
}
|
||||
const startClassR = (item) => {
|
||||
startClass(item.id).then((res) => {
|
||||
if (res.data === true) {
|
||||
item.status = '上课中'
|
||||
openLesson()
|
||||
}
|
||||
})
|
||||
// startClass(item.id).then((res) => {
|
||||
// if (res.data === true) {
|
||||
// item.status = '上课中'
|
||||
// openLesson()
|
||||
// }
|
||||
// })
|
||||
item.status = '上课中'
|
||||
openLesson()
|
||||
}
|
||||
const toolStore = useToolState()
|
||||
// const toolStore = useToolState()
|
||||
let wins = null;
|
||||
// 上课-工具类悬浮
|
||||
const openLesson = () => {
|
||||
if (toolStore.isToolWin) return ElMessage.error('您当前已开始上课,请勿重复操作')
|
||||
startClass(props.item.id)
|
||||
// startClass(props.item.id)
|
||||
listEntpcourse({
|
||||
evalid: props.item.ex2,
|
||||
edituserid: useUserStore().user.userId,
|
||||
pageSize: 500
|
||||
}).then(res=>{
|
||||
}).then(async res=>{
|
||||
if (res.rows[0].id) {
|
||||
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id })
|
||||
wins = await createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
<el-card style="width: 100%;height: 100%;overflow-y: auto">
|
||||
<template #header>
|
||||
<div style="text-align: left;display: flex;justify-content: space-between">
|
||||
<div>
|
||||
<el-button type="primary" @click="addStudent(0)">新增学生</el-button>
|
||||
<el-button type="primary" @click="importStudent()">导入学生</el-button>
|
||||
</div>
|
||||
<!-- <div>-->
|
||||
<!-- <el-button type="primary" @click="addStudent(0)">新增学生</el-button>-->
|
||||
<!-- <el-button type="primary" @click="importStudent()">导入学生</el-button>-->
|
||||
<!-- </div>-->
|
||||
<el-text class="mx-1">点击学生头像查看学生信息</el-text>
|
||||
</div>
|
||||
</template>
|
||||
<div>
|
||||
<div class="studentContent">
|
||||
<template v-if="studentList.length > 0">
|
||||
<div v-for="(item,index) in studentList" :key="index" style="width: 10%" @click="addStudent(item.studentid)">
|
||||
<div v-for="(item,index) in studentList" :key="index" style="width: 10%">
|
||||
<div>
|
||||
<el-avatar
|
||||
src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
|
||||
|
@ -54,27 +54,27 @@
|
|||
<el-form-item label="电话" prop="parentmobile">
|
||||
<el-input v-model="studentForm.parentmobile" placeholder="请输入电话" style="width: 50%"/>
|
||||
</el-form-item>
|
||||
<div>
|
||||
<el-row :gutter="4">
|
||||
<el-col :span="12">
|
||||
<el-form-item label-width="100px" label="平台登录账号">
|
||||
系统自动创建
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label-width="100px" label="平台登录密码">
|
||||
系统自动创建,默认为123123
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<!-- <div>-->
|
||||
<!-- <el-row :gutter="4">-->
|
||||
<!-- <el-col :span="12">-->
|
||||
<!-- <el-form-item label-width="100px" label="平台登录账号">-->
|
||||
<!-- 系统自动创建-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="12">-->
|
||||
<!-- <el-form-item label-width="100px" label="平台登录密码">-->
|
||||
<!-- 系统自动创建,默认为123123-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- </el-row>-->
|
||||
<!-- </div>-->
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="warning" v-show="studentForm.id > 0" @click="delStudent(1)">移出班级</el-button>
|
||||
<el-button type="danger" v-show="studentForm.id > 0 && studentForm.editoruserid == userStore.userId" @click="delStudent(2)">删除学生</el-button>
|
||||
<el-button @click="studentVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="btnStudentSave">确 定</el-button>
|
||||
</template>
|
||||
<!-- <template #footer>-->
|
||||
<!-- <el-button type="warning" v-show="studentForm.id > 0" @click="delStudent(1)">移出班级</el-button>-->
|
||||
<!-- <el-button type="danger" v-show="studentForm.id > 0 && studentForm.editoruserid == userStore.userId" @click="delStudent(2)">删除学生</el-button>-->
|
||||
<!-- <el-button @click="studentVisible = false">取 消</el-button>-->
|
||||
<!-- <el-button type="primary" @click="btnStudentSave">确 定</el-button>-->
|
||||
<!-- </template>-->
|
||||
</el-dialog>
|
||||
<!-- 学生导入-->
|
||||
<el-dialog title="学生导入" v-model="importVisiable" :width="600" append-to-body>
|
||||
|
@ -112,7 +112,7 @@
|
|||
|
||||
<script setup>
|
||||
import {addStudentmain, listClassuser,updateStudentmain,getClassmain,getStudentmain,leaveClass,removeStudentDataAll,addStudentmainByNameArray} from '@/api/classManage/index'
|
||||
import {ref, onMounted, reactive, nextTick, defineProps, watch} from 'vue'
|
||||
import {ref, onMounted, reactive, nextTick, watch} from 'vue'
|
||||
import {ElMessage,ElMessageBox} from "element-plus";
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import * as XLSX from 'xlsx'
|
||||
|
|
|
@ -0,0 +1,394 @@
|
|||
<!--
|
||||
* @Author: 苦逼程序猿
|
||||
* @Date: 2024-09-06 16:58:59
|
||||
* @Warning: 千行代码,Bug露锋芒。
|
||||
-->
|
||||
<template>
|
||||
<el-container class="class-reserv-wrap">
|
||||
<div class="class-reserv-tabs">
|
||||
<el-segmented v-model="tabActive" block :options="tabOptions" size="large" />
|
||||
</div>
|
||||
<div class="class-reserv-body">
|
||||
<task-item
|
||||
v-for="(item, index) in activeDataList"
|
||||
v-show="tabActive === '进行中'"
|
||||
:key="index"
|
||||
:item="item"
|
||||
:tabactive="tabActive"
|
||||
@click="itemDialogRef.openDialog(item)"
|
||||
@delete-reserv="deleteReserv(item)"
|
||||
></task-item>
|
||||
<task-item
|
||||
v-for="(item, index) in doneDataList"
|
||||
v-show="tabActive === '已结束'"
|
||||
:key="index"
|
||||
:item="item"
|
||||
:tabactive="tabActive"
|
||||
@click="itemDialogRef.openDialog(item)"
|
||||
@delete-reserv="deleteReserv(item)"
|
||||
></task-item>
|
||||
</div>
|
||||
<item-dialog ref="itemDialogRef"></item-dialog>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, computed, watch } from 'vue'
|
||||
import { getSelfReserv } from '@/api/classManage'
|
||||
import { listClassmain } from '@/api/classManage/index'
|
||||
import { listClassworkdata } from '@/api/classTask'
|
||||
import { homeworklist } from '@/api/teaching/classwork'
|
||||
|
||||
import TaskItem from '@/views/classTask/container/task-item.vue'
|
||||
import ItemDialog from '@/views/classTask/container/item-dialog.vue'
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import { sessionStore } from '@/utils/tool'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
const userStore = useUserStore().user
|
||||
const itemDialogRef = ref(null)
|
||||
const tabOptions = ref(['进行中', '已结束'])
|
||||
const tabActive = ref('进行中')
|
||||
const dataList = ref([])
|
||||
|
||||
// 班级列表
|
||||
const classList = ref([])
|
||||
const classListIds = ref([])
|
||||
// 所有班级作业列表
|
||||
const classWorkList = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
|
||||
const activeDataList = computed(() => {
|
||||
// return classWorkList.value
|
||||
// 当前时间超过[作业任务]截止时间的跳过
|
||||
return classWorkList.value && classWorkList.value.filter((item) => getDateTime > item.deaddate)
|
||||
})
|
||||
const deleteReserv = (item) => {
|
||||
console.log('删除待开发', item)
|
||||
// dataList.value = dataList.value.filter((is) => {
|
||||
// return is.id !== item.id
|
||||
// })
|
||||
}
|
||||
const doneDataList = computed(() => {
|
||||
// return classWorkList.value
|
||||
return classWorkList.value && classWorkList.value.filter((item) => getDateTime < item.deaddate)
|
||||
})
|
||||
|
||||
// 获取数据
|
||||
const getData = () => {
|
||||
// 获取班级列表
|
||||
listClassmain({ classuserid: userStore.userId, pageSize: 100, status: 'open' }).then((res) => {
|
||||
var clslist = []
|
||||
for (var i = 0; i < res.rows.length; i++) {
|
||||
if (res.rows[i].classstudentlist != '') {
|
||||
var array = JSON.parse('[' + res.rows[i].classstudentlist + ']')
|
||||
res.rows[i].classstudents = array
|
||||
}
|
||||
classListIds.value.push(res.rows[i].id)
|
||||
clslist.push(res.rows[i])
|
||||
}
|
||||
classList.value = clslist
|
||||
|
||||
// 班级作业数据,包含多个班级
|
||||
homeworklist({
|
||||
classidarray: classListIds.value.join(','),
|
||||
entpcourseid: '', // 章节id? 这里要全课程的作业 不分章节?
|
||||
orderby: 'uniquekey DESC',
|
||||
pageSize: 100
|
||||
}).then((response) => {
|
||||
for (var i = 0; i < response.rows.length; i++) {
|
||||
// 初始化部分新增字段值
|
||||
response.rows[i].workdatalist = []
|
||||
response.rows[i].workdatacount = 0 // 人数
|
||||
response.rows[i].workdatalistVisible = false
|
||||
response.rows[i].workdatafeedbackcount = 0
|
||||
response.rows[i].feedtimelength = 0
|
||||
response.rows[i].rightAnswerCount = 0
|
||||
response.rows[i].scoingRate = 0 + '%' // 得分率
|
||||
response.rows[i].averagetime = 0 // 平均用时
|
||||
|
||||
// ----------------------------------------------
|
||||
// 处理任务类型的UI
|
||||
if (response.rows[i].worktype == '学习目标定位') {
|
||||
response.rows[i].workclass = 'success'
|
||||
response.rows[i].workcodesList = JSON.parse(response.rows[i].workcodes)
|
||||
} else if (response.rows[i].worktype == '教材研读') {
|
||||
response.rows[i].workclass = 'primary'
|
||||
} else if (response.rows[i].worktype == '框架梳理') {
|
||||
response.rows[i].workclass = 'warning'
|
||||
} else if (response.rows[i].worktype == '学科定位') {
|
||||
response.rows[i].workclass = 'info'
|
||||
} else if (response.rows[i].worktype == '习题训练') {
|
||||
response.rows[i].workclass = 'danger'
|
||||
} else {
|
||||
response.rows[i].workclass = ''
|
||||
}
|
||||
// 如果是习题训练任务,则检查一共有多少道
|
||||
if (response.rows[i].entpcourseworklist != '') {
|
||||
response.rows[i].entpcourseworklistarray = JSON.parse(
|
||||
'[' + response.rows[i].entpcourseworklist + ']'
|
||||
)
|
||||
} else {
|
||||
response.rows[i].entpcourseworklistarray = []
|
||||
}
|
||||
// 根据 classworkdatastudentids 初始化判断分配的人数
|
||||
if (
|
||||
response.rows[i].classworkdatastudentids != '' &&
|
||||
response.rows[i].classworkdatastudentids != null &&
|
||||
response.rows[i].classworkdatastudentids != 'null'
|
||||
) {
|
||||
const stuList = JSON.parse('[' + response.rows[i].classworkdatastudentids + ']')
|
||||
response.rows[i].workdatacount = stuList.length
|
||||
}
|
||||
}
|
||||
|
||||
// 显示分配人数>0 的
|
||||
if (response.rows && response.rows.length > 0) {
|
||||
classWorkList.value =
|
||||
response.rows && response.rows.filter((item) => item.workdatacount > 0)
|
||||
//TODO: 这里没分页,貌似这个 total 不重要,后续看
|
||||
total.value = response.total
|
||||
}
|
||||
loading.value = false
|
||||
|
||||
// 再查找多个班级里,每个学生的作业数据
|
||||
getStudentClassWorkData()
|
||||
})
|
||||
})
|
||||
|
||||
//--------------
|
||||
// getSelfReserv().then((res) => {
|
||||
// const list = res.data || []
|
||||
// list.sort((a, b) => {
|
||||
// if (a.status == '上课中') return -1
|
||||
// else return 0
|
||||
// })
|
||||
// dataList.value = list
|
||||
// })
|
||||
}
|
||||
const toolStore = useToolState()
|
||||
|
||||
// 将标签中的双引号增加转义
|
||||
const escapeHtmlQuotes = (str) => {
|
||||
// 后端已replace双引号, 故前端不用在处理
|
||||
return str
|
||||
|
||||
// 只对双引号进行转义
|
||||
// return str.replace(/(<[^>]+>)/g, function (match) {
|
||||
// return match.replace(/"/g, '\\"')
|
||||
// })
|
||||
}
|
||||
const pollingST = ref(null) //轮询定时器标识
|
||||
onMounted(() => {
|
||||
getData() // 加载数据
|
||||
// 轮询查询
|
||||
pollingST.value = setInterval(() => {
|
||||
getStudentVisible()
|
||||
}, 1000 * 60)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(pollingST.value)
|
||||
//clearInterval(this.classWorkActiveData.timerId) // 关闭定时器 作业概况的
|
||||
})
|
||||
|
||||
const getDateTime = () => {
|
||||
//获取当前时间
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(now.getDate()).padStart(2, '0')
|
||||
const hh = String(now.getHours()).padStart(2, '0')
|
||||
const mm = String(now.getMinutes()).padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hh}:${mm}`
|
||||
}
|
||||
|
||||
// [作业反馈] - 实际查询逻辑
|
||||
const getStudentVisible = async () => {
|
||||
if (classListIds.value.length <= 0) {
|
||||
return
|
||||
}
|
||||
// 班级作业数据,多个班级
|
||||
const response = await homeworklist({
|
||||
classidarray: classListIds.value.join(','),
|
||||
entpcourseid: '', // 章节???这里不需要,全课程的
|
||||
orderby: 'uniquekey DESC',
|
||||
pageSize: 100
|
||||
})
|
||||
const curWorkList = response.rows
|
||||
|
||||
/**
|
||||
* warn: 这里仅更新了finishpercent(进度条), 且当前作业布置推送新任务时, curWorkList中会查到新的任务与当前页面中this.classWorkList长度不一致,
|
||||
* 故这里需循环this.classWorkList且只更新当前页面中的存在的任务进度
|
||||
*/
|
||||
for (let t = 0; t < classWorkList.value.length; t++) {
|
||||
// 当前时间超过[作业任务]截止时间的跳过
|
||||
// if( getDateTime > classWorkList.value[t].deaddate ){
|
||||
// continue;
|
||||
// }
|
||||
// 确保当前拿到的任务与页面中存在的任务能一对一(避免因删除其他操作而删除作业任务导致两个数组的index不统一而越界)
|
||||
let curWork = curWorkList.find((work) => work.id === classWorkList.value[t].id)
|
||||
// workdataresultcount 完成人数 workdatacount人数要大于0
|
||||
if (curWork && curWork.workdataresultcount > 0 && classWorkList.value[t].workdatacount > 0) {
|
||||
classWorkList.value[t].workdataresultcount = curWork.workdataresultcount
|
||||
// 桌面端貌似不需要进度条了?
|
||||
classWorkList.value[t].finishpercent = parseInt(
|
||||
(classWorkList.value[t].workdataresultcount / classWorkList.value[t].workdatacount) * 100
|
||||
)
|
||||
// 计算参与学习任务的平均用时
|
||||
console.log('平均用时??---', classWorkList.value[t].workdatafeedbackcount)
|
||||
if (classWorkList.value[t].workdatafeedbackcount > 0) {
|
||||
classWorkList.value[t].averagetime = (
|
||||
classWorkList.value[t].feedtimelength / classWorkList.value[t].workdatafeedbackcount
|
||||
).toFixed(0)
|
||||
console.log('平均用时---', classWorkList.value[t].averagetime)
|
||||
} else {
|
||||
classWorkList.value[t].averagetime = 0
|
||||
}
|
||||
} else {
|
||||
classWorkList.value[t].finishpercent = 0
|
||||
}
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
// 获取多个班级学生作业数据
|
||||
const getStudentClassWorkData = () => {
|
||||
// 再查找多个班级里,每个学生的作业数据
|
||||
console.log('======????????""""""""""')
|
||||
listClassworkdata({
|
||||
classids: classListIds.value.join(','),
|
||||
entpcourseid: '', // 章节id? 这里要全课程的作业 不分章节?
|
||||
pageSize: 1000
|
||||
}).then((res) => {
|
||||
console.log('多个班级里,每个学生的作业数据', res.rows)
|
||||
for (var t = 0; t < classWorkList.value.length; t++) {
|
||||
for (var i = 0; i < res.rows.length; i++) {
|
||||
if (res.rows[i].classworkid == classWorkList.value[t].id) {
|
||||
// if (res.rows[i].classworkid == classWorkList.value[t].id && res.rows[i].resultcount > 0) {
|
||||
console.log('==================')
|
||||
// 有几个学生完成/正在完成学习任务
|
||||
// 至少resultcount不是0
|
||||
classWorkList.value[t].workdatafeedbackcount++
|
||||
|
||||
// 在参与学习任务的人中,汇总计算用时
|
||||
classWorkList.value[t].feedtimelength += parseInt(res.rows[i].finishtimelength)
|
||||
|
||||
// 计算得分率
|
||||
if (
|
||||
res.rows[i].classworkevallist != '' &&
|
||||
res.rows[i].classworkevallist != null &&
|
||||
res.rows[i].classworkevallist != 'null'
|
||||
) {
|
||||
let replacedString = res.rows[i].classworkevallist.replace(/""/g, '"')
|
||||
// 将标签中双引号改为转义, 测试数据: "{\"id\":172907, \"rating\":0, \"teacherRating\":0, \"entpcourseworkid\":358520, \"feedcontent\":\"④①⑤③②\", \"score\":4, \"rightanswer\":\"④①⑤③②\"},{\"id\":172908, \"rating\":0, \"teacherRating\":0, \"entpcourseworkid\":358521, \"feedcontent\":\"气壮山威,鲲鹏展翅楚云飞\", \"score\":4, \"rightanswer\":\"志远天高,春风杨柳麓山青\"},{\"id\":172909, \"rating\":0, \"teacherRating\":0, \"entpcourseworkid\":363096, \"feedcontent\":\"《红烛》化用“蜡矩”这一古典意象,赋予它新的含义,赞美了红烛以“蜡炬成灰”来点亮世界的奉献精神。\", \"score\":4, \"rightanswer\":\"《立在地球边上放号》中,全诗采用间接抒情的方式,描绘了太平洋的浪潮,吟唱了一曲惊心动魄的力的颂歌,意在赞美摧毁旧世界、创造新生活的“五四”精神。\"},{\"id\":172910, \"rating\":0, \"teacherRating\":0, \"entpcourseworkid\":363098, \"feedcontent\":\"毛泽东重游橘子洲,面对如画的秋色和大好的革命形势,回忆过去战斗的岁月,不禁心潮起伏,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\", \"score\":4, \"rightanswer\":\"毛泽东重游橘子洲,面对如画的秋色和大好的革命形势,回忆过去战斗的岁月,不禁心潮起伏,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\"},{\"id\":172911, \"rating\":0, \"teacherRating\":0, \"entpcourseworkid\":363100, \"feedcontent\":\"毛泽东重游橘子洲,面对如画的秋色和大好的革命形势,回忆过去战斗的岁月,不禁心潮起伏,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\", \"score\":4, \"rightanswer\":\"毛泽东重游橘子洲,面对如画的秋色和大好的革命形势,回忆过去战斗的岁月,不禁心潮起伏,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\"}"
|
||||
replacedString = escapeHtmlQuotes(res.rows[i].classworkevallist).replace(
|
||||
/"(\[.*\])"/g,
|
||||
'$1'
|
||||
)
|
||||
replacedString = escapeHtmlQuotes(res.rows[i].classworkevallist)
|
||||
var evalarray
|
||||
try {
|
||||
evalarray = JSON.parse('[' + res.rows[i].classworkevallist + ']')
|
||||
} catch {
|
||||
evalarray = JSON.parse('[' + replacedString + ']')
|
||||
}
|
||||
|
||||
for (var e = 0; e < evalarray.length; e++) {
|
||||
if (res.rows[i].worktype == '常规作业') {
|
||||
evalarray[e].feedcontent = escapeHtmlQuotes(evalarray[e].feedcontent).replace(
|
||||
/"(\[.*\])"/g,
|
||||
'$1'
|
||||
)
|
||||
evalarray[e].feedcontent = escapeHtmlQuotes(evalarray[e].feedcontent)
|
||||
}
|
||||
if (evalarray[e].feedcontent == evalarray[e].rightanswer) {
|
||||
// 正确,得分
|
||||
classWorkList.value[t].rightAnswerCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 当前这个学习任务,共推送给了几个学生,workdatacount
|
||||
if (res.rows[i].classworkid == classWorkList.value[t].id) {
|
||||
classWorkList.value[t].workdatalist.push(res.rows[i])
|
||||
}
|
||||
}
|
||||
// 计算完成进度 workdatacount人数要大于0
|
||||
if (
|
||||
classWorkList.value[t].workdataresultcount > 0 &&
|
||||
classWorkList.value[t].workdatacount > 0
|
||||
) {
|
||||
classWorkList.value[t].finishpercent = parseInt(
|
||||
(classWorkList.value[t].workdataresultcount / classWorkList.value[t].workdatacount) * 100
|
||||
)
|
||||
} else {
|
||||
classWorkList.value[t].finishpercent = 0
|
||||
}
|
||||
|
||||
// 以下四个参数,都要计算
|
||||
// 2024-04-12,酉阳,by jackyshen
|
||||
|
||||
// 计算参与学习任务的平均用时
|
||||
if (classWorkList.value[t].workdatafeedbackcount > 0) {
|
||||
classWorkList.value[t].averagetime =
|
||||
(
|
||||
classWorkList.value[t].feedtimelength / classWorkList.value[t].workdatafeedbackcount
|
||||
).toFixed(0)
|
||||
} else {
|
||||
classWorkList.value[t].averagetime = 0
|
||||
}
|
||||
|
||||
// 计算批阅异常,需要获取每个题目的类型,找出主观题
|
||||
// 暂缓
|
||||
|
||||
// 计算平均得分率: 正确题数/(题目总数*学生人数)*100
|
||||
if (
|
||||
classWorkList.value[t].entpcourseworklistarray &&
|
||||
classWorkList.value[t].entpcourseworklistarray.length > 0
|
||||
) {
|
||||
var dd =
|
||||
(classWorkList.value[t].rightAnswerCount /
|
||||
(classWorkList.value[t].entpcourseworklistarray.length *
|
||||
classWorkList.value[t].workdatacount)) *
|
||||
100
|
||||
classWorkList.value[t].scoingRate = dd.toFixed(0) + '%'
|
||||
} else {
|
||||
classWorkList.value[t].scoingRate = '0%'
|
||||
}
|
||||
// 设定典型作答,需要获取每个题目的类型,找出主观题
|
||||
// 暂缓
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [dataList, toolStore.isToolWin],
|
||||
() => {
|
||||
console.log('====', toolStore)
|
||||
setTimeout(() => {
|
||||
getData() // 加载数据
|
||||
}, 300)
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.class-reserv-wrap {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 15px 30px;
|
||||
.class-reserv-tabs {
|
||||
width: 30%;
|
||||
text-align: left;
|
||||
}
|
||||
.class-reserv-body {
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 10px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,964 @@
|
|||
<template>
|
||||
<el-form ref="classWorkFormScoreRef" :model="classWorkFormScore">
|
||||
<div class="teacher_content" :style="{ height: dialogProps.maxheight + 'px' }">
|
||||
<div style="font-size: 18px; width: 100%; padding: 5px 10px" class="sticky">
|
||||
{{ classWorkFormScore.name }} 答题详情
|
||||
</div>
|
||||
<div class="teacher_content_con">
|
||||
<!-- 题目内容:习题训练 -->
|
||||
<div v-if="dialogProps.studentObj.worktype == '习题训练'">
|
||||
<div v-for="(stuItem, sIndex) in dialogProps.studentQuizAllList" :key="stuItem.id">
|
||||
<div v-for="quItem in dialogProps.quizlist" :key="quItem.id">
|
||||
<div v-if="stuItem.entpcourseworkid == quItem.id">
|
||||
<el-card style="max-width: 100%; margin-bottom: 10px">
|
||||
<!-- 题型 分值 -->
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span
|
||||
>{{ sIndex + 1 }}、{{ quItem.worktype }}
|
||||
{{ stuItem.score ? stuItem.score : 0 }}分</span
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 习题训练 -->
|
||||
<div v-if="dialogProps.studentObj.worktype == '习题训练'">
|
||||
<el-row>
|
||||
<el-col :span="24" style="padding: 10px">
|
||||
<!-- 题源、题目标题、题目选项 -->
|
||||
<span>{{ quItem.worktag }}</span>
|
||||
<span style="margin-left: 4px" v-html="quItem.titleFormat"></span>
|
||||
<div :span="24" style="padding: 10px" v-html="quItem.workdescFormat"></div>
|
||||
<!-- 折叠: 详情分析解答 -->
|
||||
<div class="demo-collapse">
|
||||
<el-collapse>
|
||||
<el-collapse-item title="详情分析解答" name="1">
|
||||
<el-row style="padding: 1% 4%; border: 2px dotted">
|
||||
<template #default="scope">
|
||||
<el-col :span="2" style="padding: 10px 0px"
|
||||
><em>【答案】</em></el-col
|
||||
>
|
||||
<el-col
|
||||
:span="21"
|
||||
style="padding: 10px 0px"
|
||||
v-html="quItem.workanswerFormat"
|
||||
></el-col>
|
||||
<el-col :span="2" style="padding: 10px 0px"
|
||||
><em>【分析】</em></el-col
|
||||
>
|
||||
<el-col
|
||||
:span="21"
|
||||
style="padding: 10px 0px"
|
||||
v-html="quItem.method"
|
||||
></el-col>
|
||||
<el-col :span="2" style="padding: 10px 0px"
|
||||
><em>【解答】</em></el-col
|
||||
>
|
||||
<el-col
|
||||
:span="21"
|
||||
style="padding: 10px 0px"
|
||||
v-html="quItem.analyse"
|
||||
></el-col>
|
||||
<el-col :span="2" style="padding: 10px 0px"
|
||||
><em>【点评】</em></el-col
|
||||
>
|
||||
<el-col
|
||||
:span="21"
|
||||
style="padding: 10px 0px"
|
||||
v-html="quItem.discuss"
|
||||
></el-col>
|
||||
</template>
|
||||
</el-row>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<!-- 答案 -->
|
||||
<template #footer>
|
||||
<el-row>
|
||||
<el-col :span="6" style="padding: 10px">
|
||||
<span
|
||||
>参考答案:
|
||||
<span v-if="quItem.workanswerFormat != ''">
|
||||
<sapn
|
||||
style="
|
||||
background-color: #0ed116;
|
||||
color: white;
|
||||
padding: 0 5px;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>{{ quItem.workanswerFormat.replace(/<[^>]+>/g, '') }}</sapn
|
||||
>
|
||||
</span>
|
||||
</span>
|
||||
</el-col>
|
||||
<el-col :span="6" style="padding: 10px">
|
||||
<!-- <span>学生答案:{{ stuItem.feedcontent }}</span> -->
|
||||
<span
|
||||
>学生答案:
|
||||
<span v-if="quItem.workdesc == ''">
|
||||
<span
|
||||
v-if="stuItem.feedcontent != ''"
|
||||
style="
|
||||
background-color: red;
|
||||
color: white;
|
||||
padding: 0 5px;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
{{ stuItem.feedcontent.replace('#', '、') }}
|
||||
</span>
|
||||
</span>
|
||||
<span v-else>
|
||||
<span
|
||||
v-if="stuItem.feedcontent != ''"
|
||||
style="
|
||||
background-color: red;
|
||||
color: white;
|
||||
padding: 0 5px;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
{{
|
||||
JSON.parse(quItem.workdesc)
|
||||
.map((item, index) => {
|
||||
if (item == stuItem.feedcontent) {
|
||||
return String.fromCharCode(65 + Number(index))
|
||||
}
|
||||
})
|
||||
.filter(Boolean)[0]
|
||||
}}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</el-col>
|
||||
<el-col :span="6" style="padding: 10px">
|
||||
<div
|
||||
v-for="(imageItem, index) in stuItem.imagefile"
|
||||
v-if="stuItem.imagefile && stuItem.imagefile.length > 0"
|
||||
:key="index"
|
||||
>
|
||||
<el-image
|
||||
style="width: 30px; height: 30px"
|
||||
:src="imageItem"
|
||||
:zoom-rate="1.2"
|
||||
:max-scale="7"
|
||||
:min-scale="0.2"
|
||||
:preview-src-list="stuItem.imagefile"
|
||||
:initial-index="4"
|
||||
/>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="6" style="padding: 10px">
|
||||
<!-- 单选题 填空题 多选题 判断题 主观题 复合题; 待完善:
|
||||
1、目前只支持单选题、多选题不用老师批改分数,这里先禁止分值修改; -->
|
||||
<el-input-number
|
||||
v-model="classWorkFormScore.teacherRating[sIndex].score"
|
||||
:min="0"
|
||||
:max="classWorkFormScore.teacherRating[sIndex].maxScore"
|
||||
size="small"
|
||||
:disabled="
|
||||
(quItem.worktype == '单选题' || quItem.worktype == '多选题') &&
|
||||
stuItem.feedcontent == stuItem.rightanswer &&
|
||||
stuItem.feedcontent != ''
|
||||
? true
|
||||
: false
|
||||
"
|
||||
></el-input-number>
|
||||
分
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 题目内容:常规作业、课堂展示 -->
|
||||
<div
|
||||
v-if="
|
||||
dialogProps.studentObj.worktype == '常规作业' ||
|
||||
dialogProps.studentObj.worktype == '课堂展示' ||
|
||||
dialogProps.studentObj.worktype == '框架梳理'
|
||||
"
|
||||
>
|
||||
<div v-for="(stuItem, sIndex) in dialogProps.studentQuizAllList" :key="stuItem.id">
|
||||
<el-card style="max-width: 100%; margin-bottom: 10px">
|
||||
<!-- 题型 分值 -->
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>{{ sIndex + 1 }}、{{ stuItem.score ? stuItem.score : 0 }}分</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 常规作业 -->
|
||||
<div
|
||||
v-if="
|
||||
dialogProps.studentObj.worktype == '常规作业' ||
|
||||
dialogProps.studentObj.worktype == '课堂展示' ||
|
||||
dialogProps.studentObj.worktype == '框架梳理'
|
||||
"
|
||||
>
|
||||
<!-- 文件内容格式:mp3/mp4/doc/docx/excel/pdf/ppt/pptx/jpg/jpeg/gif/png/txt ->
|
||||
<-- 老师附件展示 -->
|
||||
<!-- 折叠: 详情分析解答 -->
|
||||
<div v-if="teacherFeedContentList.length > 0">
|
||||
<div class="demo-collapse" style="border: 2px dotted">
|
||||
<el-collapse>
|
||||
<el-collapse-item title="老师布置详情" name="1">
|
||||
<div class="image_list">
|
||||
<div v-if="teachImageList.length > 0">
|
||||
<div style="margin-bottom: 5px">
|
||||
<span style="color: red">温馨提示:点击图片可放大预览 </span>
|
||||
</div>
|
||||
<div v-for="(imageItem, index) in teachImageList" :key="index">
|
||||
<el-image
|
||||
style="width: 400px; height: 400px"
|
||||
:src="imageItem.url"
|
||||
:zoom-rate="1.2"
|
||||
:max-scale="7"
|
||||
:min-scale="0.2"
|
||||
:preview-src-list="
|
||||
teachImageList
|
||||
.filter(
|
||||
(item) =>
|
||||
item.name.indexOf('jpg') > -1 ||
|
||||
item.name.indexOf('jpeg') > -1 ||
|
||||
item.name.indexOf('png') > -1
|
||||
)
|
||||
.map((item) => item.url)
|
||||
"
|
||||
:initial-index="4"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="teachFileList.length > 0">
|
||||
<div style="margin: 10px 0">
|
||||
<span style="color: red" @click="openFile"
|
||||
>温馨提示:点击此处 可预览其他类型附件!
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 学生答题展示 -->
|
||||
<div v-if="feedContentList.length > 0">
|
||||
<p>学生答题附件内容</p>
|
||||
<div class="image_list">
|
||||
<div v-if="imageList.length > 0">
|
||||
<div style="margin-bottom: 5px">
|
||||
<span style="color: red">温馨提示:点击图片可放大预览 </span>
|
||||
</div>
|
||||
<div v-for="(imageItem, index) in imageList" :key="index">
|
||||
<el-image
|
||||
style="width: 500px; height: 500px"
|
||||
:src="imageItem.url"
|
||||
:zoom-rate="1.2"
|
||||
:max-scale="7"
|
||||
:min-scale="0.2"
|
||||
:preview-src-list="
|
||||
imageList
|
||||
.filter(
|
||||
(item) =>
|
||||
item.name.indexOf('jpg') > -1 ||
|
||||
item.name.indexOf('jpeg') > -1 ||
|
||||
item.name.indexOf('png') > -1
|
||||
)
|
||||
.map((item) => item.url)
|
||||
"
|
||||
:initial-index="4"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="fileList.length > 0">
|
||||
<div style="margin: 10px 0">
|
||||
<span style="color: red" @click="openFile"
|
||||
>温馨提示:点击此处 可预览其他类型附件!
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-empty
|
||||
description="该学生还未作答"
|
||||
style="width: 100%; height: 200px"
|
||||
></el-empty>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 答案 -->
|
||||
<!-- <template #footer>
|
||||
<el-row>
|
||||
<el-col :span="12" style="padding: 10px">
|
||||
<el-input-number v-model="classWorkFormScore.teacherRating[sIndex].score"
|
||||
:controls="false"
|
||||
:min="0"
|
||||
:max="classWorkFormScore.teacherRating[sIndex].maxScore"
|
||||
size="small"
|
||||
></el-input-number> 分
|
||||
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template> -->
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 批改评价与评语 -->
|
||||
<div class="tacher_conten_foot">
|
||||
<el-row style="padding: 1% 4%; border: 2px dotted">
|
||||
<el-col :span="24" style="display: flex; flex-direction: column">
|
||||
<el-row>
|
||||
<el-col :span="14">
|
||||
<div style="display: flex; margin: 10px auto">
|
||||
<span style="display: flex; align-items: center">
|
||||
<span v-if="dialogProps.studentObj.worktype == '习题训练'">
|
||||
得分:<span style="margin: 0; color: red">{{
|
||||
classWorkFormScore.teacherRating.reduce((a, b) => a + b.score, 0).toFixed(2)
|
||||
}}</span
|
||||
>分
|
||||
</span>
|
||||
<span v-else>
|
||||
得分:
|
||||
<span v-if="classWorkFormScore.teacherRating.length > 0">
|
||||
<el-input-number
|
||||
v-model="classWorkFormScore.teacherRating[0].score"
|
||||
:controls="false"
|
||||
type="number"
|
||||
:min="0"
|
||||
:max="classWorkFormScore.teacherRating[0].maxScore"
|
||||
size="small"
|
||||
style="width: 60px"
|
||||
@change="handleChange"
|
||||
></el-input-number>
|
||||
</span>
|
||||
分
|
||||
</span>
|
||||
</span>
|
||||
<div class="score-container">
|
||||
<div
|
||||
v-for="(score, index) in teacherRatingList"
|
||||
:key="index"
|
||||
:class="[
|
||||
'score-circle',
|
||||
{ active: classWorkFormScore.rating == score.ratingKey }
|
||||
]"
|
||||
@click="selectScore(score)"
|
||||
>
|
||||
{{ score.ratingValue }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="10" style="display: flex; align-items: center">
|
||||
<el-select
|
||||
v-model="value"
|
||||
placeholder="常用评语"
|
||||
style="width: 240px"
|
||||
@change="onSelectOption"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in cities"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
<template #footer>
|
||||
<el-button v-if="!isAdding" text bg size="small" @click="onAddOption">
|
||||
新增常用语
|
||||
</el-button>
|
||||
<template v-else>
|
||||
<el-input
|
||||
v-model="optionName"
|
||||
class="option-input"
|
||||
placeholder="输入新的常用语"
|
||||
size="small"
|
||||
/>
|
||||
<el-button type="primary" size="small" @click="onConfirm"> 确定 </el-button>
|
||||
<el-button size="small" @click="clear">取消</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<el-col :span="24" style="display: flex; flex-direction: column">
|
||||
<el-form-item label="评语说明">
|
||||
<el-col :span="15" style="padding: 0px">
|
||||
<el-input
|
||||
v-model="classWorkFormScore.teacherremark"
|
||||
type="textarea"
|
||||
rows="3"
|
||||
placeholder="请输入评语说明"
|
||||
/>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div style="margin: 10px">
|
||||
<el-button type="primary" @click="onClassWorkFormScoreSave">批阅确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="fileReadopen"
|
||||
title="文件预览"
|
||||
width="80%"
|
||||
:style="{ height: dialogProps.maxheight + 'px' }"
|
||||
append-to-body
|
||||
>
|
||||
<div class="file-read-dialog">
|
||||
<div>
|
||||
<!-- 老师附件 -->
|
||||
<div v-if="teachFileList.length > 0">
|
||||
<el-card style="max-width: 480px">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>老师文件列表</span>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-for="item in teachFileList"
|
||||
:key="item"
|
||||
style="margin: 10px; display: flex; align-items: center"
|
||||
>
|
||||
<span style="margin-right: 10px">{{ item.name }}</span>
|
||||
<el-button type="primary" @click="onFileRead(item)">预览</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
<!-- 学生附件 -->
|
||||
<div v-if="fileList.length > 0">
|
||||
<el-card style="max-width: 480px">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>学生文件列表</span>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-for="item in fileList"
|
||||
:key="item"
|
||||
style="margin: 10px; display: flex; align-items: center"
|
||||
>
|
||||
<span style="margin-right: 10px">{{ item.name }}</span>
|
||||
<el-button type="primary" @click="onFileRead(item)">预览</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 100%" :style="{ height: dialogProps.maxheight + 'px' }">
|
||||
<div style="margin-left: 10px">
|
||||
预览展示区域<span style="color: red; margin-left: 10px">
|
||||
温馨提示:若预览失败,<span style="margin-left: 10px">{{ props.name }}</span
|
||||
>可点击此处<a
|
||||
:href="fileitem.url ? fileitem.url : ''"
|
||||
target="_blank"
|
||||
style="color: blue"
|
||||
>下载!</a
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
<!-- <ReFilePreview
|
||||
:name="fileitem.name"
|
||||
:type="fileitem.type"
|
||||
:file-type="fileitem.type"
|
||||
:file-path="fileitem.url"
|
||||
:text-content="textContent"
|
||||
/> -->
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script setup name="classWorkAnalysisScoreDialogRef">
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
// import useAppStore from '@/store/modules/app'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { ref, reactive } from 'vue'
|
||||
// import { Plus } from '@element-plus/icons-vue'
|
||||
import { ElMessageBox, ElMessage } from 'element-plus'
|
||||
import { updateClassworkeval } from '@/api/classTask'
|
||||
import { getTimeDate } from '@/utils/date'
|
||||
// import ReFilePreview from '@/components/ReFilePreview/index.vue'
|
||||
|
||||
// import mammoth from 'mammoth'
|
||||
// import * as XLSX from 'xlsx'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const emits = defineEmits(['class_work_score_submit'])
|
||||
const props = defineProps({})
|
||||
|
||||
const fileReadopen = ref(false)
|
||||
const analysisScoreOpen = ref(false)
|
||||
|
||||
const dialogProps = ref({
|
||||
maxheight: 300,
|
||||
studentObj: {}, //
|
||||
studentQuizAllList: [], //学生答题的list
|
||||
quizlist: [] // 当前学生的所有题目list
|
||||
})
|
||||
//学生常规作业list
|
||||
const feedContentList = ref([])
|
||||
const imageList = ref([])
|
||||
const fileList = ref([])
|
||||
// 老师常规作业、课堂展示布置题目附件list
|
||||
const teacherFeedContentList = ref([])
|
||||
const teachImageList = ref([])
|
||||
const teachFileList = ref([])
|
||||
|
||||
// 提交分值批改
|
||||
const classWorkFormScore = reactive({
|
||||
name: '', // 学生姓名
|
||||
score: 0, // 分值
|
||||
teacherRating: [], // 老师批改题目list信息
|
||||
rating: 0, // 评价星数 1-优 2-优减 3-良 4-良减 5-差
|
||||
teacherremark: '' //评分说明
|
||||
})
|
||||
const teacherRatingList = ref([
|
||||
{ ratingKey: '1', ratingValue: '优' },
|
||||
{ ratingKey: '2', ratingValue: '优-' },
|
||||
{ ratingKey: '3', ratingValue: '良' },
|
||||
{ ratingKey: '4', ratingValue: '良-' },
|
||||
{ ratingKey: '5', ratingValue: '差' }
|
||||
])
|
||||
// 确定的线上图片数据
|
||||
//#region 文件内容相关
|
||||
const fileitem = reactive({
|
||||
name: '',
|
||||
type: '',
|
||||
url: ''
|
||||
})
|
||||
// 文件预览
|
||||
const onFileRead = (file) => {
|
||||
textContent.value = '1'
|
||||
//
|
||||
fileitem.type = file.name.split('.').pop().toLowerCase()
|
||||
fileitem.url = file.url
|
||||
fileitem.name = file.name
|
||||
|
||||
// txt 读取
|
||||
if (fileitem.type == 'txt') {
|
||||
loadFileTextContent(fileitem.url)
|
||||
}
|
||||
}
|
||||
const openFile = () => {
|
||||
console.log('打开文件弹窗!')
|
||||
fileReadopen.value = true
|
||||
}
|
||||
// txt文件读取
|
||||
const textContent = ref('')
|
||||
const loadFileTextContent = async (url) => {
|
||||
try {
|
||||
const response = await fetch(url)
|
||||
if (!response.ok) {
|
||||
textContent.value = '文件读取失败,您可以点击上方链接跳到另外页面查看'
|
||||
throw new Error('文件读取失败')
|
||||
}
|
||||
textContent.value = await response.text()
|
||||
} catch (error) {
|
||||
console.error('读取文件时出错:', error)
|
||||
textContent.value = '文件读取失败,您可以点击上方链接跳到另外页面查看'
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
// 输入数字,有e这个异类可输入,处理一下
|
||||
// 输入e value为null
|
||||
const handleChange = (value) => {
|
||||
console.log(value, '=====')
|
||||
console.log(typeof value, '===value==')
|
||||
// if ((value+"").includes('e')) {
|
||||
// classWorkFormScore.teacherRating[0].score = value.replace('e', '');
|
||||
// }
|
||||
if (typeof value === 'object') {
|
||||
console.log('??????')
|
||||
classWorkFormScore.teacherRating[0].score = 0
|
||||
} else {
|
||||
classWorkFormScore.teacherRating[0].score = value
|
||||
}
|
||||
}
|
||||
|
||||
//#region 常用评语相关
|
||||
const isAdding = ref(false)
|
||||
const value = ref([])
|
||||
const optionName = ref('')
|
||||
const cities = ref([
|
||||
{
|
||||
value: '需要继续加油努力哟!棒棒哒!',
|
||||
label: '需要继续加油努力哟!棒棒哒!'
|
||||
},
|
||||
{
|
||||
value: '做得很好',
|
||||
label: '做得很好'
|
||||
},
|
||||
{
|
||||
value: '需要改进',
|
||||
label: '需要改进'
|
||||
},
|
||||
{
|
||||
value: '需要更多练习',
|
||||
label: '需要更多练习'
|
||||
},
|
||||
{
|
||||
value: '需要更仔细',
|
||||
label: '需要更仔细'
|
||||
},
|
||||
{
|
||||
value: '需要更清晰',
|
||||
label: '需要更清晰'
|
||||
},
|
||||
{
|
||||
value: '需要更准确',
|
||||
label: '需要更准确'
|
||||
},
|
||||
{
|
||||
value: '需要更详细',
|
||||
label: '需要更详细'
|
||||
},
|
||||
{
|
||||
value: '需要更简洁',
|
||||
label: '需要更简洁'
|
||||
},
|
||||
{
|
||||
value: '需要更有条理',
|
||||
label: '需要更有条理'
|
||||
},
|
||||
{
|
||||
value: '需要更有创意',
|
||||
label: '需要更有创意'
|
||||
}
|
||||
])
|
||||
|
||||
const onSelectOption = (option) => {
|
||||
classWorkFormScore.teacherremark = option
|
||||
}
|
||||
const onAddOption = () => {
|
||||
isAdding.value = true
|
||||
}
|
||||
|
||||
const onConfirm = () => {
|
||||
if (optionName.value) {
|
||||
cities.value.push({
|
||||
label: optionName.value,
|
||||
value: optionName.value
|
||||
})
|
||||
clear()
|
||||
}
|
||||
}
|
||||
|
||||
const clear = () => {
|
||||
optionName.value = ''
|
||||
isAdding.value = false
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const selectScore = (score) => {
|
||||
console.log(score, 'score----')
|
||||
classWorkFormScore.rating = score.ratingKey
|
||||
}
|
||||
|
||||
// 接收父组件传过来的参数
|
||||
const acceptParams = (params) => {
|
||||
console.log(params)
|
||||
console.log(dialogProps, 'dialogProps')
|
||||
// 先重置一下 参数
|
||||
// 重置提交表单
|
||||
classWorkFormScore.name = '' // 学生姓名
|
||||
classWorkFormScore.score = 0 // 分值
|
||||
classWorkFormScore.teacherRating = [] // 教师评分
|
||||
classWorkFormScore.rating = 0 // 评价星数 1-优 2-优减 3-良 4-良减 5-差
|
||||
classWorkFormScore.teacherremark = '' //评分说明
|
||||
value.value = '' // 常用语重置
|
||||
// 学生作业预览缓存清除
|
||||
feedContentList.value = []
|
||||
imageList.value = []
|
||||
fileList.value = []
|
||||
// 老师布置附件缓存清除
|
||||
teacherFeedContentList.value = []
|
||||
teachImageList.value = []
|
||||
teachFileList.value = []
|
||||
|
||||
// -----------------
|
||||
dialogProps.value = params
|
||||
classWorkFormScore.name = params.studentObj.studentname
|
||||
|
||||
// 学生答题分值初始化
|
||||
if (params.studentQuizAllList.length > 0) {
|
||||
if (params.studentObj.worktype == '习题训练') {
|
||||
params.studentQuizAllList.forEach((item) => {
|
||||
params.quizlist.forEach((item2) => {
|
||||
//
|
||||
if (item.entpcourseworkid == item2.id) {
|
||||
// 单选题 填空题 多选题 判断题 主观题 复合题; 待完善:
|
||||
classWorkFormScore.teacherRating.push({
|
||||
maxScore: item.score ? item.score : 100, //分值最大值 不能大于题目的分值 ?没有,那就最大100
|
||||
score:
|
||||
(item2.worktype == '单选题' || item2.worktype == '多选题') &&
|
||||
item.feedcontent == item.rightanswer
|
||||
? item.score
|
||||
: item.teacherRating
|
||||
? item.teacherRating
|
||||
: 0, // 教师批改分值: 单选多选 默认批改为题目分值
|
||||
id: item.id // 学生答题列表的id
|
||||
})
|
||||
classWorkFormScore.teacherremark = item.teacherremark // 评价语
|
||||
|
||||
// 主观题中学生回答有图片?imagefile: “” ; “[null]”; "[\"https://wzyzoss.ee2f687.png\"]"
|
||||
if (item.imagefile != '') {
|
||||
// 其他: !主观题 为“”;
|
||||
const filelist = JSON.parse(item.imagefile)
|
||||
console.log(filelist, '学生习题附带图片fimagefile-------------')
|
||||
|
||||
if (filelist && filelist.length > 0 && filelist[0] != null) {
|
||||
item.imagefile = filelist
|
||||
} else {
|
||||
item.imagefile = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// 学生回答
|
||||
if (params.studentObj.worktype == '常规作业') {
|
||||
try {
|
||||
// 老师布置的附件 datacontent TODO:常规作业、其他类型还未接入
|
||||
if (params.studentObj.datacontent != '') {
|
||||
const teachWorkFileList = JSON.parse(params.studentObj.datacontent)
|
||||
console.log(teachWorkFileList, '老师filelist-------------')
|
||||
teachWorkFileList &&
|
||||
teachWorkFileList.forEach((item) => {
|
||||
if (
|
||||
item.name.indexOf('jpg') > -1 ||
|
||||
item.name.indexOf('jpeg') > -1 ||
|
||||
item.name.indexOf('png') > -1
|
||||
) {
|
||||
teachImageList.value.push(item)
|
||||
} else {
|
||||
teachFileList.value.push(item)
|
||||
}
|
||||
})
|
||||
teacherFeedContentList.value.push(teachWorkFileList)
|
||||
}
|
||||
|
||||
dialogProps.value.studentObj.datacontent = dialogProps.value.studentObj.datacontent
|
||||
} catch (error) {
|
||||
console.error('Invalid JSON:', error)
|
||||
}
|
||||
|
||||
params.studentQuizAllList.forEach((item) => {
|
||||
classWorkFormScore.teacherRating.push({
|
||||
maxScore: item.score ? item.score : 100, //分值最大值 不能大于题目的分值 ?没有,那就最大100
|
||||
score: item.teacherRating, // 教师批改分值: 默认批改为题目分值
|
||||
id: item.id // 学生答题列表的id
|
||||
})
|
||||
classWorkFormScore.teacherremark = item.teacherremark // 评价语
|
||||
|
||||
if (item.feedcontent != '') {
|
||||
const filelist = JSON.parse(item.feedcontent)
|
||||
console.log(filelist, '学生filelist-------------')
|
||||
// 学生答题的内容 ? feedcontent应该只包含了一个数组?
|
||||
filelist &&
|
||||
filelist.forEach((item) => {
|
||||
if (
|
||||
item.name.indexOf('jpg') > -1 ||
|
||||
item.name.indexOf('jpeg') > -1 ||
|
||||
item.name.indexOf('png') > -1
|
||||
) {
|
||||
imageList.value.push(item)
|
||||
} else {
|
||||
fileList.value.push(item)
|
||||
}
|
||||
})
|
||||
feedContentList.value.push(filelist)
|
||||
}
|
||||
})
|
||||
} else if (
|
||||
params.studentObj.worktype == '课堂展示' ||
|
||||
params.studentObj.worktype == '框架梳理'
|
||||
) {
|
||||
params.studentQuizAllList.forEach((item) => {
|
||||
classWorkFormScore.teacherRating.push({
|
||||
maxScore: item.score ? item.score : 100, //分值最大值 不能大于题目的分值 ?没有,那就最大100
|
||||
score: item.teacherRating, // 教师批改分值: 默认批改为题目分值
|
||||
id: item.id // 学生答题列表的id
|
||||
})
|
||||
classWorkFormScore.teacherremark = item.teacherremark // 评价语
|
||||
// 根据移动端返回定义:只返回一张图片:rightanswer:"https://wzyzoss.eos-chongqing-3.cmecloud.cn/2024/9/5/c5d8e00a93364dd3b975f669afa217f9.png"
|
||||
// 这里只有一张图片;
|
||||
console.log(item.rightanswer, '----------课堂展示学生答题------------------')
|
||||
|
||||
if (item.rightanswer != '' && item.rightanswer != null) {
|
||||
if (
|
||||
item.rightanswer.indexOf('jpg') > -1 ||
|
||||
item.rightanswer.indexOf('jpeg') > -1 ||
|
||||
item.rightanswer.indexOf('png') > -1
|
||||
) {
|
||||
const imgeobj = {
|
||||
name: item.rightanswer,
|
||||
url: item.rightanswer
|
||||
}
|
||||
// 放入图片list
|
||||
imageList.value.push(imgeobj)
|
||||
// 没其他附件类型
|
||||
//fileList.value.push(?);
|
||||
feedContentList.value.push(imgeobj)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 其他类型待联调
|
||||
}
|
||||
}
|
||||
|
||||
// 老师批过优良,则默认批改的优良,不然就是默认的0
|
||||
console.log(params.studentQuizAllList[0].rating, '----------------------------')
|
||||
// 为null 或0 则默认为0
|
||||
classWorkFormScore.rating =
|
||||
params.studentQuizAllList[0].rating == 0 ? 0 : params.studentQuizAllList[0].rating
|
||||
}
|
||||
|
||||
analysisScoreOpen.value = true
|
||||
}
|
||||
|
||||
// 提交批改评分
|
||||
const onClassWorkFormScoreSave = () => {
|
||||
console.log(classWorkFormScore)
|
||||
// rating评价 不为0 则批改过
|
||||
if (dialogProps.value.studentQuizAllList && dialogProps.value.studentQuizAllList[0].rating != 0) {
|
||||
ElMessageBox.confirm(`该学生已批改,再次批改会覆盖之前的评分!`, '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
draggable: true
|
||||
})
|
||||
.then(() => {
|
||||
onSubmit()
|
||||
})
|
||||
.catch(() => {})
|
||||
} else {
|
||||
onSubmit()
|
||||
}
|
||||
}
|
||||
const onSubmit = () => {
|
||||
if (classWorkFormScore.rating == 0) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '请您给学生一个评价吧!'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
classWorkFormScore.teacherRating &&
|
||||
classWorkFormScore.teacherRating.map((item, index) => {
|
||||
const queryParams = {
|
||||
id: item.id,
|
||||
teacherRating: item.score, // 教师评分
|
||||
rating: classWorkFormScore.rating, // 评价
|
||||
teacherremark: classWorkFormScore.teacherremark, //评分说明
|
||||
timestamp: getTimeDate() // 时间
|
||||
}
|
||||
console.log(queryParams)
|
||||
updateClassworkeval(queryParams).then((res) => {
|
||||
// if(res.code == 200){
|
||||
// 循环提交能干个啥
|
||||
// }
|
||||
})
|
||||
})
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '提交成功!'
|
||||
})
|
||||
analysisScoreOpen.value = false
|
||||
// 清空答题清空右侧 题目列表
|
||||
emits('class_work_score_submit')
|
||||
}
|
||||
|
||||
// 初始化请求
|
||||
// onMounted(() => {})
|
||||
|
||||
// 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)
|
||||
defineExpose({
|
||||
acceptParams
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.teacher_content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.teacher_content_con {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.tacher_conten_foot {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.image_list {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
flex-direction: column;
|
||||
/* justify-content: space-evenly; */
|
||||
}
|
||||
/* .el-dialog__body{
|
||||
padding: 0!important;
|
||||
height: 100%;
|
||||
} */
|
||||
.file-read-dialog {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.score-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
/* margin-bottom: 20px; */
|
||||
}
|
||||
|
||||
.score-circle {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
background-color: pink;
|
||||
color: red;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
margin: 0 10px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.score-circle.active {
|
||||
background-color: red;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,616 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
v-model="classWorkAnalysis.open"
|
||||
:modal-append-to-body="false"
|
||||
class="clwk_dialog"
|
||||
style="width: 90%; height: 85%"
|
||||
:show-close="false"
|
||||
top="8vh"
|
||||
append-to-body
|
||||
destory-on-close
|
||||
>
|
||||
<template #title>
|
||||
<div style="font-size: 18px; display: flex; flex-wrap: nowrap">
|
||||
<div style="flex: 1">
|
||||
{{ classWorkAnalysis.title }}答题情况
|
||||
<el-tag :type="classWorkAnalysis.workclass" size="large" style="height: 25px">{{
|
||||
classWorkAnalysis.worktype
|
||||
}}</el-tag>
|
||||
</div>
|
||||
<!-- classWorkAnalysis.entpcourseworklistarray 当前学习任务所包含的试题ID -->
|
||||
<el-row
|
||||
v-if="classWorkAnalysis.entpcourseworklistarray.length > 0"
|
||||
style="margin: 0 auto; flex: 1"
|
||||
>
|
||||
<el-button-group style="margin-bottom: 10px">
|
||||
<el-button
|
||||
:type="classWorkAnalysis.view == 'studentview' ? 'success' : ''"
|
||||
@click="classWorkAnalysis.view = 'studentview'"
|
||||
>作业批阅</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="classWorkAnalysis.row.worktype == '习题训练'"
|
||||
:type="classWorkAnalysis.view == 'quizStats' ? 'success' : ''"
|
||||
@click="workHandle('quizStats')"
|
||||
>作业概况</el-button
|
||||
>
|
||||
<el-button
|
||||
v-if="classWorkAnalysis.row.worktype == '习题训练'"
|
||||
:type="classWorkAnalysis.view == 'report' ? 'success' : ''"
|
||||
@click="handleClassOverviewOpen('report')"
|
||||
>作业报告</el-button
|
||||
>
|
||||
</el-button-group>
|
||||
</el-row>
|
||||
<div style="flex: 1">
|
||||
<div
|
||||
style="float: right; padding: 0 10px; cursor: pointer"
|
||||
icon="el-icon-close"
|
||||
@click="classWorkAnalysis.open = false"
|
||||
>
|
||||
x
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 如果当前学习没有试题 -->
|
||||
<div
|
||||
v-if="classWorkAnalysis.view == 'studentview'"
|
||||
style="width: 100%"
|
||||
class="clwk_dialog_view"
|
||||
:height="mainHeight"
|
||||
>
|
||||
<div class="view_table">
|
||||
<el-radio-group
|
||||
v-model="tableRadio.value"
|
||||
style="margin-bottom: 10px"
|
||||
@change="tableRadioChange"
|
||||
>
|
||||
<el-radio-button :value="1" :label="'已交' + '(' + tableRadio.num1 + ')'" />
|
||||
<el-radio-button :value="0" :label="'未交' + '(' + tableRadio.num0 + ')'" />
|
||||
</el-radio-group>
|
||||
<!-- 学生列表:classWorkAnalysis.classworkdata; 已交未交:tableRadio.list -->
|
||||
<el-table
|
||||
v-loading="loading_dt_table"
|
||||
:data="tableRadio.list"
|
||||
row-key="id"
|
||||
highlight-current-row
|
||||
@row-click="getStudentClassWorkDataDetail"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="52" reserve-selection align="center" />
|
||||
<el-table-column label="姓名" prop="studentname" width="100" align="center" />
|
||||
<el-table-column label="提交时间" prop="updatedate" width="170" align="center" />
|
||||
<el-table-column label="批阅状态" prop="teacherRating" align="center" width="120" sortable>
|
||||
<template #default="scope">
|
||||
<template v-if="scope.row.teacherRating == 0"
|
||||
><span style="color: #2196f3">待批阅</span></template
|
||||
>
|
||||
<!-- 1-优 2-优减 3-良 4-良减 5-差 -->
|
||||
<template v-if="scope.row.teacherRating == 1"
|
||||
><el-tag type="danger">优</el-tag></template
|
||||
>
|
||||
<template v-if="scope.row.teacherRating == 2"
|
||||
><el-tag type="danger">优-</el-tag></template
|
||||
>
|
||||
<template v-if="scope.row.teacherRating == 3"
|
||||
><el-tag type="warning">良</el-tag></template
|
||||
>
|
||||
<template v-if="scope.row.teacherRating == 4"
|
||||
><el-tag type="info">良-</el-tag></template
|
||||
>
|
||||
<template v-if="scope.row.teacherRating == 5"
|
||||
><el-tag type="info">差</el-tag></template
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="view_teachrting">
|
||||
<div class="classwork-score">
|
||||
<div v-if="classWorkAnalysis.activeStudentQuizlist.length == 0">
|
||||
<el-empty
|
||||
description="点击左侧表格学生信息可查看批阅详情"
|
||||
style="width: 100%; height: 500px"
|
||||
></el-empty>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div v-if="isopen_dtwk_table">
|
||||
<div v-show="classWorkAnalysis.activeStudentQuizlist.length > 0">
|
||||
<item-dialog-score
|
||||
ref="classWorkAnalysisScoreDialogRef"
|
||||
@class_work_score_submit="onClassWorkScoreSubmit"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-empty
|
||||
description="点击左侧表格学生信息可查看批阅详情"
|
||||
style="width: 100%; height: 500px"
|
||||
></el-empty>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 作业概况 -->
|
||||
<div v-else-if="classWorkAnalysis.view == 'quizStats'">
|
||||
<!-- <quiz-stats :active-data="classWorkActiveData" /> -->
|
||||
</div>
|
||||
|
||||
<!-- 作业报告-->
|
||||
<div v-else-if="classWorkAnalysis.view == 'report'" style="overflow-y: scroll">
|
||||
<!-- <ClassOverview :table-list="overviewData" :eval-id="courseObj.evalid"></ClassOverview> -->
|
||||
</div>
|
||||
|
||||
<!-- <template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="classWorkAnalysis.open=false">关 闭</el-button>
|
||||
</div>
|
||||
</template> -->
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, defineExpose, onMounted, reactive, computed, watch, nextTick, getCurrentInstance } from 'vue'
|
||||
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
|
||||
import { listClassworkdata, listEntpcoursework, listClassworkeval } from '@/api/classTask'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getCurrentTime, getAfterMinutes } from '@/utils/date'
|
||||
import { processList } from '@/hooks/useProcessList'
|
||||
import ItemDialogScore from '@/views/classTask/container/item-dialog-score.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const emit = defineEmits(['addSuccess'])
|
||||
const props = defineProps({
|
||||
bookId: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
const mainHeight = ref(document.documentElement.clientHeight - 110)
|
||||
const classWorkAnalysis = reactive({
|
||||
open: false
|
||||
})
|
||||
const tableRadio = reactive({
|
||||
value: '1', // 已交
|
||||
list: [], // 已交list
|
||||
num1: 0, // 已交人数
|
||||
num0: 0 // 未交人数
|
||||
}) // 批阅 是否已交
|
||||
const loading_dt_table = ref(false)
|
||||
const isopen_dtwk_table = ref(false)
|
||||
|
||||
// zdg: 作业概况
|
||||
const classWorkActiveData = reactive({
|
||||
quizlist: [], // 当前习题列表
|
||||
studentList: [], // 当前课程-所有学生
|
||||
workFeedList: [], // 当前课程-所有学生反馈数据
|
||||
timerId: 0 // 定时器id
|
||||
})
|
||||
//所选学生题目- 答题题目分析与评价
|
||||
const classWorkAnalysisScore = reactive({
|
||||
studentObj: {}, // 当前学生的作业题型等信息
|
||||
studentQuizAllList: [], // 选择学生的回答list
|
||||
quizlist: [] // 选择学生的题目list
|
||||
})
|
||||
|
||||
// watch(
|
||||
// // () => props.currentNode,
|
||||
// (newValue, oldValue) => {
|
||||
// form.name = newValue.label
|
||||
// }
|
||||
// )
|
||||
const openDialog = (data) => {
|
||||
console.log(data, '点击的item答题情况')
|
||||
|
||||
classWorkAnalysis.title = data.uniquekey ? data.uniquekey + '--' : ''
|
||||
classWorkAnalysis.worktype = data.worktype
|
||||
classWorkAnalysis.workclass = data.workclass
|
||||
// 重置学生列表
|
||||
tableRadio.list = []
|
||||
tableRadio.value = '1'
|
||||
tableRadio.num0 = 0
|
||||
tableRadio.num1 = 0
|
||||
|
||||
classWorkAnalysis.open = true
|
||||
// 默认显示是学生作业反馈
|
||||
classWorkAnalysis.view = 'studentview'
|
||||
// 当前学习任务所包含的试题ID
|
||||
classWorkAnalysis.entpcourseworklistarray = data.entpcourseworklistarray
|
||||
// 默认选中的学生
|
||||
classWorkAnalysis.activeStudentQuizlist = []
|
||||
// 默认选中的试题
|
||||
classWorkAnalysis.activeQuizAnalysisData = []
|
||||
|
||||
classWorkAnalysis.row = data
|
||||
window.test = this
|
||||
// zdg: 学生列表
|
||||
const studentArr = data.classworkdatastudentids
|
||||
? JSON.parse(`[${data.classworkdatastudentids}]`)
|
||||
: []
|
||||
classWorkActiveData.studentList = studentArr
|
||||
/** 学生完成情况分析--获取作业学生list数据 */
|
||||
getClassWorkStudentList(data.id)
|
||||
|
||||
// 课程列表idlist
|
||||
var ids = []
|
||||
for (var i = 0; i < data.entpcourseworklistarray.length; i++) {
|
||||
ids.push(data.entpcourseworklistarray[i].id)
|
||||
}
|
||||
// 课程作业列表
|
||||
listEntpcoursework({ ids: ids.join(','), pageSize: 500 }).then((idres) => {
|
||||
for (var i = 0; i < idres.rows.length; i++) {
|
||||
// //新增了 复合题、主观题(背景+小题目) 题目标题优化一下 .replace(/!@#\$%/g,'')
|
||||
idres.rows[i].titletext = idres.rows[i].title.replace(/!@#\$%/g, '')
|
||||
}
|
||||
classWorkAnalysis.quizlist = idres.rows
|
||||
classWorkActiveData.quizlist = idres.rows // zdg: 作业概览组件使用
|
||||
|
||||
// 统计每个题目的正误率
|
||||
// 这个学习任务所有题目+所有学生的答题数据 , pageSize: 100
|
||||
listClassworkeval({ workid: data.id, pageSize: 1000 }).then((wevalres) => {
|
||||
for (var i = 0; i < classWorkAnalysis.quizlist.length; i++) {
|
||||
// 分析每一道题目
|
||||
var scoingCount = 0
|
||||
var feedcount = 0
|
||||
// 全部人数
|
||||
var evalCount = 0
|
||||
for (var w = 0; w < wevalres.rows.length; w++) {
|
||||
if (wevalres.rows[w].entpcourseworkid == classWorkAnalysis.quizlist[i].id) {
|
||||
evalCount++
|
||||
|
||||
// 只统计有回答的题目
|
||||
if (wevalres.rows[w].feedcontent != '') {
|
||||
// 已经作答的人数
|
||||
feedcount++
|
||||
// 简单判断正误
|
||||
if (wevalres.rows[w].feedcontent == wevalres.rows[w].rightanswer) {
|
||||
wevalres.rows[w].scoingStatus = true
|
||||
scoingCount++
|
||||
// 学生回答与参考答案一样,则:得分=分值
|
||||
wevalres.rows[w].teacherRating = wevalres.rows[w].score
|
||||
} else {
|
||||
wevalres.rows[w].scoingStatus = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
classWorkAnalysis.quizlist[i].evalCount = evalCount
|
||||
// 作答人数
|
||||
classWorkAnalysis.quizlist[i].feedcount = feedcount
|
||||
// 得分率 这里优化一下(没回答会是NaN%) scoingRate
|
||||
if (scoingCount == 0 && feedcount == 0) {
|
||||
classWorkAnalysis.quizlist[i].scoingRate = '0%'
|
||||
} else {
|
||||
classWorkAnalysis.quizlist[i].scoingRate =
|
||||
((scoingCount / feedcount) * 100).toFixed(0) + '%'
|
||||
}
|
||||
}
|
||||
// zdg: 所有反馈数据
|
||||
const getStudentid = (workdataid) => {
|
||||
// 获取学生id
|
||||
const classworkdata = (classWorkAnalysis.classworkdata || []).find(
|
||||
(o) => o.id === workdataid
|
||||
)
|
||||
return classworkdata ? classworkdata.studentid : ''
|
||||
}
|
||||
wevalres.rows.forEach((o) => {
|
||||
o.studentid = getStudentid(o.workdataid)
|
||||
})
|
||||
classWorkActiveData.workFeedList = wevalres.rows
|
||||
})
|
||||
})
|
||||
|
||||
console.log(classWorkAnalysis, '点击进度后获得的数据')
|
||||
}
|
||||
|
||||
//#region 学生完成情况分析
|
||||
/** 1、获取作业学生列表 */
|
||||
const getClassWorkStudentList = (rowId) => {
|
||||
// 本地保存这个rowid,老师批改后续中使用
|
||||
localStorage.setItem('activeClassWorkRowId', rowId)
|
||||
// 先清空表格中的数据
|
||||
classWorkAnalysis.classworkdata = []
|
||||
// 加载中_
|
||||
loading_dt_table.value = true
|
||||
// 找当前学习任务的classworkdata数据
|
||||
listClassworkdata({ classworkid: rowId, pageSize: 100 })
|
||||
.then((response) => {
|
||||
for (var i = 0; i < response.rows.length; i++) {
|
||||
if (response.rows[i].entpcourseworklist != '') {
|
||||
response.rows[i].entpcourseworkarray = JSON.parse(
|
||||
'[' + response.rows[i].entpcourseworklist + ']'
|
||||
)
|
||||
} else {
|
||||
response.rows[i].entpcourseworkarray = []
|
||||
}
|
||||
|
||||
// 老师批阅状态 默认0 未批改
|
||||
response.rows[i].teacherRating = 0
|
||||
|
||||
// 计算每个学生的得分率
|
||||
if (
|
||||
response.rows[i].classworkevallist != '' &&
|
||||
response.rows[i].classworkevallist != null &&
|
||||
response.rows[i].classworkevallist != 'null'
|
||||
) {
|
||||
// 将标签中双引号改为转义, 测试数据: "{\"id\":172910, \"feedcontent\":\"毛泽东,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\", \"score\":4, \"rightanswer\":\"毛泽东重,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\"},{\"id\":172911, \"rating\":0, \"teacherRating\":0, \"entpcourseworkid\":363100, \"feedcontent\":\"毛泽东重游橘子洲,面对如画的秋色和大好的革命形势,回忆过去战斗的岁月,不禁心潮起伏,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\", \"score\":4, \"rightanswer\":\"毛泽东重游橘子洲,面对如画的秋色和大好的革命形势,回忆过去战斗的岁月,不禁心潮起伏,<bdo class=\"mathjye-underpoint2\">浮想联翩</bdo>。\"}"
|
||||
// 常规作业(去除【】前后引号).replace(/"(\[.*\])"/g, '$1'); :eg: "feedcontent\":\"[{\"name\":\"Bliss.jpg\",\"url\":\"https://wzyzoss.3b8daa474.jpg\"}]\",
|
||||
// json转换会报错; .replace(/""/g, '"') eg: ""宇宙环境安全""
|
||||
response.rows[i].classworkevallist = escapeHtmlQuotes(response.rows[i].classworkevallist)
|
||||
console.log('学生完成情况分析classworkevallist', response.rows[i].classworkevallist)
|
||||
const evalarray = JSON.parse('[' + response.rows[i].classworkevallist + ']')
|
||||
var scoingCount = 0
|
||||
var feedcount = 0
|
||||
for (var e = 0; e < evalarray.length; e++) {
|
||||
if (evalarray[e].feedcontent != '') {
|
||||
feedcount++
|
||||
// 与答案对比正误。注意注意,这里仅限单选题
|
||||
if (evalarray[e].feedcontent == evalarray[e].rightanswer) {
|
||||
scoingCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(evalarray, 'evalarray------------------------------------')
|
||||
if (feedcount > 0) {
|
||||
// 多个题目的总得分率: 正确题数/(题目数*100)
|
||||
response.rows[i].scoingRate = ((scoingCount / feedcount) * 100).toFixed(0) + '%'
|
||||
} else {
|
||||
response.rows[i].scoingRate = '0%'
|
||||
}
|
||||
// 批阅状态 优良类 :注意:这里题目中的评价都是一样的,所以取第一个
|
||||
if (evalarray[0].rating != '') {
|
||||
response.rows[i].teacherRating = evalarray[0].rating
|
||||
}
|
||||
} else {
|
||||
response.rows[i].scoingRate = '0%'
|
||||
}
|
||||
}
|
||||
classWorkAnalysis.classworkdata = response.rows
|
||||
loading_dt_table.value = false
|
||||
|
||||
// 默认获取已交的学生列表
|
||||
tableRadio.list =
|
||||
classWorkAnalysis.classworkdata &&
|
||||
classWorkAnalysis.classworkdata.filter((item) => item.resultcount > 0)
|
||||
tableRadio.value = '1'
|
||||
tableRadio.num0 = classWorkAnalysis.classworkdata.length - tableRadio.list.length
|
||||
tableRadio.num1 = tableRadio.list.length
|
||||
})
|
||||
.catch(() => {
|
||||
loading_dt_table.value = false
|
||||
})
|
||||
}
|
||||
/** 2、查看某一个学生的学习任务完成详情*/
|
||||
const getStudentClassWorkDataDetail = (row) => {
|
||||
// 这里取出的是学生完成情况
|
||||
// 具体的题目数据在this.classWorkAnalysis.quizlist里
|
||||
console.log(row, '点击了左侧学生')
|
||||
//更新到待批改的学生信息中
|
||||
classWorkAnalysisScore.studentObj = row
|
||||
listClassworkeval({ workdataid: row.id, pageSize: 100 })
|
||||
.then((wevalres) => {
|
||||
for (var i = 0; i < classWorkAnalysis.quizlist.length; i++) {
|
||||
// 分析每一道题目
|
||||
for (var w = 0; w < wevalres.rows.length; w++) {
|
||||
if (wevalres.rows[w].entpcourseworkid == classWorkAnalysis.quizlist[i].id) {
|
||||
wevalres.rows[w].quiztitle = classWorkAnalysis.quizlist[i].title
|
||||
wevalres.rows[w].quiztitletext = classWorkAnalysis.quizlist[i].title.replace(
|
||||
/<[^>]*>/g,
|
||||
''
|
||||
)
|
||||
wevalres.rows[w].score = wevalres.rows[w].score ? wevalres.rows[w].score : 0
|
||||
|
||||
// 参考答案 去除下html标签
|
||||
wevalres.rows[w].rightanswer =
|
||||
wevalres.rows[w].rightanswer != '' && wevalres.rows[w].rightanswer != null
|
||||
? wevalres.rows[w].rightanswer.replace(/<[^>]+>/g, '')
|
||||
: wevalres.rows[w].rightanswer
|
||||
// 学生回答 去除下html标签
|
||||
wevalres.rows[w].feedcontent =
|
||||
wevalres.rows[w].feedcontent != '' && wevalres.rows[w].feedcontent != null
|
||||
? wevalres.rows[w].feedcontent.replace(/<[^>]+>/g, '')
|
||||
: wevalres.rows[w].feedcontent
|
||||
|
||||
if (classWorkAnalysis.row.worktype == '常规作业') {
|
||||
wevalres.rows[w].feedcontent = JSON.parse(wevalres.rows[w].feedcontent)
|
||||
}
|
||||
if (wevalres.rows[w].feedcontent != '') {
|
||||
if (wevalres.rows[w].feedcontent == wevalres.rows[w].rightanswer) {
|
||||
wevalres.rows[w].scoingStatus = true
|
||||
// 学生回答与参考答案一样,则:得分=分值
|
||||
wevalres.rows[w].teacherRating = wevalres.rows[w].score
|
||||
} else {
|
||||
wevalres.rows[w].scoingStatus = false
|
||||
}
|
||||
} else {
|
||||
wevalres.rows[w].scoingStatus = ''
|
||||
}
|
||||
// 计算得分
|
||||
}
|
||||
// "回答" prop="feedcontent" width="200" align="center"></el-table-column>
|
||||
// <el-table-column label="参考答案" prop="rightanswer"
|
||||
//新增了 复合题、主观题(背景+小题目) 题目标题优化一下
|
||||
wevalres.rows[w].worktitle = wevalres.rows[w].worktitle.replace(/!@#\$%/g, '')
|
||||
}
|
||||
}
|
||||
classWorkAnalysis.activeStudentQuizlist = wevalres.rows
|
||||
// 加载右边表格
|
||||
isopen_dtwk_table.value = true
|
||||
// 加载右边评语区域
|
||||
if (wevalres.rows.length > 0) {
|
||||
handleClassWorkAnalysissScoreOpen(row)
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '未获取到答题信息,请稍后再看,或者联系管理员查看情况!'
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('获取答题情况失败')
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '未获取到答题信息!'
|
||||
})
|
||||
})
|
||||
}
|
||||
/** 3、教师批改后返回的方法*/
|
||||
const onClassWorkScoreSubmit = () => {
|
||||
console.log('批改后返回的方法')
|
||||
loading_dt_table.value = true
|
||||
isopen_dtwk_table.value = false
|
||||
// 1、清空答题情况的两个table数据,- 左侧学生列表:classWorkAnalysis.classworkdata;- 右侧学生回答题目列表:classWorkAnalysis.activeStudentQuizlist
|
||||
// - 左侧学生列表
|
||||
classWorkAnalysis.classworkdata = []
|
||||
classWorkAnalysis.activeStudentQuizlist = []
|
||||
// 2、刷新左侧学生列表数据,更新批改状态
|
||||
const rowid = localStorage.getItem('activeClassWorkRowId')
|
||||
getClassWorkStudentList(rowid)
|
||||
}
|
||||
// 查看并批改一个学生的题目作答(答题题目分析与评价)
|
||||
const handleClassWorkAnalysissScoreOpen = (row) => {
|
||||
console.log(row, '所选点击的信息')
|
||||
|
||||
// 当前学生的回答list
|
||||
classWorkAnalysisScore.studentQuizAllList = classWorkAnalysis.activeStudentQuizlist
|
||||
// 当前学生的所有题目list
|
||||
classWorkAnalysisScore.quizlist = classWorkAnalysis.quizlist
|
||||
// 格式化试题格式信息
|
||||
processList(classWorkAnalysisScore.quizlist)
|
||||
// 屏幕高度
|
||||
classWorkAnalysisScore.maxheight = mainHeight.value - 100
|
||||
|
||||
// 防止组件未渲染完成 调用里面方法报错
|
||||
nextTick(() => {
|
||||
proxy.$refs.classWorkAnalysisScoreDialogRef.acceptParams(classWorkAnalysisScore)
|
||||
})
|
||||
}
|
||||
//#endregion
|
||||
|
||||
// 将标签中的双引号增加转义
|
||||
const escapeHtmlQuotes = (str) => {
|
||||
// 后端已replace双引号, 故前端不用在处理
|
||||
return str
|
||||
|
||||
// 只对双引号进行转义
|
||||
// return str.replace(/(<[^>]+>)/g, function (match) {
|
||||
// return match.replace(/"/g, '\\"')
|
||||
// })
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openDialog
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
// :deep(.reserv-date-pick) {
|
||||
// width: 140px;
|
||||
// }
|
||||
// :deep(.reserv-time-pick) {
|
||||
// width: 240px;
|
||||
// }
|
||||
.clwk_dialog {
|
||||
.clwk_dialog_view {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
// align-items: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.view_table {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.view_teachrting {
|
||||
flex: 2;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.clwk_dialog {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.clwk_dialog .el-dialog {
|
||||
margin: 0 auto !important;
|
||||
height: 85%!important;
|
||||
overflow: hidden;
|
||||
}
|
||||
.clwk_dialog .el-dialog__header {
|
||||
/* position: absolute;
|
||||
top: 0;
|
||||
left: 0; */
|
||||
width: 100%!important;
|
||||
}
|
||||
.clwk_dialog .el-dialog__body {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 15px;
|
||||
bottom: 1px;
|
||||
right:0;
|
||||
padding:5px;
|
||||
z-index:1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
/* overflow:hidden;
|
||||
overflow-y: auto; */
|
||||
}
|
||||
.clwk_dialog .el-dialog__footer{
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
}
|
||||
.clwk_dialog .classwork-score{
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
.clwk_dialog {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.clwk_dialog .el-dialog {
|
||||
margin: 0 auto !important;
|
||||
height: 85%!important;
|
||||
overflow: hidden;
|
||||
}
|
||||
.clwk_dialog .el-dialog__header {
|
||||
/* position: absolute;
|
||||
top: 0;
|
||||
left: 0; */
|
||||
width: 100%!important;
|
||||
}
|
||||
.clwk_dialog .el-dialog__body {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 15px;
|
||||
bottom: 1px;
|
||||
right:0;
|
||||
padding:5px;
|
||||
z-index:1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
/* overflow:hidden;
|
||||
overflow-y: auto; */
|
||||
}
|
||||
.clwk_dialog .el-dialog__footer{
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
}
|
||||
.clwk_dialog .classwork-score{
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,143 @@
|
|||
<template>
|
||||
<div class="class-reserv-item">
|
||||
<div class="class-reserv-item-body">
|
||||
<div class="class-reserv-item-title1">
|
||||
<el-tag style="margin-left: 5px" :type="item.workclass"> {{ item.worktype }}</el-tag>
|
||||
<label style="margin-left: 10px">{{ item.uniquekey }}</label>
|
||||
</div>
|
||||
|
||||
<div class="class-reserv-item-title3">
|
||||
<!-- <span v-for="(tag, index) in item.classItemList" :key="index" style="margin-left: 5px">
|
||||
{{ index === 0 ? tag.name : '、' + tag.name }}
|
||||
</span> -->
|
||||
<span>{{ item.classcaption }}</span>
|
||||
| 截止时间:{{ item.deaddate }} | {{ tabactive }}
|
||||
</div>
|
||||
</div>
|
||||
<el-switch v-model="value1" active-text="云同步"> </el-switch>
|
||||
<div class="class-reserv-item-tool">
|
||||
<span><span style="color: #000fff; font-weight: 900; font-size: 15px">{{ item.workdataresultcount }}</span>/{{ item.workdatacount }}</span>
|
||||
<span>已交</span>
|
||||
</div>
|
||||
<div class="class-reserv-item-tool">
|
||||
<span style="color: #ff7f00; font-weight: 900; font-size: 15px">2</span>
|
||||
<span>待批阅</span>
|
||||
</div>
|
||||
<div class="class-reserv-item-tool">
|
||||
<span><span style="color: #007fff; font-weight: 900; font-size: 15px">{{ item.averagetime?item.averagetime:0 }}</span>分钟 </span>
|
||||
<span>平均用时</span>
|
||||
</div>
|
||||
<div class="class-reserv-item-tool">
|
||||
<span style="color: #ff6ec7; font-weight: 900; font-size: 15px">{{ item.scoingRate }}</span>
|
||||
<span>得分率</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { createWindow } from '@/utils/tool'
|
||||
import { deleteSmartReserv, startClass, endClass } from '@/api/classManage'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { listEntpcourse } from '@/api/teaching/classwork'
|
||||
const emit = defineEmits(['openEdit', 'deleteReserv'])
|
||||
const props = defineProps({
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
tabactive: {
|
||||
type: String,
|
||||
default: () => ''
|
||||
}
|
||||
})
|
||||
import { ref, reactive } from 'vue'
|
||||
const value1 = ref(true);
|
||||
const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
||||
const toolStore = useToolState() // 获取状态管理-tool
|
||||
const openEdit = () => {
|
||||
emit('openEdit', props.item)
|
||||
}
|
||||
const deleteReserv = () => {
|
||||
deleteSmartReserv([props.item.id]).then((res) => {
|
||||
if (res.data === true) {
|
||||
ElMessage({
|
||||
message: '删除成功',
|
||||
type: 'success'
|
||||
})
|
||||
emit('deleteReserv', props.item)
|
||||
}
|
||||
})
|
||||
}
|
||||
const startClassR = (item) => {
|
||||
// startClass(item.id).then((res) => {
|
||||
// if (res.data === true) {
|
||||
// item.status = '上课中'
|
||||
// openLesson()
|
||||
// }
|
||||
// })
|
||||
item.status = '上课中'
|
||||
openLesson()
|
||||
}
|
||||
// const toolStore = useToolState()
|
||||
let wins = null;
|
||||
// 上课-工具类悬浮
|
||||
const openLesson = () => {
|
||||
// startClass(props.item.id)
|
||||
listEntpcourse({
|
||||
evalid: props.item.ex2,
|
||||
edituserid: useUserStore().user.userId,
|
||||
pageSize: 500
|
||||
}).then(async res=>{
|
||||
if (res.rows[0].id) {
|
||||
wins = await createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id })
|
||||
}
|
||||
})
|
||||
}
|
||||
const endClassR = (item) => {
|
||||
endClass(item.id).then((res) => {
|
||||
if (res.data === true) {
|
||||
ElMessage({
|
||||
message: '下课成功',
|
||||
type: 'success'
|
||||
})
|
||||
item.status = '已结束'
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.class-reserv-item {
|
||||
display: flex;
|
||||
background-color: white;
|
||||
border-radius: 10px;
|
||||
padding: 10px 5px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.class-reserv-item-body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: left;
|
||||
padding-left: 10px;
|
||||
font-size: 14px;
|
||||
.class-reserv-item-title1 {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
label {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
.class-reserv-item-tool {
|
||||
margin-left: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -47,7 +47,7 @@
|
|||
/>
|
||||
</el-dialog>
|
||||
<!--选择学科-->
|
||||
<SelectSubject v-model="isSubject" :login-data="loginForm" @on-success="successEditSubject" />
|
||||
<SelectSubject v-model="isSubject" :login-data="loginForm" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
|
@ -121,12 +121,6 @@ const submitForm = async (formEl) => {
|
|||
})
|
||||
}
|
||||
|
||||
const successEditSubject = () => {
|
||||
isSubject.value = false
|
||||
ElMessage.success('登录成功')
|
||||
ipcRenderer && ipcRenderer.send('openMainWindow')
|
||||
}
|
||||
|
||||
const getCookie = async () => {
|
||||
const username = (await getCookieDetail('username'))[0]
|
||||
const password = (await getCookieDetail('password'))[0]
|
||||
|
|
|
@ -95,6 +95,12 @@
|
|||
</template>
|
||||
<template v-else>
|
||||
<!-- 判断是不是自己创建的课件-->
|
||||
<div class="item-popover-item">
|
||||
<el-button text @click="openFileLink(item)">
|
||||
<i class="iconfont icon-arrangement"></i>
|
||||
<span>布置</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="item-popover-item" v-if="userInfo.userId === Number(item.createUserId)">
|
||||
<el-button text @click="editTalk(item, index)">
|
||||
<i class="iconfont icon-bianji"></i>
|
||||
|
@ -142,6 +148,7 @@ import { toTimeText } from '@/utils/date'
|
|||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import outLink from '@/utils/linkConfig'
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
export default {
|
||||
|
@ -161,7 +168,7 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
emits: { 'on-move': null, 'on-delete': null, 'on-set': null, 'on-delhomework': null },
|
||||
emits: { 'on-move': null, 'on-delete': null, 'on-set': null, 'on-delhomework': null,'on-filearg': null },
|
||||
data() {
|
||||
return {
|
||||
listenList: [],
|
||||
|
@ -223,6 +230,7 @@ export default {
|
|||
}
|
||||
},
|
||||
openFileWin(items) {
|
||||
if (!items||!items.fileSuffix) return;
|
||||
getPrepareById(items.id).then((item) => {
|
||||
Object.assign(items, item)
|
||||
asyncLocalFile(items).then(() => {
|
||||
|
@ -238,12 +246,12 @@ export default {
|
|||
fileType: item.fileType
|
||||
})
|
||||
ipcRenderer.on('listen-file-change-on' + item.fileNewName, () => {
|
||||
item.async = 'on'
|
||||
items.async = 'on'
|
||||
})
|
||||
ipcRenderer.on('listen-file-change-success' + item.fileNewName, (e, { data, md5 }) => {
|
||||
item.fileSize = data.fileSize
|
||||
item.md5 = md5
|
||||
item.async = true
|
||||
items.fileSize = data.fileSize
|
||||
items.md5 = md5
|
||||
items.async = true
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -256,6 +264,21 @@ export default {
|
|||
// 删除作业
|
||||
deleteHomework(item){
|
||||
this.$emit('on-delhomework', item)
|
||||
},
|
||||
// 文件资源打开web AIX 布置作业
|
||||
openFileLink(item){
|
||||
let unitId = item.levelSecondId ? item.levelSecondId : item.levelFirstId
|
||||
// key 对应的 linkConfig.js 外部链接配置
|
||||
let key = 'filehomework'
|
||||
let configObj = outLink()[key]
|
||||
// 通知主进程
|
||||
ipcRenderer.send('openWindow', {
|
||||
key,
|
||||
fullPath: configObj.fullPath + `&fileShowName=${item.fileShowName}&fileFullPath=${item.fileFullPath}&unitId=${unitId}`,
|
||||
cookieData: { ...configObj.data }
|
||||
})
|
||||
|
||||
this.$emit('on-filearg', item)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
placeholder="请选择日期"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
:disabled-date="disabledDate"
|
||||
/>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
|
@ -53,6 +54,8 @@
|
|||
range-separator="-"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
:disabled-hours="disabledHours"
|
||||
:disabled-minutes="disabledMinute"
|
||||
/>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
|
@ -81,6 +84,8 @@ import { ref, defineExpose, onMounted, reactive, computed, watch } from 'vue'
|
|||
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getCurrentTime, getAfterMinutes } from '@/utils/date'
|
||||
|
||||
const emit = defineEmits(['addSuccess'])
|
||||
const props = defineProps({
|
||||
bookId: {
|
||||
|
@ -143,6 +148,52 @@ const locationOptions = [
|
|||
const locationMessage = computed(() => {
|
||||
return locationOptions.find((item) => item.value === form.type).message
|
||||
})
|
||||
|
||||
// 设置一个月后的日期不能选择
|
||||
const disabledDate = (time)=> {
|
||||
// 禁用今天之前的日期
|
||||
const today = new Date();
|
||||
if (time.getTime() < today.getTime() - 8.64e7) {
|
||||
// 返回true表示禁用
|
||||
return true;
|
||||
}
|
||||
// 同时禁用超过一个月后的日期
|
||||
const oneMonthLater = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
|
||||
if (time.getTime() > oneMonthLater.getTime()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 限制小时-返回被禁选的小时
|
||||
const disabledHours = ()=>{
|
||||
if(getCurrentTime('YYYY-MM-DD') == form.day){
|
||||
const arrs = []
|
||||
for (let i = 0; i < 24; i++) {
|
||||
if (new Date().getHours() <= i) continue;
|
||||
arrs.push(i)
|
||||
}
|
||||
return arrs;
|
||||
}
|
||||
}
|
||||
// 限制分-返回被禁选的
|
||||
const disabledMinute = (hour,role) => {
|
||||
if(getCurrentTime('YYYY-MM-DD') == form.day){
|
||||
const arrs = []
|
||||
if(role == 'start'){
|
||||
for (let i = 0; i < 60; i++) {
|
||||
if (new Date().getMinutes() <= i) continue;
|
||||
arrs.push(i)
|
||||
}
|
||||
return arrs;
|
||||
}
|
||||
else{
|
||||
if(form.time[0]) return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const openDialog = (data) => {
|
||||
if (data) {
|
||||
updateForm.value = data
|
||||
|
@ -154,6 +205,11 @@ const openDialog = (data) => {
|
|||
form.resource = data.classList.split(',').map((item) => parseInt(item))
|
||||
form.classRoom = data.classRoom
|
||||
}
|
||||
else{
|
||||
// 默认当前时间
|
||||
form.day = getCurrentTime('YYYY-MM-DD')
|
||||
form.time = [getCurrentTime('HH:mm'), getAfterMinutes(45)]
|
||||
}
|
||||
centerDialogVisible.value = true
|
||||
}
|
||||
const closeDialog = () => {
|
||||
|
|
|
@ -1,326 +0,0 @@
|
|||
<template>
|
||||
<el-dialog v-model="dialogVisible" center top="10vh" width="600px" :show-close="false" append-to-body
|
||||
style="border-radius: 10px; padding: 10px 15px;">
|
||||
<template #header>
|
||||
<div class="homerwork-header flex">
|
||||
<span>{{ title }}</span>
|
||||
<i class="iconfont icon-guanbi" @click="cloneDialog"></i>
|
||||
</div>
|
||||
</template>
|
||||
<div v-loading="setLoading">
|
||||
<el-form :model="form" label-width="80px" ref="ruleForm" :rules="rules">
|
||||
<el-form-item label="班级" prop="grade">
|
||||
<el-scrollbar max-height="200px" style="width: 100%;">
|
||||
<el-tree ref="treeRef" :data="gradeList" :props="defaultProps" :load="getLoad" node-key="id"
|
||||
@check="handleCheckChange" lazy show-checkbox />
|
||||
</el-scrollbar>
|
||||
</el-form-item>
|
||||
<el-form-item label="选中学生" prop="student">
|
||||
<el-scrollbar max-height="200px">
|
||||
<el-tag v-for="(tag, index) in studentList" :key="tag.studentid" closable type="primary"
|
||||
@close="delStudent(index)">
|
||||
{{ tag.name }}
|
||||
</el-tag>
|
||||
</el-scrollbar>
|
||||
</el-form-item>
|
||||
<el-form-item label="完成要求" prop="feedback">
|
||||
<el-radio-group v-model="form.feedback">
|
||||
<el-radio value="必做" size="large">必做</el-radio>
|
||||
<el-radio value="选做" size="large">选做</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="截止时间" prop="deaddate">
|
||||
<el-date-picker v-model="form.deaddate" value-format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
|
||||
time-format="HH:mm" type="datetime" :clearable="false" placeholder="请选择截止时间" />
|
||||
</el-form-item>
|
||||
<el-form-item label="推荐用时" prop="timelength">
|
||||
<el-input-number v-model="form.timelength" :min="1" :max="500" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click.stop="cloneDialog">取消</el-button>
|
||||
<el-button type="primary" @click.stop="onSubmit('ruleForm')">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { listClassmain, listClassgroup } from '@/api/classManage/index'
|
||||
import { saveByClassWorkArray } from '@/api/teaching/classwork'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { uniqBy, groupBy } from 'lodash'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
entpcourseid: {
|
||||
default: ''
|
||||
},
|
||||
row: {
|
||||
default: ''
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '布置作业'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
return {
|
||||
dialogVisible: false,
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'label',
|
||||
isLeaf: 'leaf',
|
||||
},
|
||||
setLoading: false,
|
||||
// 用户信息
|
||||
userInfo: null,
|
||||
// 班级列表
|
||||
gradeList: [],
|
||||
curGradeId: '',
|
||||
// 小组列表
|
||||
groupList: [],
|
||||
// 选中的学生
|
||||
studentList: [],
|
||||
// 表单
|
||||
form: {
|
||||
feedback: '必做',
|
||||
deaddate: '',
|
||||
timelength: 1
|
||||
},
|
||||
// 表单规则
|
||||
rules: {
|
||||
grade: [
|
||||
{ validator: this.validateGrade, trigger: 'blur' }
|
||||
],
|
||||
student: [
|
||||
{ validator: this.validateStudent, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//截至时间默认值
|
||||
this.form.deaddate = this.getCurrentDate() + ' ' + '10:00:00'
|
||||
this.userInfo = useUserStore().user
|
||||
},
|
||||
methods: {
|
||||
// 获取班级列表
|
||||
getGradeList() {
|
||||
listClassmain({ classuserid: this.userInfo.userId, pageSize: 100, status: 'open' }).then(res => {
|
||||
let list = res.rows
|
||||
list.forEach(item => {
|
||||
item.label = item.caption
|
||||
item.level = 0
|
||||
item.children = []
|
||||
item.classstudentlist = JSON.parse("[" + item.classstudentlist + "]")
|
||||
item.classstudentlist.forEach(el => {
|
||||
el.classId = item.id
|
||||
})
|
||||
})
|
||||
this.gradeList = list
|
||||
})
|
||||
},
|
||||
// 获取节点下一级
|
||||
getLoad(node, resolve) {
|
||||
if (node.level == 0) return resolve([])
|
||||
// 获取二级节点 小组
|
||||
if (node.level == 1) {
|
||||
listClassgroup({ classid: node.key, orderby: 'orderidx', pageSize: 100 }).then(res => {
|
||||
if (res.rows.length > 0) {
|
||||
let ary = []
|
||||
res.rows.forEach(item => {
|
||||
if (item.parentid === 0) {
|
||||
//studentGroup 小组学生
|
||||
let studentGroup = JSON.parse("[" + item.studentlist + "]")
|
||||
studentGroup.forEach(el => {
|
||||
el.label = el.name
|
||||
el.leaf = true
|
||||
el.level = 2,
|
||||
el.id = el.studentid
|
||||
el.classId = item.classid
|
||||
})
|
||||
ary.push({
|
||||
label: item.groupname,
|
||||
...item,
|
||||
level: 1,
|
||||
children: studentGroup
|
||||
})
|
||||
}
|
||||
})
|
||||
resolve(ary)
|
||||
}
|
||||
else {
|
||||
resolve([])
|
||||
}
|
||||
})
|
||||
}
|
||||
// 三级节点 小组学生
|
||||
if (node.level == 2) {
|
||||
resolve(node.data.children)
|
||||
}
|
||||
|
||||
},
|
||||
//节点勾选后触发 拿学生
|
||||
handleCheckChange(data, checked) {
|
||||
this.studentList = []
|
||||
// 选中节点集合
|
||||
let checkNodes = checked.checkedNodes
|
||||
let ary = []
|
||||
checkNodes.forEach(item => {
|
||||
// 一级节点 班级
|
||||
if (item.level == 0) {
|
||||
ary = [...ary, ...(item.classstudentlist)]
|
||||
}
|
||||
// 二级节点 班级下面的小组
|
||||
if (item.level == 1) {
|
||||
ary = [...ary, ...(item.children)]
|
||||
}
|
||||
// 三级节点 小组下面的学生
|
||||
if (item.level == 2) {
|
||||
ary = [...ary, item]
|
||||
}
|
||||
})
|
||||
this.studentList = uniqBy(ary, 'studentid')
|
||||
},
|
||||
// 删除学生
|
||||
delStudent(index) {
|
||||
this.studentList.splice(index, 1)
|
||||
},
|
||||
onSubmit(formName) {
|
||||
|
||||
this.$refs[formName].validate(valid => {
|
||||
if (valid) {
|
||||
/**
|
||||
* 根据学生列表中的classId分班
|
||||
* studentList 为选中的所有学生 这些学生可能来自不同班级
|
||||
*/
|
||||
let gradeObj = groupBy(this.studentList, 'classId')
|
||||
// 处理要提交的参数
|
||||
let ary = []
|
||||
for (const value in gradeObj) {
|
||||
//这些参数 参照AIx web端 作业推送
|
||||
let obj = {
|
||||
id: 0,
|
||||
parentid: this.row.id,
|
||||
classid: value,
|
||||
classcourseid: 0,
|
||||
entpcourseid: this.entpcourseid,
|
||||
studentlist: JSON.stringify(gradeObj[value]),
|
||||
feedback: this.form.feedback,
|
||||
workkey: "",
|
||||
timelength: this.form.timelength,
|
||||
weights: 1,
|
||||
deaddate: this.form.deaddate,
|
||||
workdate: this.getCurrentDate(),
|
||||
uniquekey: this.row.uniquekey,
|
||||
entpcourseworklist: "[" + this.row.entpcourseworklist + "]",
|
||||
needMsgNotifine: 'false',
|
||||
msgkey: 'newclasswork',
|
||||
title: "作业任务",
|
||||
msgcontent: '',
|
||||
teachername: this.userInfo.nickName,
|
||||
unixstamp: new Date().getTime(),
|
||||
worktype: this.row.worktype
|
||||
}
|
||||
|
||||
ary.push(obj)
|
||||
}
|
||||
this.setLoading = true
|
||||
saveByClassWorkArray({
|
||||
classworkarray: JSON.stringify(ary)
|
||||
}).then(() => {
|
||||
this.setLoading = false
|
||||
ElMessage.success('操作成功')
|
||||
this.cloneDialog()
|
||||
}).catch(()=>{
|
||||
this.setLoading = false
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 关闭弹窗
|
||||
cloneDialog() {
|
||||
this.$emit('on-close')
|
||||
this.studentList = []
|
||||
this.$refs['ruleForm'].resetFields();
|
||||
},
|
||||
// 获取当前年月日
|
||||
getCurrentDate() {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth() + 1; // 月份是从0开始的,所以需要+1
|
||||
const day = now.getDate()
|
||||
return `${year}-${month.length == 2 ? month : '0' + month}-${day.length == 2 ? day : '0' + day}`;
|
||||
},
|
||||
validateGrade(rule, value, callback) {
|
||||
if (this.studentList.length == 0) {
|
||||
callback(new Error('请勾选班级或者学生'));
|
||||
}
|
||||
else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
validateStudent(rule, value, callback) {
|
||||
if (this.studentList.length == 0) {
|
||||
callback(new Error('学生不能为空'));
|
||||
}
|
||||
else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelValue(val) {
|
||||
this.dialogVisible = val
|
||||
if (val) {
|
||||
this.getGradeList()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.homerwork-header {
|
||||
justify-content: space-between;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
|
||||
.icon-guanbi {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.el-tag {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.dialog-footer{
|
||||
padding-bottom: 10px
|
||||
}
|
||||
|
||||
:deep(.el-checkbox){
|
||||
transform : scale(1.3)
|
||||
}
|
||||
:deep(.el-icon){
|
||||
transform : scale(1.3)
|
||||
}
|
||||
</style>
|
|
@ -3,8 +3,8 @@
|
|||
<ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" />
|
||||
<div class="page-right">
|
||||
<div class="header-top flex">
|
||||
<div class="textbook-img">
|
||||
<el-image style="width: 80px; height: 110px" :src="curBookImg" @click="navtoPdf" />
|
||||
<div class="textbook-img" @click="navtoPdf">
|
||||
<el-image style="width: 80px; height: 110px" :src="curBookImg" />
|
||||
<el-progress
|
||||
v-if="downloadNum > 0 && downloadNum < 100"
|
||||
style="position: absolute; left: 0; z-index: 999"
|
||||
|
@ -20,11 +20,11 @@
|
|||
</div>
|
||||
<el-button
|
||||
:type="!curClassReserv.id ? 'info' : 'primary'"
|
||||
:disabled="!curClassReserv.id"
|
||||
:disabled="!curClassReserv.id||toolStore.isToolWin"
|
||||
class="to-class-btn"
|
||||
@click="openLesson"
|
||||
>
|
||||
<label><i class="iconfont icon-lingdang"></i>上课</label>
|
||||
<label><i class="iconfont icon-lingdang"></i>{{curClassReserv.status=='上课中'?'上课中':'上课'}}</label>
|
||||
<label>{{ curClassReserv.classDay }} {{ getWeekday1(curClassReserv.classDay) }}</label>
|
||||
<label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label>
|
||||
</el-button>
|
||||
|
@ -79,6 +79,7 @@
|
|||
@on-delete="deleteTalk"
|
||||
@on-set="openSet"
|
||||
@on-delhomework="delhomework"
|
||||
@on-filearg="isOpenHomework = true"
|
||||
>
|
||||
<el-checkbox v-if="!item.uniquekey" label="" :value="item" />
|
||||
</file-list-item>
|
||||
|
@ -91,6 +92,7 @@
|
|||
@on-delete="deleteTalk"
|
||||
@on-set="openSet"
|
||||
@on-delhomework="delhomework"
|
||||
|
||||
>
|
||||
<el-checkbox v-if="!item.uniquekey" label="" :value="item" />
|
||||
</file-list-item>
|
||||
|
@ -112,7 +114,6 @@
|
|||
v-model="setDialog"
|
||||
:entpcourseid="entpcourseid"
|
||||
:row="row"
|
||||
@on-close="closeHomework"
|
||||
/>
|
||||
</div>
|
||||
<reserv
|
||||
|
@ -121,6 +122,7 @@
|
|||
:book-id="uploadData.textbookId"
|
||||
@add-success="initReserv"
|
||||
></reserv>
|
||||
<!-- <button @click="ipcMsgSend('tool-sphere:close')">测试</button> -->
|
||||
</template>
|
||||
<script setup>
|
||||
import { Check } from '@element-plus/icons-vue'
|
||||
|
@ -137,18 +139,19 @@ import { useToolState } from '@/store/modules/tool'
|
|||
import MoveFile from '@/components/move-file/index.vue'
|
||||
import FileListItem from '@/views/prepare/container/file-list-item.vue'
|
||||
import { getSmarttalkPage, moveSmarttalk } from '@/api/file'
|
||||
import { homeworklist, listEntpcourse } from '@/api/teaching/classwork'
|
||||
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 SetHomework from './container/set-homework.vue'
|
||||
import SetHomework from '@/components/set-homework/index.vue'
|
||||
import outLink from '@/utils/linkConfig'
|
||||
import { createWindow } from '@/utils/tool'
|
||||
import { uniqBy, cloneDeep } from 'lodash'
|
||||
import { delClasswork, addEntpcourse } from '@/api/teaching/classwork'
|
||||
import { createWindow, ipcMsgSend, sessionStore } from '@/utils/tool'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { delClasswork } from '@/api/teaching/classwork'
|
||||
import { getSelfReserv, startClass } from '@/api/classManage'
|
||||
import { useGetHomework } from '@/hooks/useGetHomework'
|
||||
const toolStore = useToolState()
|
||||
|
||||
const fs = require('fs')
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
|
||||
|
@ -192,10 +195,10 @@ export default {
|
|||
// 用户信息
|
||||
userStore: '',
|
||||
entpcourseid: '',
|
||||
timerId: null,
|
||||
// 布置作业弹窗
|
||||
setDialog: false,
|
||||
row: ''
|
||||
row: '',
|
||||
isOpenHomework: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -205,13 +208,7 @@ export default {
|
|||
)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route(to) {
|
||||
if (to.path != '/prepare' && this.timerId) {
|
||||
clearInterval(this.timerId)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.userStore = useUserStore().user
|
||||
ipcRenderer.removeAllListeners('copy-file-default-reply')
|
||||
|
@ -223,12 +220,24 @@ export default {
|
|||
this.initReserv()
|
||||
},
|
||||
mounted() {
|
||||
window.test = sessionStore
|
||||
window.test1 = toolStore
|
||||
this.$watch(
|
||||
() => toolStore.isToolWin,
|
||||
(newD, oldD) => {
|
||||
setTimeout(this.initReserv, 500)
|
||||
}
|
||||
)
|
||||
// electron 当前窗口
|
||||
const curWin = Remote.getCurrentWindow()
|
||||
curWin.on('focus', ()=>{
|
||||
if(!this.isOpenHomework) return
|
||||
this.initHomeWork()
|
||||
this.asyncAllFile()
|
||||
this.isOpenHomework = false
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
// activated() {
|
||||
// if (this.uploadData.textbookId !== null) {
|
||||
|
@ -410,158 +419,53 @@ export default {
|
|||
this.curBookImg = data.textBook.curBookImg
|
||||
this.curBookPath = data.textBook.curBookPath
|
||||
this.checkFileList = []
|
||||
this.currentWorkList = []
|
||||
let cata = parseCataByNode(data.node)
|
||||
this.currentNode = data.node
|
||||
this.uploadData.levelFirstId = cata[0]
|
||||
this.uploadData.levelSecondId = cata[1]
|
||||
this.uploadData.levelThirdId = cata[2]
|
||||
this.uploadData.textbookId = data.textBook.curBookId
|
||||
const toolStore = useToolState()
|
||||
toolStore.curSubjectNode.data = data
|
||||
toolStore.curSubjectNode.querySearch = this.uploadData
|
||||
// 不要同时修改共享数据,这样只会触发一次
|
||||
this.$nextTick(() =>{ toolStore.curSubjectNode.querySearch = this.uploadData })
|
||||
this.initHomeWork()
|
||||
await this.asyncAllFile()
|
||||
},
|
||||
// 获取作业
|
||||
async initHomeWork() {
|
||||
if (this.timerId) {
|
||||
clearInterval(this.timerId)
|
||||
}
|
||||
if (this.uploadData.levelSecondId) {
|
||||
// 获取作业列表所需ID 可能存在没有
|
||||
let { rows } = await this.getChapterId()
|
||||
if (rows.length > 0) {
|
||||
this.entpcourseid = rows[0].id
|
||||
} else {
|
||||
await this.createEntpcourse()
|
||||
let { rows } = await this.getChapterId()
|
||||
this.entpcourseid = rows[0].id
|
||||
}
|
||||
|
||||
// 查询作业
|
||||
this.getHomeWorkList()
|
||||
}
|
||||
},
|
||||
// 创建新的entpcourse
|
||||
createEntpcourse() {
|
||||
// 参照 web AIx 传入参数
|
||||
var cform = {}
|
||||
cform.entpid = this.userStore.deptId
|
||||
cform.level = 1
|
||||
cform.parentid = 0
|
||||
cform.dictid = 0
|
||||
cform.evalid = this.currentNode.id
|
||||
cform.evalparentid = 0
|
||||
cform.edusubject = this.currentNode.edusubject
|
||||
cform.edudegree = this.currentNode.edudegree
|
||||
cform.edustage = this.currentNode.edustage
|
||||
cform.coursetype = '课标学科'
|
||||
cform.coursetitle = this.currentNode.itemtitle
|
||||
cform.coursedesc = ''
|
||||
cform.status = ''
|
||||
cform.dflag = 0
|
||||
cform.edituserid = this.userStore.userId
|
||||
cform.createblankfile = 'yes'
|
||||
return addEntpcourse(cform)
|
||||
const { res, chapterId } = await useGetHomework(this.currentNode)
|
||||
this.entpcourseid = chapterId
|
||||
this.currentWorkList = cloneDeep(res)
|
||||
},
|
||||
openReserv() {
|
||||
this.$refs['reservDialog'].openDialog()
|
||||
},
|
||||
// 打开外部链接
|
||||
handleOutLink(key) {
|
||||
if (key == 'homeWork') {
|
||||
// 查询作业
|
||||
this.createTimer()
|
||||
if(key == 'homeWork'){
|
||||
this.isOpenHomework = true
|
||||
}
|
||||
// key 对应的 linkConfig.js 外部链接配置
|
||||
let configObj = outLink()[key]
|
||||
let fullPath = configObj.fullPath
|
||||
//打开作业 高考 url增加unitId 章节ID
|
||||
if(key != 'standard' && key != 'aiModel'){
|
||||
let unitId = this.uploadData.levelSecondId ? this.uploadData.levelSecondId : this.uploadData.levelFirstId
|
||||
if(key == 'gk'){
|
||||
fullPath += `?unitId=${unitId}`
|
||||
}
|
||||
else{
|
||||
fullPath += `&unitId=${unitId}`
|
||||
}
|
||||
}
|
||||
// 通知主进程
|
||||
ipcRenderer.send('openWindow', {
|
||||
key,
|
||||
fullPath: configObj.fullPath,
|
||||
fullPath: fullPath,
|
||||
cookieData: { ...configObj.data }
|
||||
})
|
||||
},
|
||||
// 根据教材章节单元ID 查询作业列表所需ID
|
||||
getChapterId() {
|
||||
console.log(this.userStore, 'this.userStore')
|
||||
return listEntpcourse({
|
||||
evalid: this.uploadData.levelSecondId,
|
||||
edituserid: this.userStore.userId,
|
||||
pageSize: 500
|
||||
})
|
||||
},
|
||||
// 查询作业列表定时器
|
||||
createTimer() {
|
||||
this.timerId = setInterval(() => {
|
||||
this.getHomeWorkList()
|
||||
}, 2500)
|
||||
},
|
||||
// 查询作业列表
|
||||
getHomeWorkList() {
|
||||
homeworklist({
|
||||
entpcourseid: this.entpcourseid,
|
||||
edituserid: this.userStore.userId,
|
||||
pageSize: 100
|
||||
}).then((res) => {
|
||||
//以下代码 参照AIx web端 作业布置
|
||||
let list = []
|
||||
for (var i = 0; i < res.rows.length; i++) {
|
||||
res.rows[i].taskconfig = []
|
||||
|
||||
// 找child
|
||||
for (var j = 0; j < res.rows.length; j++) {
|
||||
if (res.rows[j].parentid == res.rows[i].id) {
|
||||
var ss = []
|
||||
if (res.rows[j].classworkdatastudentids != null) {
|
||||
ss = JSON.parse('[' + res.rows[j].classworkdatastudentids + ']')
|
||||
}
|
||||
var js = {
|
||||
id: res.rows[j].id,
|
||||
classid: res.rows[j].classid,
|
||||
classcaption: res.rows[j].classcaption,
|
||||
parentid: 0,
|
||||
worktype: '',
|
||||
workkey: res.rows[j].workkey,
|
||||
worktag: '',
|
||||
entpcourseid: 0,
|
||||
evalid: 0,
|
||||
edusubject: '',
|
||||
edudegree: '',
|
||||
workdate: '',
|
||||
title: '',
|
||||
workcodes: '',
|
||||
studentlist: ss,
|
||||
deaddate: res.rows[j].deaddate,
|
||||
timelength: res.rows[j].timelength,
|
||||
weights: res.rows[j].weights,
|
||||
feedtype: res.rows[j].feedtype
|
||||
}
|
||||
res.rows[i].taskconfig.push(js)
|
||||
}
|
||||
}
|
||||
res.rows[i].fileShowName = res.rows[i].uniquekey
|
||||
|
||||
// 注意slideid>0的,这一些作业是添加到PPT页面的,所以在作业管理中不能出现
|
||||
// 2024-05-15,酉阳,jackyshen
|
||||
if (res.rows[i].classid == 0 && res.rows[i].slideid == 0) {
|
||||
list.push(res.rows[i])
|
||||
}
|
||||
|
||||
// 如果是习题训练任务,则检查一共有多少道
|
||||
if (res.rows[i].entpcourseworklist != '') {
|
||||
res.rows[i].entpcourseworklistarray = JSON.parse(
|
||||
'[' + res.rows[i].entpcourseworklist + ']'
|
||||
)
|
||||
} else {
|
||||
res.rows[i].entpcourseworklistarray = []
|
||||
}
|
||||
}
|
||||
// 去重
|
||||
let ary = uniqBy([...this.currentFileList, ...list], 'id')
|
||||
// 深度克隆
|
||||
this.currentWorkList = cloneDeep(ary)
|
||||
})
|
||||
},
|
||||
getWeekday1(date) {
|
||||
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
||||
const weekday = new Date(date).getDay()
|
||||
|
@ -580,29 +484,23 @@ export default {
|
|||
ElMessage.success('操作成功')
|
||||
this.isLoading = false
|
||||
await this.asyncAllFile()
|
||||
this.getHomeWorkList()
|
||||
this.initHomeWork()
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoading = false
|
||||
})
|
||||
},
|
||||
closeHomework() {
|
||||
this.setDialog = false
|
||||
},
|
||||
|
||||
// 打开PDF-课件
|
||||
async navtoPdf() {
|
||||
if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
|
||||
// if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
|
||||
let path = await this.getBookPathFromServer()
|
||||
createWindow('open-PDF', {
|
||||
url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path
|
||||
})
|
||||
},
|
||||
// 上课-工具类悬浮
|
||||
openLesson() {
|
||||
const toolStore = useToolState()
|
||||
if (toolStore.isToolWin) return this.$message.error('您当前已开始上课,请勿重复操作')
|
||||
startClass(this.curClassReserv.id)
|
||||
async openLesson() {
|
||||
// await startClass(this.curClassReserv.id)
|
||||
createWindow('tool-sphere', {
|
||||
url:
|
||||
'/tool/sphere?entpcourseid=' +
|
||||
|
@ -734,6 +632,7 @@ export default {
|
|||
cursor: pointer !important;
|
||||
}
|
||||
& > :deep(span) {
|
||||
pointer-events: none;
|
||||
flex-direction: column !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<!-- 裁剪+效果 -->
|
||||
<div class="box">
|
||||
<div class="box_1">
|
||||
<img :src="filePath" ref="image" />
|
||||
<img :src="dev_api + filePath" ref="image" />
|
||||
</div>
|
||||
|
||||
<!--裁剪完的图片-->
|
||||
|
@ -60,6 +60,7 @@ export default {
|
|||
},
|
||||
},
|
||||
setup(props, context) {
|
||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||
|
||||
// 原生上传的文件
|
||||
const uploadImg = (e) => {
|
||||
|
@ -163,7 +164,7 @@ export default {
|
|||
// 页面刷新自动执行
|
||||
onMounted(() => {
|
||||
if (props.filePath) {
|
||||
dataFile.image.src = props.filePath;
|
||||
dataFile.image.src = dev_api.value + props.filePath;
|
||||
copper();
|
||||
}
|
||||
});
|
||||
|
@ -175,6 +176,7 @@ export default {
|
|||
uploadImg,
|
||||
upLoading,
|
||||
cancle,
|
||||
dev_api
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6" :xs="24">
|
||||
<el-row :gutter="20" style="display: flex;flex-wrap: nowrap;justify-content: start">
|
||||
<el-col :xs="24" style="min-width: 260px;max-width: 300px">
|
||||
<el-card class="box-card">
|
||||
<template v-slot:header>
|
||||
<div class="clearfix">
|
||||
|
@ -97,10 +97,10 @@ const state = reactive({
|
|||
postGroup: {}
|
||||
})
|
||||
|
||||
function getUser() {
|
||||
async function getUser() {
|
||||
getUserProfile().then((response) => {
|
||||
response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar
|
||||
state.user = response.data
|
||||
// response.data.avatar = import.meta.env.VITE_APP_BASE_API + response.data.avatar
|
||||
Object.assign(state.user,response.data)
|
||||
state.roleGroup = response.roleGroup
|
||||
state.postGroup = response.postGroup
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div class="user-info-head" @click="editCropper()">
|
||||
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
|
||||
<img :src="dev_api + options.img" title="点击上传头像" class="img-circle img-lg" />
|
||||
<el-dialog
|
||||
v-model="open"
|
||||
append-to-body
|
||||
|
@ -28,6 +28,7 @@ const userStore = useUserStore()
|
|||
|
||||
const open = ref(false)
|
||||
const visible = ref(false)
|
||||
const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
|
||||
|
||||
//图片裁剪数据
|
||||
const options = reactive({
|
||||
|
@ -56,7 +57,7 @@ function uploadImg(data) {
|
|||
formData.append('avatarfile', data)
|
||||
uploadAvatar(formData).then((response) => {
|
||||
open.value = false
|
||||
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl
|
||||
options.img = response.imgUrl
|
||||
userStore.user.avatar = options.img
|
||||
ElMessage({
|
||||
message: '上传成功',
|
||||
|
@ -68,7 +69,7 @@ function uploadImg(data) {
|
|||
|
||||
/** 关闭窗口 */
|
||||
function closeDialog() {
|
||||
// options.img = userStore.avatar
|
||||
options.img = userStore.user.avatar
|
||||
options.visible = false
|
||||
}
|
||||
const cancle = () => {
|
||||
|
|
|
@ -15,6 +15,15 @@
|
|||
<el-radio value="1">女</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="学段">
|
||||
<el-radio-group v-model="user.edustage" @change="semeterChange">
|
||||
<template v-for="(item,index) in semesterList" :key="index">
|
||||
<el-radio :value="item.title">
|
||||
{{item.title }}
|
||||
</el-radio>
|
||||
</template>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="任教学科">
|
||||
<el-radio-group v-model="user.edusubject">
|
||||
<template v-for="(item,index) in subjectList" :key="index">
|
||||
|
@ -32,7 +41,7 @@
|
|||
|
||||
<script setup>
|
||||
import { ref, getCurrentInstance } from 'vue'
|
||||
import { updateUserProfile } from '@/api/system/user'
|
||||
import {updateUserInfo } from '@/api/system/user'
|
||||
import { listEvaluation } from '@/api/subject/index'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import {ElMessage} from 'element-plus'
|
||||
|
@ -46,6 +55,26 @@ const props = defineProps({
|
|||
const { proxy } = getCurrentInstance()
|
||||
const userStore = useUserStore()
|
||||
|
||||
//选择学段
|
||||
const semesterList = ref([
|
||||
{
|
||||
id:1,
|
||||
title:'幼儿园'
|
||||
},
|
||||
{
|
||||
id:2,
|
||||
title:'小学'
|
||||
},
|
||||
{
|
||||
id:3,
|
||||
title:'初中'
|
||||
},
|
||||
{
|
||||
id:4,
|
||||
title:'高中'
|
||||
},
|
||||
])
|
||||
|
||||
const rules = ref({
|
||||
nickName: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }],
|
||||
email: [
|
||||
|
@ -97,15 +126,17 @@ setTimeout(() => {
|
|||
function submit() {
|
||||
proxy.$refs.userRef.validate((valid) => {
|
||||
if (valid) {
|
||||
console.log(props.user)
|
||||
updateUserProfile(props.user).then((response) => {
|
||||
props.user.avatar = userStore.user.avatar
|
||||
updateUserInfo(props.user).then((response) => {
|
||||
if(response.code == 200){
|
||||
userStore.getInfo().then(res => {
|
||||
if(res.code === 200){
|
||||
ElMessage.success('修改成功')
|
||||
}else{
|
||||
ElMessage.error(response.msg)
|
||||
}
|
||||
userStore.login({username:props.user.userName,password:props.user.plainpwd}).then(() => {
|
||||
userStore.getInfo().then(res => {
|
||||
if(res.code === 200){
|
||||
ElMessage.success('修改成功')
|
||||
}else{
|
||||
ElMessage.error(response.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}else{
|
||||
ElMessage.error(response.msg)
|
||||
|
@ -114,4 +145,9 @@ function submit() {
|
|||
}
|
||||
})
|
||||
}
|
||||
const semeterChange = (item) => {
|
||||
if(item === '幼儿园'){
|
||||
props.user.edusubject = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -7,12 +7,30 @@
|
|||
@click="sourceStore.changeTab(item.value)">{{ item.label
|
||||
}}</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12" class="search-box flex">
|
||||
<el-input v-model="sourceStore.query.fileName" @input="sourceStore.changeName" style="width: 240px"
|
||||
|
||||
<el-col :span="12" class="search-box flex" v-if="isThird">
|
||||
<el-input v-model="sourceStore.thirdQuery.title" @input="onchangeInput()" style="width: 240px"
|
||||
placeholder="请输入关键词" />
|
||||
</el-col>
|
||||
<el-col :span="12" class="search-box flex" v-else>
|
||||
<el-input v-model="sourceStore.query.fileName" @input="onchangeInput()" style="width: 240px"
|
||||
placeholder="请输入关键词" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="resoure-btns">
|
||||
|
||||
<!-- 第三方资源筛选-->
|
||||
<el-row class="resoure-btns" v-if="isThird">
|
||||
<el-col :span="24" class="query-row flex">
|
||||
<div class="flex row-left">
|
||||
<el-button v-for="item in coursewareTypeList" :key="item.id"
|
||||
:type="sourceStore.thirdQuery.type == item.value ? 'primary' : ''" round
|
||||
@click="sourceStore.thirdChangeType(item.value)">
|
||||
{{item.label }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="resoure-btns" v-else>
|
||||
<el-col :span="24" class="query-row flex">
|
||||
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix"
|
||||
style="width: 110px">
|
||||
|
@ -30,13 +48,36 @@
|
|||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {watch,ref,onMounted} from 'vue'
|
||||
import useResoureStore from '../store'
|
||||
|
||||
import {coursewareTypeList} from '@/utils/resourceDict'
|
||||
const isThird = ref(false)
|
||||
const sourceStore = useResoureStore()
|
||||
// 防抖函数
|
||||
const debounce = (fn, t) => {
|
||||
let timer;
|
||||
return function (...args) {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(() => fn.apply(this, args), t);
|
||||
};
|
||||
};
|
||||
// 初始化防抖函数
|
||||
const debouncedChangeName = debounce(sourceStore.changeName, 300);
|
||||
const onchangeInput = () => {
|
||||
debouncedChangeName()
|
||||
}
|
||||
onMounted(() => {
|
||||
sourceStore.query.fileSource = '平台'
|
||||
})
|
||||
|
||||
watch(() => sourceStore.query.fileSource,() => {
|
||||
sourceStore.query.fileSource === '第三方'?isThird.value = true:isThird.value = false
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.resoure-search {
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
<template>
|
||||
<div v-loading="sourceStore.loading" class="resource-list">
|
||||
<el-scrollbar>
|
||||
<el-empty v-if="!sourceStore.thirdResult.list.length" description="暂无数据" />
|
||||
<ul>
|
||||
<li
|
||||
v-for="item in sourceStore.thirdResult.list"
|
||||
:key="item.itemId"
|
||||
class="list-item"
|
||||
@click="handleRow"
|
||||
>
|
||||
<div class="item-left flex">
|
||||
<div style="position: relative" @click="clickImg(item.itemId)">
|
||||
<FileImage :file-name="item.fileType" :size="50" />
|
||||
<el-icon style="position: absolute;top: 1px;right: 5px"><Search /></el-icon>
|
||||
</div>
|
||||
<div class="flex item-left-content">
|
||||
<div class="name flex" :title="item.title">
|
||||
<div></div>
|
||||
<div
|
||||
style="
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
width: 200px;
|
||||
"
|
||||
>
|
||||
{{ item.title }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-tags flex" style="margin-bottom: 5px;">
|
||||
<el-text type="info" size="small" class="mr-10">标签:</el-text>
|
||||
<el-tag type="info" size="small" class="mr-10">{{ item.year }}</el-tag>
|
||||
<el-tag type="info" size="small" class="mr-10">{{ item.typeName }}</el-tag>
|
||||
<el-tag type="info" size="small" class="mr-10">{{ item.provinceName }}</el-tag>
|
||||
</div>
|
||||
<div class="item-tags flex">
|
||||
<el-text type="info" size="small" class="mr-10">
|
||||
<el-icon><Clock/></el-icon>
|
||||
{{ timestampToDate(item.dateline) }}
|
||||
</el-text>
|
||||
<el-text type="info" size="small" class="mr-10">
|
||||
<el-icon><View /></el-icon>
|
||||
{{ item.viewCount }}人看过
|
||||
</el-text>
|
||||
<el-text type="info" size="small" class="mr-10">
|
||||
<el-icon><Folder /></el-icon>
|
||||
{{ item.formatSize }}
|
||||
</el-text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</el-scrollbar>
|
||||
<div class="pagination-box">
|
||||
<el-pagination
|
||||
v-model:current-page="sourceStore.thirdQuery.page"
|
||||
v-model:page-size="sourceStore.thirdQuery.perPage"
|
||||
:page-sizes="[10, 20, 30, 50]"
|
||||
background
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="sourceStore.thirdResult.total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
<el-dialog v-model="isViewImg" width="80%" :modal-append-to-body="false" :append-to-body="false">
|
||||
<div class="demo-image__lazy">
|
||||
<el-image v-for="(url,index) in srcList" :key="index" :src="url" lazy />
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- <video width="550" controls autoplay loop>-->
|
||||
<!-- <source src="https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-360p.mp4" type="video/mp4" />-->
|
||||
<!-- </video>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
// import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Clock,View,Folder,Search } from '@element-plus/icons-vue'
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
import { getFileSuffix } from '@/utils/ruoyi'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import useResoureStore from '../store'
|
||||
import {getImgPath} from "@/api/file/third";
|
||||
|
||||
const userstore = useUserStore()
|
||||
const sourceStore = useResoureStore()
|
||||
|
||||
// const userInfo = userstore.user
|
||||
//判断是否预览图片
|
||||
const isViewImg = ref(false)
|
||||
//显示图片的路径
|
||||
const srcList = ref([])
|
||||
|
||||
// 分页change
|
||||
const handleSizeChange = (limit) => {
|
||||
sourceStore.thirdQuery.perPage = limit
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
const handleCurrentChange = (page) => {
|
||||
sourceStore.thirdQuery.page = page
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
//将时间戳转化为时间的格式
|
||||
function timestampToDate(timestamp) {
|
||||
// 如果时间戳是10位数,则将其转换为毫秒级
|
||||
if (timestamp.toString().length === 10) {
|
||||
timestamp *= 1000;
|
||||
}
|
||||
|
||||
const date = new Date(timestamp);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以加1,并确保两位数
|
||||
const day = String(date.getDate()).padStart(2, '0'); // 确保两位数
|
||||
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
//获取图片的路径
|
||||
const clickImg = (id) => {
|
||||
srcList.value = []
|
||||
getImgPath({itemId:id}).then(res => {
|
||||
if(res.code === 200){
|
||||
isViewImg.value = true
|
||||
res.data.forEach(item => {
|
||||
item.subsets.forEach(previewItem => {
|
||||
previewItem.previewFiles.forEach(fileItem => {
|
||||
srcList.value.push(fileItem.fileUrl)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
::v-deep(.el-popover) {
|
||||
min-width: 50px;
|
||||
width: 50px !important;
|
||||
}
|
||||
.custom-popover {
|
||||
width: 80px !important;
|
||||
min-width: 80px !important;
|
||||
padding: 5px !important;
|
||||
|
||||
.item-popover-item {
|
||||
padding: 5px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
|
||||
.iconfont {
|
||||
margin-right: 5px;
|
||||
color: #a2a2a2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.resource-list {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: auto;
|
||||
.list-item {
|
||||
flex: 1;
|
||||
padding: 10px 20px;
|
||||
border-bottom: solid #f1f1f1 1px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
background-color: rgba(144, 147, 153, 0.2);
|
||||
cursor: pointer;
|
||||
}
|
||||
.item-left {
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
.icon {
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
.item-left-content {
|
||||
margin-left: 10px;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 14px;
|
||||
color: #3b3b3b;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 1px;
|
||||
height: 15px;
|
||||
background-color: #d9dce2;
|
||||
}
|
||||
|
||||
.item-tags {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mr-10 {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.gray-text {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.item-btns {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
:deep(.item-popover) {
|
||||
font-size: 12px;
|
||||
flex-direction: column;
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-shenglvehao {
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.icon-jiahao {
|
||||
font-size: 12px;
|
||||
margin-right: 3px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-box {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
height: 65px;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -1,7 +1,8 @@
|
|||
<template>
|
||||
<div class="page-resource flex">
|
||||
<!--左侧 教材 目录-->
|
||||
<ChooseTextbook @change-book="getData" @node-click="getData" />
|
||||
<Third v-if="isThird" @node-click="getDataOther"></Third>
|
||||
<ChooseTextbook v-else @change-book="getData" @node-click="getData" />
|
||||
|
||||
<div class="page-right">
|
||||
<!-- 搜索 -->
|
||||
|
@ -18,7 +19,9 @@
|
|||
>
|
||||
</ResoureSearch>
|
||||
<!-- 列表 -->
|
||||
<ResoureList />
|
||||
<!-- 第三方列表-->
|
||||
<ThirdList v-if="isThird" />
|
||||
<ResoureList v-else />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 上传弹窗 -->
|
||||
|
@ -26,11 +29,13 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref, toRaw } from 'vue'
|
||||
import { onMounted, ref, toRaw,watch } from 'vue'
|
||||
import useResoureStore from './store'
|
||||
import ChooseTextbook from '@/components/choose-textbook/index.vue'
|
||||
import Third from '@/components/choose-textbook/third.vue'
|
||||
import ResoureSearch from './container/resoure-search.vue'
|
||||
import ResoureList from './container/resoure-list.vue'
|
||||
import ThirdList from './container/third-list.vue'
|
||||
import uploadDialog from '@/components/upload-dialog/index.vue'
|
||||
import uploaderState from '@/store/modules/uploader'
|
||||
import { createWindow } from '@/utils/tool'
|
||||
|
@ -41,9 +46,8 @@ const toolStore = useToolState()
|
|||
const openDialog = () => {
|
||||
isDialogOpen.value = true
|
||||
}
|
||||
// onMounted(async () => {
|
||||
// console.log('toolStore: ', toolStore.windowState)
|
||||
// })
|
||||
//判断是否去查看第三方资源
|
||||
const isThird = ref(false)
|
||||
|
||||
// 查询
|
||||
const getData = (data) => {
|
||||
|
@ -66,6 +70,15 @@ const getData = (data) => {
|
|||
levelSecondId
|
||||
}
|
||||
sourceStore.handleQuery()
|
||||
// 头部 教材分析打开外部链接需要当前章节ID
|
||||
localStorage.setItem('unitId', JSON.stringify({ levelFirstId, levelSecondId}))
|
||||
}
|
||||
const getDataOther = (data) => {
|
||||
sourceStore.thirdQuery.chapterId = data.chapterId
|
||||
sourceStore.thirdQuery.bookId = data.bookId
|
||||
sourceStore.thirdQuery.stage = data.stage
|
||||
sourceStore.thirdQuery.subjectId = data.subjectId
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
|
||||
// 提交文件
|
||||
|
@ -92,6 +105,9 @@ const fileCallBack = (res) => {
|
|||
onMounted(() => {
|
||||
sourceStore.getCreate()
|
||||
})
|
||||
watch(() => sourceStore.query.fileSource,() => {
|
||||
sourceStore.query.fileSource === '第三方'?isThird.value = true:isThird.value = false
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { getSmarttalkPage } from '@/api/file/index'
|
||||
import { getBookList } from '@/api/file/third'
|
||||
import { tabs, resourceType, resourceFormat } from '@/utils/resourceDict'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { hasPermission } from '@/utils/hasPermission'
|
||||
|
@ -60,23 +61,56 @@ export default defineStore('resource', {
|
|||
isAsc: 'desc',
|
||||
...structQuery
|
||||
},
|
||||
//第三方的查询条件
|
||||
thirdQuery:{
|
||||
page:1,
|
||||
perPage:20,
|
||||
chapterId:0,
|
||||
bookId:0,
|
||||
stage:0,
|
||||
subjectId:0,
|
||||
type:'',
|
||||
title:''
|
||||
},
|
||||
result: {
|
||||
list: [],
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
//第三方的数据单独处理
|
||||
thirdResult:{
|
||||
list: [],
|
||||
total: 0,
|
||||
},
|
||||
}),
|
||||
actions: {
|
||||
handleQuery() {
|
||||
try {
|
||||
this.loading = true
|
||||
let data = { ...this.query }
|
||||
if (data.fileSuffix == -1) {
|
||||
data.fileSuffix = ''
|
||||
if(this.query.fileSource !== '第三方'){
|
||||
let data = { ...this.query }
|
||||
if (data.fileSuffix == -1) {
|
||||
data.fileSuffix = ''
|
||||
}
|
||||
getSmarttalkPage(data).then((res) => {
|
||||
this.result.total = res.total
|
||||
this.result.list = res.rows
|
||||
})
|
||||
}else{
|
||||
let data = JSON.parse(JSON.stringify(this.thirdQuery))
|
||||
if (data.title) {
|
||||
data.title.trim()
|
||||
}else{
|
||||
data.title = null
|
||||
}
|
||||
getBookList(data).then((res) => {
|
||||
if(res.code === 200){
|
||||
if(res.data.code === 0){
|
||||
this.thirdResult.total = res.data.page.totalCount
|
||||
this.thirdResult.list = [...res.data.data]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
getSmarttalkPage(data).then((res) => {
|
||||
this.result.total = res.total
|
||||
this.result.list = res.rows
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
|
@ -90,6 +124,11 @@ export default defineStore('resource', {
|
|||
this.query.fileFlag = val
|
||||
this.handleQuery()
|
||||
},
|
||||
thirdChangeType(val) {
|
||||
this.thirdQuery.type = val
|
||||
this.handleQuery()
|
||||
},
|
||||
//第三方的切换类型区别开
|
||||
changeSuffix(val) {
|
||||
this.query.fileSuffix = val
|
||||
this.handleQuery()
|
||||
|
@ -99,12 +138,12 @@ export default defineStore('resource', {
|
|||
this.handleQuery()
|
||||
},
|
||||
getCreate(){
|
||||
if(this.query.fileSource == '平台'){
|
||||
if(this.query.fileSource == '平台' || this.query.fileSource == '第三方' ){
|
||||
this.isCreate = hasPermission(['platformmanager'])
|
||||
}
|
||||
else{
|
||||
this.isCreate = hasPermission(['schoolteacher','headmaster'])
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
|
|
@ -19,6 +19,7 @@ const emit = defineEmits(['update:modelValue'])
|
|||
onMounted(async() => {
|
||||
if (canvasRef.value) {
|
||||
FabricVue.drawConfig.drawColors = ['red']
|
||||
FabricVue.drawConfig.drawWidth = 3
|
||||
FabricVue.boardConfig.mode = TYPES.ActionMode.OTHER
|
||||
FabricVue.boardConfig.backgroundColor = 'transparent'
|
||||
const option = { freeDrawingCursor: 'default' }
|
||||
|
@ -28,7 +29,7 @@ onMounted(async() => {
|
|||
const handleMode = (newVal, oldVal) => {
|
||||
if(toolStore.isPdfWin){
|
||||
if(newVal=='clear'){
|
||||
emit('update:modelValue', oldVal)
|
||||
setTimeout(() => emit('update:modelValue', oldVal), 10)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ const handleMode = (newVal, oldVal) => {
|
|||
case 'clear': // 清空画布
|
||||
if(oldVal){
|
||||
FabricVue.history?.clean()
|
||||
emit('update:modelValue', oldVal)
|
||||
setTimeout(() => emit('update:modelValue', oldVal), 10)
|
||||
}
|
||||
|
||||
break
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-button color="#349d44" @click="openFileLink(item)">推送</el-button>
|
||||
</li>
|
||||
<!--作业-->
|
||||
<li class="item flex" v-for="item in dataList" :key="item.id">
|
||||
|
@ -50,7 +51,7 @@
|
|||
</el-scrollbar>
|
||||
</div>
|
||||
<SetHomework v-model="setDialog" :title="'推送作业'" :entpcourseid="entpcourseid" :row="curRow"
|
||||
@on-close="closeHomework" />
|
||||
@on-close="closeHomework" @on-success="successHomework"/>
|
||||
</div>
|
||||
<div class="homework flex" v-else>
|
||||
<div class="unit-top flex">
|
||||
|
@ -72,18 +73,17 @@
|
|||
import { ref, onMounted, toRaw } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { homeworklist } from '@/api/teaching/classwork'
|
||||
import { getSmarttalkPage, getPrepareById } from '@/api/file'
|
||||
import SetHomework from '@/views/prepare/container/set-homework.vue'
|
||||
import { getSmarttalkPage } from '@/api/file'
|
||||
import SetHomework from '@/components/set-homework/index.vue'
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
import { useGetHomework } from '@/hooks/useGetHomework'
|
||||
import { ipcMsgSend } from '@/utils/tool'
|
||||
import { ipcMsgSend, ipcMsgSend2, ipcMsgInvoke } from '@/utils/tool'
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import { asyncLocalFile } from '@/utils/talkFile'
|
||||
import Lesson from './lesson.vue';
|
||||
import { parseCataByNode } from '@/utils/talkFile'
|
||||
import MsgEnum from '@/plugins/imChat/msgEnum' // 消息枚举
|
||||
import { createHomework } from '../createHomework'
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const route = useRoute();
|
||||
const usertore = useUserStore().user
|
||||
const toolStore = useToolState()
|
||||
|
@ -96,11 +96,9 @@ const dataList = ref([])
|
|||
const setDialog = ref(false)
|
||||
// 资源数据
|
||||
const resourceList = ref([])
|
||||
|
||||
//
|
||||
//当前点击的数据
|
||||
const curRow = ref('')
|
||||
|
||||
|
||||
const sendHomework = (row) => {
|
||||
curRow.value = row
|
||||
setTimeout(() => {
|
||||
|
@ -109,14 +107,18 @@ const sendHomework = (row) => {
|
|||
setDialog.value = true
|
||||
}
|
||||
//
|
||||
const closeHomework = () => {
|
||||
const closeHomework = async() => {
|
||||
ipcMsgSend('tool-sphere:set:ignore', true)
|
||||
setDialog.value = false
|
||||
}
|
||||
|
||||
|
||||
// 推送成功
|
||||
const successHomework = (data)=>{
|
||||
// console.log('推送成功', data)
|
||||
// 发送im消息-推送作业(app|平板)
|
||||
ipcMsgInvoke('im-chat:msg', data, MsgEnum.HEADS.MSG_0016)
|
||||
}
|
||||
// 章节目录change
|
||||
const changeChapter = async (data)=>{
|
||||
const res = await useGetHomework(data)
|
||||
const { res } = await useGetHomework(data)
|
||||
dataList.value = res
|
||||
let cata = parseCataByNode(data)
|
||||
|
||||
|
@ -127,6 +129,38 @@ const changeChapter = async (data)=>{
|
|||
getResource()
|
||||
}
|
||||
|
||||
// 资源推送
|
||||
const openFileLink = async (item) =>{
|
||||
/**
|
||||
* 资源推送
|
||||
* 1:先生成作业
|
||||
* 2:再进行推送
|
||||
*/
|
||||
|
||||
// 根据当前月份日期 生成一个作业编号
|
||||
const today = new Date();
|
||||
// 获取月份
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0');
|
||||
// 获取当前日
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
// 生成一个作业编号
|
||||
const uniquekey = `${usertore.edusubject}-${month}${day}-${dataList.value.length + 1}`
|
||||
|
||||
// 章节ID
|
||||
const querySearch = toolStore.curSubjectNode.querySearch
|
||||
const evalid = querySearch.levelSecondId ? querySearch.levelSecondId : querySearch.levelFirstId
|
||||
|
||||
// 资源数据
|
||||
const data = [{name: item.fileShowName, ulr: item.fileFullPath}]
|
||||
// 生成作业
|
||||
await createHomework({ uniquekey, evalid, data, entpcourseid: entpcourseid.value })
|
||||
// 查询作业
|
||||
getHomework()
|
||||
let row = dataList.value.at(-1)
|
||||
sendHomework(row)
|
||||
}
|
||||
|
||||
|
||||
// 获取资源数据
|
||||
const getResource = () => {
|
||||
let querySearch = toRaw(toolStore.curSubjectNode).querySearch
|
||||
|
@ -141,71 +175,13 @@ const getResource = () => {
|
|||
|
||||
}
|
||||
|
||||
// 获取作业数据
|
||||
const getHomework = () => {
|
||||
//获取作业数据
|
||||
const getHomework = async () => {
|
||||
const data = toRaw(toolStore.curSubjectNode).data.node
|
||||
loading.value = true
|
||||
try {
|
||||
homeworklist({
|
||||
entpcourseid: entpcourseid.value,
|
||||
edituserid: usertore.userId,
|
||||
pageSize: 100
|
||||
}).then(res => {
|
||||
//以下代码 参照AIx web端 作业布置
|
||||
let list = []
|
||||
for (var i = 0; i < res.rows.length; i++) {
|
||||
res.rows[i].taskconfig = []
|
||||
|
||||
// 找child
|
||||
for (var j = 0; j < res.rows.length; j++) {
|
||||
if (res.rows[j].parentid == res.rows[i].id) {
|
||||
var ss = []
|
||||
if (res.rows[j].classworkdatastudentids != null) {
|
||||
ss = JSON.parse('[' + res.rows[j].classworkdatastudentids + ']')
|
||||
}
|
||||
var js = {
|
||||
id: res.rows[j].id,
|
||||
classid: res.rows[j].classid,
|
||||
classcaption: res.rows[j].classcaption,
|
||||
parentid: 0,
|
||||
worktype: '',
|
||||
workkey: res.rows[j].workkey,
|
||||
worktag: '',
|
||||
entpcourseid: 0,
|
||||
evalid: 0,
|
||||
edusubject: '',
|
||||
edudegree: '',
|
||||
workdate: '',
|
||||
title: '',
|
||||
workcodes: '',
|
||||
studentlist: ss,
|
||||
deaddate: res.rows[j].deaddate,
|
||||
timelength: res.rows[j].timelength,
|
||||
weights: res.rows[j].weights,
|
||||
feedtype: res.rows[j].feedtype
|
||||
}
|
||||
res.rows[i].taskconfig.push(js)
|
||||
}
|
||||
}
|
||||
res.rows[i].fileShowName = res.rows[i].uniquekey
|
||||
|
||||
// 注意slideid>0的,这一些作业是添加到PPT页面的,所以在作业管理中不能出现
|
||||
// 2024-05-15,酉阳,jackyshen
|
||||
if (res.rows[i].classid == 0 && res.rows[i].slideid == 0) {
|
||||
list.push(res.rows[i])
|
||||
}
|
||||
|
||||
// 如果是习题训练任务,则检查一共有多少道
|
||||
if (res.rows[i].entpcourseworklist != '') {
|
||||
res.rows[i].entpcourseworklistarray = JSON.parse(
|
||||
'[' + res.rows[i].entpcourseworklist + ']'
|
||||
)
|
||||
} else {
|
||||
res.rows[i].entpcourseworklistarray = []
|
||||
}
|
||||
}
|
||||
|
||||
dataList.value = list
|
||||
})
|
||||
const { res } = await useGetHomework(data)
|
||||
dataList.value = res
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
@ -230,10 +206,10 @@ function leave(el, done) {
|
|||
onMounted(() => {
|
||||
entpcourseid.value = route.query.entpcourseid
|
||||
lesson.value = route.query.label
|
||||
getHomework()
|
||||
setTimeout(()=>{
|
||||
getHomework()
|
||||
getResource()
|
||||
},5000)
|
||||
},200)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
<script setup>
|
||||
// 功能说明:im-chat 腾讯im chat聊天室
|
||||
import { onMounted, ref, reactive, watchEffect } from 'vue'
|
||||
import { ImChat } from '@/plugins/imChat'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import * as http from '@/api/apiService' // 自定义api service
|
||||
import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' // 相关工具
|
||||
const userStore = useUserStore()
|
||||
const emits = defineEmits(['change'])
|
||||
const props = defineProps({
|
||||
isGroup: { type: Boolean, default: false }, // 是否创建群
|
||||
})
|
||||
const imChatObj = reactive({imChat:null})
|
||||
onMounted(() => {
|
||||
ipcMainHandle() // 绑定-监听ipcMain im相关消息
|
||||
})
|
||||
// 初始化 im-chat
|
||||
const initImChat = async (timGroupId) => {
|
||||
// console.log('im-chat', userStore.user.timuserid)
|
||||
try {
|
||||
const { timuserid, deptId, userId } = userStore.user
|
||||
// 获取腾讯云签名
|
||||
const res = await http.imChat.getTxCloudSign({imUserId: timuserid})
|
||||
if (res && res.code == 200) {
|
||||
const { sdkAppId, sign } = res.data
|
||||
// 群名称
|
||||
const groupName = `${deptId}-classteaching-${userId}`
|
||||
// 注册im-chat
|
||||
// await ipcMsgInvoke('im-chat:init', sdkAppId)
|
||||
imChatObj.imChat = new ImChat(sdkAppId, sign, timuserid)
|
||||
// 初始化 im-chat
|
||||
await imChatObj.imChat.init()
|
||||
// 监听 im-chat 消息
|
||||
imChatObj.imChat.watch((res) => {
|
||||
imChatObj.imChat.setConsole('%cchat-msg', res)
|
||||
msgHandle(res) // 消息处理
|
||||
})
|
||||
// 登录 im-chat(为了不漏消息,需要在登录之前-监听)
|
||||
await imChatObj.imChat.login()
|
||||
// 创建群
|
||||
if (!timGroupId||props.isGroup) { // 创建群
|
||||
await createGroup(groupName)
|
||||
} else { // 已有群-设置群id
|
||||
imChatObj.imChat.timGroupId = timGroupId
|
||||
}
|
||||
return imChatObj.imChat
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('im-error: ', error)
|
||||
}
|
||||
}
|
||||
// 消息处理
|
||||
const msgHandle = (msg) => {
|
||||
const { type, data } = msg
|
||||
switch(type) {
|
||||
case 'TIMAddRecvNewMsgCallback': // 收到新消息 data=[]
|
||||
{
|
||||
(data||[]).forEach(o => {
|
||||
const msgArr = o?.message_elem_array||[]
|
||||
msgArr.forEach(info => {
|
||||
const msgType = info?.elem_type // 消息类型 TIMElemType
|
||||
const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
|
||||
emits('change', 'msg', msgData, o, type, msgType)
|
||||
})
|
||||
})
|
||||
}
|
||||
break
|
||||
case 'TIMSetConvEventCallback': // 监听会话事件 data = {data,type}
|
||||
{
|
||||
const convArr = data.data || []
|
||||
convArr.forEach(o => {
|
||||
const msgArr = o?.conv_last_msg?.message_elem_array||[]
|
||||
msgArr.forEach(info => {
|
||||
const msgType = info?.elem_type // 消息类型 TIMElemType
|
||||
const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
|
||||
emits('change', 'msg', msgData, o?.conv_last_msg, type, msgType)
|
||||
})
|
||||
})
|
||||
}
|
||||
emits('change', 'msg-conv', msg)
|
||||
break
|
||||
}
|
||||
// 未处理的消息
|
||||
emits('change', 'msgDef', msg)
|
||||
}
|
||||
// 创建群组
|
||||
const createGroup = async (groupName) => {
|
||||
if (!imChatObj.imChat) return
|
||||
await imChatObj.imChat.createGroup(groupName)
|
||||
emits('change', 'createGroup', imChatObj.imChat.timGroupId)
|
||||
}
|
||||
// 退出
|
||||
const logout = () => imChatObj.imChat?.logout()
|
||||
// 解散群
|
||||
const deleteGroup = () => imChatObj.imChat?.deleteGroup()
|
||||
|
||||
// 绑定-监听ipcMain im相关消息
|
||||
const ipcMainHandle = () => {
|
||||
ipcMain?.removeHandler?.('im-chat:msg') // 先移除已有的 ipcMain 消息
|
||||
ipcMain?.handle?.('im-chat:msg', (e, msg, head, type) => { // 重新绑定 ipcMain 消息
|
||||
return imChatObj.imChat?.sendMsgGroup(msg, head, type)
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ initImChat, logout, deleteGroup, imChatObj })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="im-chat">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
|
@ -13,9 +13,8 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, nextTick, markRaw, toRaw } from 'vue'
|
||||
import { ref, onMounted, nextTick, toRaw } from 'vue'
|
||||
import { useToolState } from '@/store/modules/tool'
|
||||
import { parseCataByNode } from '@/utils/talkFile'
|
||||
|
||||
const emit = defineEmits(['changeChapter'])
|
||||
const toolStore = useToolState()
|
||||
|
@ -42,18 +41,17 @@ const getTreeData = () => {
|
|||
evaluationList.value = JSON.parse(localStorage.getItem('evaluationList'))
|
||||
|
||||
//上册
|
||||
let volumeOne = evaluationList.value.filter(item => item.level == 1 && item.semester == '上册')
|
||||
//下册
|
||||
let volumeTwo = evaluationList.value.filter(item => item.level == 1 && item.semester == '下册')
|
||||
/**
|
||||
* 不区分上下册
|
||||
* 2024/08/20调整
|
||||
*/
|
||||
let volumeOne = evaluationList.value.filter(item => item.level == 1)
|
||||
|
||||
//数据过滤
|
||||
|
||||
let upData = transData(volumeOne)
|
||||
let downData = transData(volumeTwo)
|
||||
if(upData.length && downData.length){
|
||||
treeData.value = [...upData,...downData]
|
||||
}
|
||||
else if(upData.length || downData.length){
|
||||
treeData.value = upData.length ? upData : downData
|
||||
if(upData.length){
|
||||
treeData.value = [...upData]
|
||||
}
|
||||
else{
|
||||
treeData.value = []
|
||||
|
|
|
@ -1,24 +1,33 @@
|
|||
<template>
|
||||
<div class="warp" ref="btnRef">
|
||||
<div class="warp" ref="btnRef" :style="isFold?'min-height:auto;':''">
|
||||
<slot name="start"></slot>
|
||||
<!-- 工具按钮 -->
|
||||
<el-space direction="vertical">
|
||||
<template v-for="(item,index) in list">
|
||||
<slot :name="item.prop" :item="item" :index="index">
|
||||
<div class="c-btn flex flex-col items-center gap-2 p-2" @click.stop="clickHandel(item,$event)">
|
||||
<i class="iconfont" :class="item.icon" :style="item.style" />
|
||||
<span>{{item.label||item.text||item.name}}</span>
|
||||
</div>
|
||||
</slot>
|
||||
</template>
|
||||
<slot name="append"></slot>
|
||||
</el-space>
|
||||
<slot name="end"></slot>
|
||||
<transition name="el-zoom-in-bottom">
|
||||
<el-space direction="vertical" v-show="!isFold">
|
||||
<template v-for="(item,index) in list">
|
||||
<slot :name="item.prop" :item="item" :index="index">
|
||||
<div class="c-btn flex flex-col items-center gap-2 p-2" @click.stop="clickHandel(item,$event)">
|
||||
<i class="iconfont" :class="item.icon" :style="item.style" />
|
||||
<span>{{item.label||item.text||item.name}}</span>
|
||||
</div>
|
||||
</slot>
|
||||
</template>
|
||||
<slot name="append"></slot>
|
||||
</el-space>
|
||||
</transition>
|
||||
<slot name="end">
|
||||
<span class="fold" @click="isFold=!isFold" :style="isFold?'margin: 5px;':''">
|
||||
{{isFold?'<<<':'>>>'}}
|
||||
</span>
|
||||
</slot>
|
||||
<!-- 内容部分 -->
|
||||
<transition name="el-fade-in">
|
||||
<div class="c-popover" :style="`--top: ${topPos}px;--height:${hPost}px;`" v-show="isVisible">
|
||||
<div class="content">
|
||||
<homework/>
|
||||
<div class="content" v-if="isVisible">
|
||||
<slot name="content">
|
||||
<homework v-if="activeObj?.prop === 'resource'" />
|
||||
<span v-else style="color:red;">{{activeObj}}</span>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
|
@ -51,6 +60,7 @@ const activeObj = ref(null) // 当前激活的按钮
|
|||
const btnRef = ref(null) // 按钮元素-ref
|
||||
const topPos = ref(30) // 顶部距离-内容的距离
|
||||
const hPost = ref(0) // 顶部距离-内容的距离
|
||||
const isFold = ref(false) // 是否折叠
|
||||
let posBtnAll = {} // 存储位置
|
||||
// === 计算属性 ===
|
||||
const list = computed(() => props.data.map((o,i) => {
|
||||
|
@ -97,7 +107,7 @@ const clickHandel = (o, e) => {
|
|||
min-width: 4em;
|
||||
border-radius: 4em;
|
||||
background-color: #121212;
|
||||
.el-space{margin: 20px 0;}
|
||||
.el-space{margin: 20px 0 0;}
|
||||
.c-btn{
|
||||
color: #d9dce3;
|
||||
cursor: pointer;
|
||||
|
@ -110,6 +120,20 @@ const clickHandel = (o, e) => {
|
|||
background: #454545fa;
|
||||
}
|
||||
}
|
||||
.fold{
|
||||
display: block;
|
||||
color: #ccc;
|
||||
font-size: 14px;
|
||||
padding: 3px 6px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
margin-bottom: 10px;
|
||||
&:hover{
|
||||
color: #409eff;
|
||||
border-radius: 4px;
|
||||
// background: #454545fa;
|
||||
}
|
||||
}
|
||||
}
|
||||
.c-popover{
|
||||
--top: 30px;
|
||||
|
@ -135,8 +159,4 @@ const clickHandel = (o, e) => {
|
|||
transform: rotate(45deg);
|
||||
}
|
||||
}
|
||||
.content{
|
||||
color: red;
|
||||
|
||||
}
|
||||
</style>
|
|
@ -1,28 +1,73 @@
|
|||
<template>
|
||||
<button v-if="props.test" @click="trigger">测试</button>
|
||||
<div ref="warpRef" class="c-warp">
|
||||
<template v-for="i in sum">
|
||||
<slot><el-icon><Star /></el-icon></slot>
|
||||
<div v-if="props.test">
|
||||
<el-button type="primary" @click="trigger" v-tap:trigger="">点赞</el-button>
|
||||
<el-button type="primary" @click="trigger(2, '学生A')" v-tap:trigger="[2,'学生A']">疑惑</el-button>
|
||||
</div>
|
||||
<!-- 温度计-模式 -->
|
||||
<div v-if="props.type == 2" class="c-anim">
|
||||
<div class="item like" :style="`height:${wtData.like*5}px;`"></div>
|
||||
<div class="item doubt" :style="`height:${wtData.doubt*5}px;`"></div>
|
||||
</div>
|
||||
<!-- (默认)弹幕-模式 -->
|
||||
<div v-else ref="warpRef" class="c-warp">
|
||||
<template v-for="(item, index) in iconCache.list">
|
||||
<slot>
|
||||
<el-icon v-if="props.def"><Star /></el-icon>
|
||||
<div v-else class="item">
|
||||
<svg class="icon" aria-hidden="true">
|
||||
<use :xlink:href="`#icon-`+item.icon"></use>
|
||||
</svg>
|
||||
<!-- 学生姓名 -->
|
||||
<div class="tip" v-if="item.name">
|
||||
<span :title="item.name">{{item.name}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</slot>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
// 功能说明:动画-点赞
|
||||
import { nextTick, ref } from 'vue'
|
||||
import { ref, nextTick, useSlots, reactive } from 'vue'
|
||||
import {Star} from '@element-plus/icons-vue'
|
||||
const warpRef = ref(null)
|
||||
const props = defineProps({ test: Boolean })
|
||||
const sum = ref(0)
|
||||
// === 方法 ===
|
||||
const trigger = () => {
|
||||
sum.value++
|
||||
nextTick(() => {
|
||||
const el = warpRef.value.lastElementChild // 获取最后一个新加的元素
|
||||
animInit(el)
|
||||
})
|
||||
const slots = useSlots() // 获取插槽
|
||||
const isSlot = !!Object.keys(slots).length // 是否使用了插槽
|
||||
const props = defineProps({
|
||||
test: Boolean, // 是否开启-测试按钮
|
||||
def: Boolean, // 是否使用默认图标
|
||||
type: String, // 模式 1-弹幕 2-温度计
|
||||
tback: Number, // 模式:温度计-退回速度
|
||||
tsleep: Number, // 模式:温度计-执行退回间隔
|
||||
})
|
||||
let iconCache = reactive({list:[]}) // 图标缓存
|
||||
let wtData = reactive({ // 温度计模式-计数
|
||||
like: 0, doubt: 0,
|
||||
timeout: {like: null, doubt: null}, // 定时器-单次
|
||||
interval: {like: null, doubt: null}, // 定时器-循环
|
||||
})
|
||||
|
||||
// === 触发 type 1: 点赞 2: 疑惑 ===
|
||||
const trigger = async (type, name) => {
|
||||
if (typeof type == 'string') { name = type; type = 1 } // 兼容
|
||||
if (props.type == 2) { // 温度计-模式
|
||||
weatherglassModel(type)
|
||||
} else { // 默认-弹幕模式
|
||||
iconCache.list.push({
|
||||
name,
|
||||
icon: isSlot||props.def ? '' : getRandomIcon(type) // 图标
|
||||
})
|
||||
nextTick(() => {
|
||||
const el = warpRef.value.lastElementChild // 获取最后一个新加的元素
|
||||
const tipEl = el.querySelector('.tip') // 获取提示元素
|
||||
// console.log(el)
|
||||
animInit(el, tipEl, type)
|
||||
})
|
||||
}
|
||||
}
|
||||
// 初始化动画
|
||||
const animInit = (el) => {
|
||||
const animInit = (el, tipEl, type) => {
|
||||
const { height, width } = el.getBoundingClientRect()
|
||||
const sumH = warpRef.value.clientHeight
|
||||
const sumW = warpRef.value.clientWidth
|
||||
|
@ -32,15 +77,25 @@ const animInit = (el) => {
|
|||
let opacity = 0 // 透明度
|
||||
let scale = 0 // 缩放
|
||||
let transform = '' // 旋转 缩放 偏移等操作
|
||||
let transform2 = '' // 旋转 缩放 偏移等操作-恢复
|
||||
let right = getRandom(5, maxw, false, true) // 随机-右距离
|
||||
let isPlus = getRandomBool()?'':'-' // 随机-方向
|
||||
let isPlus2 = isPlus ? '' : '-' // 随机-方向-恢复
|
||||
let rotate = getRandom(0, 60, false, true) // 随机-旋转
|
||||
let scaleMax = getRandom(0, 1, true, true)+1 // 随机-缩放倍数
|
||||
let scaleMax = getRandom(0.5, 1.5, true, true)+1 // 随机-缩放倍数
|
||||
setStatic(el,'position','absolute') // 设置-定位
|
||||
setStatic(el, 'right', right, 'px') // 设置-右距离
|
||||
// 特殊处理
|
||||
if (type === 1) { // 疑惑
|
||||
rotate = getRandom(0, 15, false, true) // 随机-旋转
|
||||
scaleMax = getRandom(2.5, 3, true, true) // 随机-缩放倍数
|
||||
}
|
||||
// console.log('zdg: ', right, isPlus, rotate, scaleMax, maxw)
|
||||
|
||||
const amFn = () => { // opacity: 0.5;
|
||||
// if (bottom == 130) return
|
||||
// 到顶了- 移除元素
|
||||
if (bottom > maxH) {el.remove();return}
|
||||
if (bottom > maxH) {el.remove();resetIconCache();return}
|
||||
// 透明度: 进入-慢慢出现
|
||||
if (bottom < 101 && opacity < 1) opacity = toNumber(opacity + 0.01)
|
||||
else if (bottom > maxH - 100 && opacity > 0) opacity = toNumber(opacity - 0.01)
|
||||
|
@ -49,18 +104,69 @@ const animInit = (el) => {
|
|||
// 缩放:退出-慢慢缩小
|
||||
else if (bottom > maxH - (scaleMax/0.1) && scale > 0) scale = toNumber(scale - 0.1)
|
||||
bottom++
|
||||
// console.log('zdg: ', scale)
|
||||
// console.log('zdg: ', scale) rotate(${isPlus2}${rotate}deg)
|
||||
// 设置样式
|
||||
transform = `rotate(${isPlus}${rotate}deg) scale(${scale})`
|
||||
setStatic(el, 'bottom', bottom, 'px')
|
||||
setStatic(el, 'opacity', opacity)
|
||||
setStatic(el, 'transform', transform)
|
||||
if (!!tipEl && type) {
|
||||
transform2 = `rotate(${isPlus2}${rotate}deg) scale(${toNumber(1/scale)})`
|
||||
setStatic(tipEl, 'transform', transform2)
|
||||
}
|
||||
requestAnimationFrame(amFn)
|
||||
}
|
||||
amFn() // 初次执行
|
||||
}
|
||||
// 温度计-模式触发 1: 点赞 2: 疑惑
|
||||
const weatherglassModel = async(type) => {
|
||||
const field = type == 2 ? 'doubt' : 'like'
|
||||
wtData[field]++
|
||||
autoReduce(type)
|
||||
}
|
||||
// 温度计-自动恢复初始
|
||||
const autoReduce = type => {
|
||||
const field = type == 2 ? 'doubt' : 'like'
|
||||
const reduceFn = () => { // 该定时器: 会一直执行间隔1s
|
||||
wtData.interval[field] = setInterval(() => {
|
||||
wtData[field]--
|
||||
// 停止-定时器
|
||||
if (wtData[field] <= 0) {
|
||||
clearInterval(wtData.interval[field])
|
||||
wtData[field] = 0
|
||||
}
|
||||
}, (props.tback||100))
|
||||
}
|
||||
if (!!wtData.timeout[field]) clearInterval(wtData.timeout[field]) // 清除定时器:上一次
|
||||
if (!!wtData.interval[field]) clearInterval(wtData.interval[field]) // 清除定时器:上一次
|
||||
wtData.timeout[field] = setTimeout(() => {
|
||||
reduceFn()
|
||||
}, (props.tsleep||20) * 1000)
|
||||
}
|
||||
// 设置-静态样式
|
||||
const setStatic = (el, type, val, end) => el.style[type] = val + (end || '')
|
||||
// 重置缓存列表
|
||||
const resetIconCache = () => {
|
||||
const len = warpRef.value?.children?.length||0
|
||||
if (!len && iconCache.list.length) iconCache.list = []
|
||||
}
|
||||
// 随机图案样式-默认
|
||||
const getRandomIcon = (type) => {
|
||||
let iconArr = []
|
||||
switch (type) {
|
||||
case 2: // 阿里icon-疑惑
|
||||
iconArr = ['yiwen', 'a-yiwen', 'yihuo', 'yiwen-01']
|
||||
break
|
||||
default:
|
||||
iconArr = [ // 阿里icon-点赞
|
||||
'zan10', 'zanping', 'zan9', 'dianzan-red', 'zan8', 'zan11', 'zan7', 'MBEfenggeduosetubiao-xihuan',
|
||||
'zan6', 'zan-yizan', 'zan5', 'yizan', 'zan4', 'zan3', 'zan2', 'zan1', 'zan'
|
||||
]
|
||||
break
|
||||
}
|
||||
const ind = getRandom(0, iconArr.length-1)
|
||||
return iconArr[ind]||''
|
||||
}
|
||||
// 随机数 isFloat:是否小数 isMax:是否包含最大值
|
||||
const getRandom = (min, max, isFloat, isMax, pos=2) => {
|
||||
const maxVal = isMax ? max - min + 1 : max - min
|
||||
|
@ -71,11 +177,30 @@ const getRandom = (min, max, isFloat, isMax, pos=2) => {
|
|||
const getRandomBool = () => Math.random() > 0.5
|
||||
// 转换数字-(小数精度丢失)
|
||||
const toNumber = (v, pos = 2) => Number(v.toFixed(pos))
|
||||
// 延时
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||
// 自定义-局部指令
|
||||
const vTap = {
|
||||
mounted(el, binding) {
|
||||
const instance = binding.instance
|
||||
const fn = binding.arg
|
||||
const args = binding.value||[]
|
||||
if (!fn) return
|
||||
let cleId = null
|
||||
el.addEventListener('mousedown', () => {
|
||||
cleId = setInterval(() => {instance[fn](...args)}, 10);
|
||||
})
|
||||
el.addEventListener('mouseup', () => {
|
||||
!!cleId && clearInterval(cleId)
|
||||
})
|
||||
}
|
||||
}
|
||||
// 暴露方法
|
||||
defineExpose({ trigger })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
// 弹幕-模式
|
||||
.c-warp {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
|
@ -83,5 +208,66 @@ defineExpose({ trigger })
|
|||
width: 30%;
|
||||
height: 50%;
|
||||
pointer-events: none;
|
||||
.item{
|
||||
display: inline-block;
|
||||
.tip{
|
||||
position: absolute;
|
||||
padding: 3px 6px;
|
||||
border-radius: 4px;
|
||||
background: linear-gradient(90deg, #9fe597, #cce581);
|
||||
font-size: 12px;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 65px;
|
||||
transform-origin: right top;
|
||||
span{
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
/* text-overflow: ellipsis; */
|
||||
white-space: nowrap;
|
||||
cursor: default;
|
||||
}
|
||||
&::before{
|
||||
content: " ";
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
z-index: -1;
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(45deg, #b2e68d, #bce689);
|
||||
bottom: -3px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) rotate(45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 温度计-模式
|
||||
.c-anim {
|
||||
position: fixed;
|
||||
// height: 90vh;
|
||||
// border: 1px solid;
|
||||
inset: auto auto 3em 1em;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-end;
|
||||
.item{
|
||||
flex: 1;
|
||||
border-radius: 3px;
|
||||
min-width: 15px;
|
||||
// height: 500px;
|
||||
&.like{
|
||||
background-image: linear-gradient(to top, #fef0f0, #f56c6c);
|
||||
// animation: striped-flow 5s linear infinite;
|
||||
}
|
||||
&.doubt{
|
||||
background-image: linear-gradient(to top, #fdf6ec, #e6a23c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@keyframes striped-flow {
|
||||
0%{background-position: 0 500px;}
|
||||
100%{background-position: 0 0;}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,37 @@
|
|||
import useUserStore from '@/store/modules/user'
|
||||
import { addClassworkReturnId } from '@/api/teaching/classwork'
|
||||
|
||||
export const createHomework = ({ uniquekey, evalid, data, entpcourseid }) =>{
|
||||
const usertore = useUserStore().user
|
||||
|
||||
var formObj = {};
|
||||
formObj.id = 0;
|
||||
|
||||
formObj.deaddate = '';
|
||||
formObj.entpid = usertore.deptId;
|
||||
formObj.level = 1;
|
||||
formObj.parentid = 0;
|
||||
formObj.worktype = '常规作业';
|
||||
formObj.workkey = '';
|
||||
formObj.worktag = '';
|
||||
|
||||
formObj.uniquekey = uniquekey;
|
||||
|
||||
formObj.classid = 0;
|
||||
formObj.classcourseid = 0;
|
||||
|
||||
formObj.entpcourseid = entpcourseid;
|
||||
|
||||
formObj.slideid = 0;
|
||||
|
||||
formObj.workcodes = JSON.stringify(data);
|
||||
|
||||
formObj.edusubject = usertore.edusubject;
|
||||
formObj.evalid = evalid
|
||||
|
||||
formObj.edustage = usertore.edustage;
|
||||
formObj.status = '';
|
||||
formObj.edituserid = usertore.userId;
|
||||
formObj.entpcourseworklist = JSON.stringify([{'id':-2, 'score': '10'}]);
|
||||
return addClassworkReturnId(formObj)
|
||||
}
|
|
@ -36,6 +36,7 @@ class Drag {
|
|||
const {cx, cy} = this.getMousePos(e)
|
||||
this.x = cx
|
||||
this.y = cy
|
||||
this.getCurPos() // 被拖拽元素初始坐标
|
||||
// 手动-触发事件 v-drag-start
|
||||
this.el.dispatchEvent(new CustomEvent('v-drag-start', {detail:{drag: this}}))
|
||||
}
|
||||
|
@ -85,12 +86,20 @@ class Drag {
|
|||
}
|
||||
// 获取移动后坐标
|
||||
getPos(x, y) {
|
||||
const w = this.max.w - this.toRound(this.el.clientWidth)
|
||||
const h = this.max.h - this.toRound(this.el.clientHeight)
|
||||
// 边界控制:图标元素
|
||||
// const w = this.max.w - this.toRound(this.el.clientWidth)
|
||||
// const h = this.max.h - this.toRound(this.el.clientHeight)
|
||||
// 边界控制:整个工具
|
||||
const w = this.max.w - this.toRound(this.handle.clientWidth)
|
||||
const h = this.max.h - this.toRound(this.handle.clientHeight)
|
||||
x = x < 0 ? 0 : x > w ? w : x
|
||||
y = y < 0 ? 0 : y > h ? h : y
|
||||
return { x, y }
|
||||
}
|
||||
getCurPos(dom) {
|
||||
const pos = this[dom||'handle']?.getBoundingClientRect()
|
||||
this.data = {left:this.toRound(pos.left), top:this.toRound(pos.top)}
|
||||
}
|
||||
// 小数转整数
|
||||
toRound = v => Math.round(v)
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
<side-vue v-ignore @ignore-mounted="sideMouse" @change="sideChange"></side-vue>
|
||||
|
||||
<!-- 点赞组件 -->
|
||||
<upvote-vue></upvote-vue>
|
||||
<upvote-vue ref="upvoteRef" type="2"></upvote-vue>
|
||||
|
||||
<!-- 底部工具栏 :style="dataPos.style"-->
|
||||
<!-- im-chat 聊天组件 -->
|
||||
<im-chat ref="imChatRef" @change="chatChange" />
|
||||
|
||||
<!-- 底部工具栏 -->
|
||||
<div class="tool-bottom-all" @mouseenter="mouseChange(0)" @mouseleave="mouseChange(1)">
|
||||
<div v-drag="{handle:'.tool-bottom-all', dragtime}"
|
||||
@v-drag-start="dragtime = Date.now()">
|
||||
|
@ -17,43 +20,58 @@
|
|||
<el-image :src="logo" draggable="false" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="tool-btns" v-show="!isFold">
|
||||
<el-segmented class="c-btns" v-model="tabActive" :options="btnList" size="large" block
|
||||
@change="tabChange">
|
||||
<template #default="{item}">
|
||||
<div class="c-btn flex flex-col items-center gap-2 p-2">
|
||||
<i class="iconfont" :class="item.icon" :style="item.style" />
|
||||
<span>{{item.label}}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-segmented>
|
||||
</div>
|
||||
<transition name="a-fade">
|
||||
<div class="tool-btns" v-if="!isFold">
|
||||
<el-segmented class="c-btns" v-model="tabActive" :options="btnList" size="large" block
|
||||
@change="tabChange">
|
||||
<template #default="{item}">
|
||||
<div class="c-btn flex flex-col items-center gap-2 p-2">
|
||||
<i class="iconfont" :class="item.icon" :style="item.style" />
|
||||
<span>{{item.label}}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-segmented>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 功能说明:electron 悬浮球
|
||||
import { onMounted, ref, reactive, watchEffect } from 'vue'
|
||||
import { onMounted, ref, reactive, watchEffect, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router';
|
||||
import { endClass } from '@/api/classManage'
|
||||
import logo from '@root/resources/icon.png' // logo
|
||||
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus'
|
||||
import * as classManageApi from '@/api/classManage'
|
||||
import logo from '@root/resources/logo.png' // logo
|
||||
import boardVue from './components/board.vue' // 画板-子组件
|
||||
import sideVue from './components/side.vue' // 画板-子组件
|
||||
import upvoteVue from './components/upvote.vue' // 点赞-子组件
|
||||
import imChat from './components/imChat.vue' // im-chat-子组件
|
||||
import vDrag from './directive/drag' // 自定义指令-拖拽
|
||||
import vIgnore from './directive/ignore' // 自定义指令-穿透
|
||||
import { useToolState } from '@/store/modules/tool' // 数据状态-缓存
|
||||
import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' // 相关工具
|
||||
import { ipcMsgSend, ipcMain, sessionStore } from '@/utils/tool' // 相关工具
|
||||
import MsgEnum from '@/plugins/imChat/msgEnum' // 消息头-相关定义(nuem)
|
||||
|
||||
const route = useRoute();
|
||||
const tabActive = ref('select') // 工具栏当前选中项
|
||||
const isFold = ref(false) // 折叠工具栏
|
||||
const isDrag = ref(false) // 开始拖拽
|
||||
const dragtime = ref(0) // 拖拽时间-计算点击还是拖动
|
||||
const isShow = ref(false) // 是否显示-画板
|
||||
const isOver = ref(false) // 是否下课
|
||||
const toolStore = useToolState() // 状态管理
|
||||
const boardVueRef=ref(null) // 画板ref
|
||||
const btnList = [ // 工具栏按钮列表
|
||||
const upvoteRef = ref(null) // 点赞 ref
|
||||
const imChatRef = ref(null) // im-chat ref
|
||||
const classObj = reactive({ // 课程相关
|
||||
id: route.query.reservId, // 课程id
|
||||
data: {} // 课程信息
|
||||
})
|
||||
const msgIds = [] // 消息id
|
||||
const electron = window.electron // electron
|
||||
const btnList = [ // 工具栏按钮列表
|
||||
{ label: '选择', value: 'select', icon: 'icon-mouse' },
|
||||
{ label: '画笔', value: 'brush', icon: 'icon-huabi' },
|
||||
{ label: '板擦', value: 'erase', icon: 'icon-xiangpica' },
|
||||
|
@ -64,52 +82,122 @@ const btnList = [ // 工具栏按钮列表
|
|||
]
|
||||
// === 页面加载完毕 ===
|
||||
onMounted(async() => {
|
||||
resetStatus() // 开启重置状态-监听
|
||||
if (!electron) return // 浏览器端
|
||||
window.test = sessionStore
|
||||
window.test1 = toolStore
|
||||
getClassInfo() // 获取课堂详情 ex3
|
||||
resetStatus() // 开启重置状态-监听
|
||||
})
|
||||
|
||||
|
||||
// ==== 方法 ===
|
||||
// const test = (e) => { console.log('test', e) }
|
||||
// 获取课堂信息
|
||||
const getClassInfo = async () => {
|
||||
const { data } = await classManageApi.getClassInfo(classObj.id)
|
||||
classObj.data = data
|
||||
// 群id
|
||||
let timGroupId = data?.ex3 || ''
|
||||
console.log('获取群ID:', timGroupId)
|
||||
const chat = await imChatRef.value?.initImChat(timGroupId) // 初始化im-chat
|
||||
if (!timGroupId) timGroupId = chat?.timGroupId
|
||||
if (!timGroupId) return ElMessage.error('房间创建-失败')
|
||||
classManageApi.startClass(classObj.id, timGroupId) // 开始上课
|
||||
}
|
||||
// 切换tab-change
|
||||
const tabChange = (val) => {
|
||||
const bool = !toolStore.isPdfWin && !toolStore.showBoardAll
|
||||
if(bool) toolStore.showBoardAll = true
|
||||
// ipcMsgSend('tool-sphere:close')
|
||||
console.log('tabChange:', val, bool)
|
||||
toolStore.model = val // 存储当前tab
|
||||
}
|
||||
// logo 点击-事件 折叠|展开
|
||||
const logoHandle = (e,t) => {
|
||||
if (Date.now() - dragtime.value < 200) {
|
||||
isFold.value = !isFold.value
|
||||
setTimeout(() => {
|
||||
// 处理: 工具被拖动到右侧时功能被遮挡
|
||||
const dom = document.querySelector('.tool-bottom-all')
|
||||
const { x } = dom.getBoundingClientRect()
|
||||
const w = window.innerWidth - (470 || 80)
|
||||
// if (x > w) dom.style.left = `${w}px`
|
||||
if (x > w) { // 动画
|
||||
let left = x
|
||||
const animatFn = () => {
|
||||
left-=30
|
||||
if (left < w) left == w
|
||||
dom.style.left = `${left}px`
|
||||
if (left > w) requestAnimationFrame(animatFn)
|
||||
}
|
||||
requestAnimationFrame(animatFn)
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
// 底部工具栏:移入移出-是否穿透
|
||||
const mouseChange = (bool) => {
|
||||
let resBool = false
|
||||
if (bool == 0) return setIgnore(resBool) // 移入不穿透
|
||||
if (tabActive.value == 'select') resBool = !!bool
|
||||
if (!isShow.value) resBool = !!bool
|
||||
else {
|
||||
if (!isShow.value) resBool = !!bool
|
||||
// pdf强行穿透
|
||||
const isPdf = !resBool && toolStore.isPdfWin
|
||||
if (isPdf) resBool = true
|
||||
}
|
||||
// console.log('mouseChange:', bool, resBool)
|
||||
setIgnore(resBool)
|
||||
}
|
||||
// im-chat: 聊天事件 {type, data}
|
||||
const chatChange = (type, data, ...args) => {
|
||||
if (type == 'createGroup') { // 创建群-监听
|
||||
console.log('创建群:', data)
|
||||
!!data && classManageApi.startClass(classObj.id, data)
|
||||
} else if (type == 'msg') { // im-chat 消息监听
|
||||
if (!data) return // 没有msg数据 message_msg_id
|
||||
const msgId = (args||[])[0].message_msg_id
|
||||
const { msgKey:head, msgcontent:msg, senduserid:sendId, msgType } = data
|
||||
switch(head) {
|
||||
case MsgEnum.HEADS.MSG_0001: // 点赞
|
||||
case MsgEnum.HEADS.MSG_0002: // 疑惑
|
||||
// console.log('点赞:', data)
|
||||
if(msgIds.includes(msgId)) return // 忽略重复-点赞消息
|
||||
upvoteRef.value.trigger(head, data.name) // 触发点赞|疑惑
|
||||
if (msgIds.length >= 100) msgIds.shift() // 删除第一个
|
||||
msgIds.push(msgId) // 添加到数组
|
||||
break
|
||||
default:
|
||||
console.log('未知消息:', data)
|
||||
break
|
||||
}
|
||||
}
|
||||
// console.log('im-chat-sphere:', type, data)
|
||||
}
|
||||
|
||||
// 忽略鼠标穿透
|
||||
const setIgnore = (bool) => {ipcMsgSend('tool-sphere:set:ignore', bool)}
|
||||
// 重置状态: 鼠标|画板
|
||||
const resetStatus = () => {
|
||||
if (toolStore.isToolWin) return // 已经打开过-忽略
|
||||
ipcMain?.handle?.('tool-sphere:reset', () => {
|
||||
setTimeout(() => {
|
||||
boardVueRef.value.handleMode(tabActive.value)
|
||||
mouseChange(1)
|
||||
}, 500)
|
||||
})
|
||||
// 以下代码废弃-暂时无用
|
||||
// ipcMain?.removeHandler('tool-sphere:reset') // 避免已绑定,先移除在绑定
|
||||
// ipcMain?.handle?.('tool-sphere:reset', () => {
|
||||
// setTimeout(() => {
|
||||
// boardVueRef.value.handleMode(tabActive.value)
|
||||
// mouseChange(1)
|
||||
// }, 500)
|
||||
// })
|
||||
toolStore.isToolWin = true // 标记状态
|
||||
}
|
||||
// 侧边工具栏: 移入移出
|
||||
const sideMouse = e => {
|
||||
const {type} = e.detail
|
||||
if (isOver.value && type == 'mouseleave') {
|
||||
setIgnore(false) // 关闭窗口鼠标-穿透
|
||||
return
|
||||
}
|
||||
mouseChange(type == 'mouseleave')
|
||||
}
|
||||
// 侧边工具栏: 操作变化
|
||||
const sideChange = o => {
|
||||
const sideChange = async o => {
|
||||
// console.log(o)
|
||||
switch(o.prop) {
|
||||
case 'resource': // 资源
|
||||
|
@ -119,9 +207,32 @@ const sideChange = o => {
|
|||
case 'win': // 窗口
|
||||
break
|
||||
case 'over': // 下课
|
||||
toolStore.isToolWin = false
|
||||
endClass(route.query.reservId)
|
||||
ipcMsgSend('tool-sphere:close')
|
||||
isOver.value = true
|
||||
ElMessageBox.confirm('确认结束课程吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() // 发送下课消息
|
||||
// const elMsg = ElMessage.warning({duration:0,message:'正在下课...'})
|
||||
// const elMsg = ElLoading.service({lock: true, text: '正在下课...', background: 'rgba(0, 0, 0, 0.7)'})
|
||||
// 延迟2秒后关闭窗口,如果马上解散群,会导致群组不存在
|
||||
setTimeout(async() => {
|
||||
// elMsg.close()
|
||||
// toolStore.isToolWin = false
|
||||
toolStore.resetDef() // 重置状态
|
||||
await imChatRef.value?.deleteGroup() // 解散群
|
||||
await imChatRef.value?.logout() // 退出im
|
||||
await classManageApi.endClass(route.query.reservId)
|
||||
ipcMsgSend('tool-sphere:close') // 关闭窗口
|
||||
}, 500);
|
||||
|
||||
// isOver.value = false
|
||||
// setIgnore(true) // 开启窗口鼠标-穿透
|
||||
}).catch(() => {
|
||||
isOver.value = false
|
||||
setIgnore(true) // 开启窗口鼠标-穿透
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -131,6 +242,12 @@ watchEffect(() => {
|
|||
// 不同的时候, 更新值: 是否显示-画板
|
||||
const show = !toolStore.isPdfWin && toolStore.showBoardAll
|
||||
if (show != isShow.value) isShow.value = show
|
||||
if (isShow.value) {
|
||||
nextTick(() => {
|
||||
mouseChange(1) // 移除工具栏
|
||||
boardVueRef.value.handleMode(tabActive.value)
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -180,4 +297,15 @@ watchEffect(() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
.a-fade-leave-active,.a-fade-enter-active{
|
||||
transition: all .3s;
|
||||
}
|
||||
.a-fade-enter-from,.a-fade-leave-to{
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
.a-fade-enter-to,.a-fade-leave-from{
|
||||
width: 350px;
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue