ppt上课-资源更新
This commit is contained in:
parent
fbacb32940
commit
7e18f2e9d9
|
@ -23,7 +23,9 @@ const defaultData = {
|
||||||
curNode: null, // 当前选中的节点
|
curNode: null, // 当前选中的节点
|
||||||
defaultExpandedKeys: [], //展开的节点
|
defaultExpandedKeys: [], //展开的节点
|
||||||
subjectTree: [] // "树结构" 章节
|
subjectTree: [] // "树结构" 章节
|
||||||
}
|
},
|
||||||
|
env: {}, // 不走同步 Pinia - 变量
|
||||||
|
curr: {} // 不走同步 Pinia - 当前信息
|
||||||
},
|
},
|
||||||
local: { // 本地(永久localStorage)
|
local: { // 本地(永久localStorage)
|
||||||
},
|
},
|
||||||
|
|
|
@ -213,7 +213,7 @@ const delStudent = (index) => {
|
||||||
const onSubmit = (formEl) => {
|
const onSubmit = (formEl) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
// 课堂id
|
// 课堂id
|
||||||
const classRoomId = sessionStore.get('curClassRoom.id')
|
const classRoomId = sessionStore.get('curr.curClassRoom.id')
|
||||||
formEl.validate((valid) => {
|
formEl.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@ import _ from 'lodash'
|
||||||
// import { diff } from 'jsondiffpatch'
|
// import { diff } from 'jsondiffpatch'
|
||||||
// const Remote = isNode?require('@electron/remote'):{} // 远程模块
|
// const Remote = isNode?require('@electron/remote'):{} // 远程模块
|
||||||
|
|
||||||
const exArrs = ['subject'] // 不需要同步key-排除
|
const exArrs = ['subject','env','curr'] // 不需要同步key-排除
|
||||||
|
|
||||||
export function shareStorePlugin({store}) {
|
export function shareStorePlugin({store}) {
|
||||||
store.$subscribe((mutation, state) => { // 自动同步
|
store.$subscribe((mutation, state) => { // 自动同步
|
||||||
|
@ -60,7 +60,7 @@ function stateSyncWatch(storeName, newState) {
|
||||||
const diffData = findDifferences(oldState, newState)
|
const diffData = findDifferences(oldState, newState)
|
||||||
if(!_.keys(diffData).length) return // 没有变化就终止执行
|
if(!_.keys(diffData).length) return // 没有变化就终止执行
|
||||||
// 数据处理: 找出差异
|
// 数据处理: 找出差异
|
||||||
// console.log('state-change-diffData', diffData)
|
console.log('state-change-diffData', diffData, newState)
|
||||||
try {
|
try {
|
||||||
let pinaValue = {} // store pina状态管理需要的数据格式
|
let pinaValue = {} // store pina状态管理需要的数据格式
|
||||||
// 数据转换处理
|
// 数据转换处理
|
||||||
|
@ -83,7 +83,7 @@ function stateSyncWatch(storeName, newState) {
|
||||||
// 没变化也终止执行
|
// 没变化也终止执行
|
||||||
if (_.isEqual(oldValAll, newValAll)) return
|
if (_.isEqual(oldValAll, newValAll)) return
|
||||||
// 更新本地数据-session
|
// 更新本地数据-session
|
||||||
sessionStore.set(key, newValAll)
|
sessionStore.set(key, newValAll || null)
|
||||||
|
|
||||||
// 数据处理: pina-store
|
// 数据处理: pina-store
|
||||||
const jsonStr = JSON.stringify(pinaValue) // 从新组装-json数据
|
const jsonStr = JSON.stringify(pinaValue) // 从新组装-json数据
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { sessionStore } from '@/utils/store'
|
||||||
|
|
||||||
// 默认数据
|
// 默认数据
|
||||||
const defData = sessionStore.store || {}
|
const defData = sessionStore.store || {}
|
||||||
const exArrs = ['subject']
|
const exArrs = ['subject','env','curr']
|
||||||
exArrs.forEach(k => Object.keys(defData).includes(k) && (delete defData[k]))
|
exArrs.forEach(k => Object.keys(defData).includes(k) && (delete defData[k]))
|
||||||
|
|
||||||
// 延时
|
// 延时
|
||||||
|
|
|
@ -18,7 +18,9 @@ const loadPdfAnimation = (path) => {
|
||||||
},2000)
|
},2000)
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const bookpath = localStorage.getItem('PDF-LOCAL-PATH')
|
console.log('路由参数====',route);
|
||||||
|
const { pdfUrl } = route.query
|
||||||
|
const bookpath = !!pdfUrl ? pdfUrl : localStorage.getItem('PDF-LOCAL-PATH')
|
||||||
// const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + bookpath
|
// const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + bookpath
|
||||||
// const isDev = process.env.NODE_ENV == 'development'
|
// const isDev = process.env.NODE_ENV == 'development'
|
||||||
// if (isDev)
|
// if (isDev)
|
||||||
|
@ -28,7 +30,7 @@ onMounted(() => {
|
||||||
// const newpath = getStaticUrl(bookpath, 'user', 'selfFile', true)
|
// const newpath = getStaticUrl(bookpath, 'user', 'selfFile', true)
|
||||||
loadPdfAnimation(bookpath)
|
loadPdfAnimation(bookpath)
|
||||||
// pdfUrl.value = filepath
|
// pdfUrl.value = filepath
|
||||||
// console.log('课件路径',newpath);
|
// console.log('课件路径',bookpath);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -636,6 +636,10 @@ export default {
|
||||||
const path = await this.getBookPathFromServer(data.textBook.curBookPath)
|
const path = await this.getBookPathFromServer(data.textBook.curBookPath)
|
||||||
const localpath = getAppInstallUrl('pdfjs-dist/web/viewer.html', 'user', '\\out\\renderer', true) + "?file="
|
const localpath = getAppInstallUrl('pdfjs-dist/web/viewer.html', 'user', '\\out\\renderer', true) + "?file="
|
||||||
localStorage.setItem('PDF-LOCAL-PATH',localpath + encodeURIComponent(import.meta.env.VITE_APP_RES_FILE_PATH + path))
|
localStorage.setItem('PDF-LOCAL-PATH',localpath + encodeURIComponent(import.meta.env.VITE_APP_RES_FILE_PATH + path))
|
||||||
|
// 相关数据存储session中
|
||||||
|
sessionStore.set('curr.textBook', data.textBook)
|
||||||
|
sessionStore.set('env.pdfBasePath', localpath)
|
||||||
|
sessionStore.set('env.fileBasePath', import.meta.env.VITE_APP_RES_FILE_PATH)
|
||||||
this.checkFileList = []
|
this.checkFileList = []
|
||||||
this.currentWorkList = []
|
this.currentWorkList = []
|
||||||
let cata = parseCataByNode(data.node)
|
let cata = parseCataByNode(data.node)
|
||||||
|
|
|
@ -26,6 +26,23 @@
|
||||||
<div class="content" v-if="isVisible">
|
<div class="content" v-if="isVisible">
|
||||||
<slot name="content">
|
<slot name="content">
|
||||||
<homework v-if="activeObj?.prop === 'resource'" :curNode="curNode" @closeActive="closeActive" />
|
<homework v-if="activeObj?.prop === 'resource'" :curNode="curNode" @closeActive="closeActive" />
|
||||||
|
<template v-else-if="activeObj?.prop === 'book'">
|
||||||
|
<div class="item">
|
||||||
|
<div class="item-title">
|
||||||
|
<h3>{{ curNode.label }}</h3>
|
||||||
|
<span class="sub">{{ curNode.edusubject }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="item-content" v-loading="loading">
|
||||||
|
<el-scrollbar height="300px">
|
||||||
|
<div class="item-content-item" v-for="item in cData">
|
||||||
|
<el-tag effect="dark">{{ item.tag }}</el-tag>
|
||||||
|
<span>{{ curNode.bookName }}</span>
|
||||||
|
<el-button :color="item.color||'#349d44'" size="small" @click="openFile(item)">打开</el-button>
|
||||||
|
</div>
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<span v-else style="color:red;">{{activeObj}}</span>
|
<span v-else style="color:red;">{{activeObj}}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,6 +54,8 @@
|
||||||
import { computed, defineProps, ref, reactive, watchEffect, onMounted} from 'vue'
|
import { computed, defineProps, ref, reactive, watchEffect, onMounted} from 'vue'
|
||||||
import { sessionStore } from '@/utils/store'
|
import { sessionStore } from '@/utils/store'
|
||||||
import homework from './homework.vue';
|
import homework from './homework.vue';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
import { toRoter } from '@/utils/tool' // 相关工具
|
||||||
|
|
||||||
// 功能说明:侧边-工具栏
|
// 功能说明:侧边-工具栏
|
||||||
const colors = ['#409EFF','#00f389', '#ff7f00', '#ffff00', '#00baff', '#13b189', '#F56C6C']
|
const colors = ['#409EFF','#00f389', '#ff7f00', '#ffff00', '#00baff', '#13b189', '#F56C6C']
|
||||||
|
@ -49,7 +68,7 @@ const props = defineProps({
|
||||||
data: { // 数据
|
data: { // 数据
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [
|
default: () => [
|
||||||
{ label: '资源', prop: 'book', isExtra: true, icon: 'icon--kejian' },
|
{ label: '资源', prop: 'book', icon: 'icon--kejian' },
|
||||||
{ label: '活动', prop: 'resource', icon: 'icon-kechengziyuan1' },
|
{ label: '活动', prop: 'resource', icon: 'icon-kechengziyuan1' },
|
||||||
// { label: '互动', prop: 'interact', icon: 'icon-hudong' },
|
// { label: '互动', prop: 'interact', icon: 'icon-hudong' },
|
||||||
// { label: '窗口', prop: 'win', icon: 'icon-tubiaozhizuomobanyihuifu-' },
|
// { label: '窗口', prop: 'win', icon: 'icon-tubiaozhizuomobanyihuifu-' },
|
||||||
|
@ -63,8 +82,9 @@ const btnRef = ref(null) // 按钮元素-ref
|
||||||
const topPos = ref(30) // 顶部距离-内容的距离
|
const topPos = ref(30) // 顶部距离-内容的距离
|
||||||
const hPost = ref(0) // 顶部距离-内容的距离
|
const hPost = ref(0) // 顶部距离-内容的距离
|
||||||
const isFold = ref(false) // 是否折叠
|
const isFold = ref(false) // 是否折叠
|
||||||
|
const cData = ref(null) // 内容数据
|
||||||
|
const loading = ref(false) // 加载中
|
||||||
let posBtnAll = {} // 存储位置
|
let posBtnAll = {} // 存储位置
|
||||||
|
|
||||||
let curNode = null // 当前节点(作业需要)
|
let curNode = null // 当前节点(作业需要)
|
||||||
// === 计算属性 ===
|
// === 计算属性 ===
|
||||||
const list = computed(() => props.data.map((o,i) => {
|
const list = computed(() => props.data.map((o,i) => {
|
||||||
|
@ -89,7 +109,16 @@ const getStyle = (style,index) => {
|
||||||
return `${style}${style.endsWith(';')?'':';'}color:${color};`
|
return `${style}${style.endsWith(';')?'':';'}color:${color};`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 事件
|
// 获取内容数据
|
||||||
|
const getContent = o => {
|
||||||
|
loading.value = true
|
||||||
|
const { bookName } = curNode
|
||||||
|
const textbook = { type: 'book', tag: '教材', name: bookName }
|
||||||
|
const course = { type: 'course', tag: '课标', name: bookName }
|
||||||
|
cData.value = [textbook, course]
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
// 回调: 菜单点击
|
||||||
const clickHandel = (o, e) => {
|
const clickHandel = (o, e) => {
|
||||||
if (!o.isExtra) { // 忽略其他操作: 打开内容窗口,指示器指向当前
|
if (!o.isExtra) { // 忽略其他操作: 打开内容窗口,指示器指向当前
|
||||||
const node = e.target.parentNode.getBoundingClientRect()
|
const node = e.target.parentNode.getBoundingClientRect()
|
||||||
|
@ -98,15 +127,36 @@ const clickHandel = (o, e) => {
|
||||||
activeObj.value = o
|
activeObj.value = o
|
||||||
const nodeH = parseInt(node.height / 2) // 高度的一半
|
const nodeH = parseInt(node.height / 2) // 高度的一半
|
||||||
topPos.value = Math.round(parseInt(node.top) - posBtnAll.top + nodeH)
|
topPos.value = Math.round(parseInt(node.top) - posBtnAll.top + nodeH)
|
||||||
|
|
||||||
|
// 获取内容数据
|
||||||
|
if (['book'].includes(o.prop)) getContent(o)
|
||||||
}
|
}
|
||||||
emit('change', o)
|
emit('change', o)
|
||||||
}
|
}
|
||||||
|
// 回调: 打开文件
|
||||||
|
const openFile = item => {
|
||||||
|
if (['book', 'course'].includes(item.type)) {
|
||||||
|
const isBool = sessionStore.has('curr.textBook')
|
||||||
|
if (!isBool) return ElMessage.error('打开失败,请重试!')
|
||||||
|
const textBook = sessionStore.get('curr.textBook')
|
||||||
|
const pdfBasePath = sessionStore.get('env.pdfBasePath')
|
||||||
|
const fileBasePath = sessionStore.get('env.fileBasePath')
|
||||||
|
let path = ''
|
||||||
|
if (item.type == 'book') path = (textBook.curBookPath||'').replace('.txt', '.pdf')
|
||||||
|
else path = textBook.curBookPath.replace(/([^-]*)$/, '课标.pdf')
|
||||||
|
const url = pdfBasePath + encodeURIComponent(`${fileBasePath}${path}`)
|
||||||
|
// 打开新窗口
|
||||||
|
toRoter(`${process.env['ELECTRON_RENDERER_URL']}/#/fullscreenpdf?pdfUrl=${url}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 回调: 关闭事件
|
||||||
const closeActive = () =>{
|
const closeActive = () =>{
|
||||||
if (isVisible.value) { // 打开状态,关闭
|
if (isVisible.value) { // 打开状态,关闭
|
||||||
isVisible.value = false
|
isVisible.value = false
|
||||||
emit('change', { prop: 'close' })
|
emit('change', { prop: 'close' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({closeActive})
|
defineExpose({closeActive})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -177,5 +227,33 @@ defineExpose({closeActive})
|
||||||
top: var(--top);
|
top: var(--top);
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
|
.content{
|
||||||
|
// 每个菜单
|
||||||
|
.item{
|
||||||
|
margin: 0 15px;
|
||||||
|
&-title{
|
||||||
|
margin-bottom: 20px;
|
||||||
|
h3{
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.sub{
|
||||||
|
color: #cecece;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-content-item{
|
||||||
|
display: flex;
|
||||||
|
background-color: #384342;
|
||||||
|
padding: 15px 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -103,7 +103,7 @@ onMounted(async() => {
|
||||||
const getClassInfo = async () => {
|
const getClassInfo = async () => {
|
||||||
const { data } = await classManageApi.getClassInfo(classObj.id)
|
const { data } = await classManageApi.getClassInfo(classObj.id)
|
||||||
classObj.data = data
|
classObj.data = data
|
||||||
sessionStore.set('curClassRoom', classObj) // 课堂信息-缓存
|
sessionStore.set('curr.curClassRoom', classObj) // 课堂信息-缓存
|
||||||
// 群id
|
// 群id
|
||||||
let timGroupId = data?.ex3 || ''
|
let timGroupId = data?.ex3 || ''
|
||||||
console.log('获取群ID:', timGroupId)
|
console.log('获取群ID:', timGroupId)
|
||||||
|
@ -208,14 +208,7 @@ const sideChange = async o => {
|
||||||
// console.log(o)
|
// console.log(o)
|
||||||
switch(o.prop) {
|
switch(o.prop) {
|
||||||
case 'book':
|
case 'book':
|
||||||
if(isOpenBook.value) {
|
isMask.value = !isMask.value
|
||||||
isOpenBook.value = false
|
|
||||||
ElMessage.info('已经打开课本了哦')
|
|
||||||
}else {
|
|
||||||
// createWindow('fullScreen-PDF',{url: '/fullscreenpdf'})
|
|
||||||
toRoter(`${process.env['ELECTRON_RENDERER_URL']}/#/fullscreenpdf`)
|
|
||||||
isOpenBook.value = true
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
case 'close': // 关闭
|
case 'close': // 关闭
|
||||||
maskChange(false)
|
maskChange(false)
|
||||||
|
|
Loading…
Reference in New Issue