This commit is contained in:
zdg 2024-09-03 18:02:46 +08:00
parent b6504e114f
commit 7894214859
6 changed files with 58 additions and 23 deletions

View File

@ -68,6 +68,18 @@ function stateSyncInit(wid, store) {
ipcRenderer.invoke('pinia-state-init', wid, storeName, curJson) 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) { function stateChange(store) {
const storeName = store.$id const storeName = store.$id
@ -124,5 +136,10 @@ const filterByKey = (obj, key, value) => {
} }
return res; return res;
} }
// 获取对象值
const getObjValue = (obj, key) => {
}
// 对象克隆 // 对象克隆
const objClone = (obj) => JSON.parse(JSON.stringify(obj)) const objClone = (obj) => JSON.parse(JSON.stringify(obj))

View File

@ -11,13 +11,13 @@ const path = isNode?require('path'):{}
const Remote = isNode?require('@electron/remote'):{} const Remote = isNode?require('@electron/remote'):{}
const { ipcRenderer } = isNode?require('electron'):window.electron || {} const { ipcRenderer } = isNode?require('electron'):window.electron || {}
const API = isNode?window.api:{} // preload-api const API = isNode?window.api:{} // preload-api
// import { useToolState } from '@/store/modules/tool' // 获取store状态 import { useToolState } from '@/store/modules/tool' // 获取store状态
// const Store = isNode?require('electron-store'):null // 持久化存储 // const Store = isNode?require('electron-store'):null // 持久化存储
import store from './store' import store from './store'
// 常用变量 // 常用变量
const BaseUrl = isNode?process.env['ELECTRON_RENDERER_URL']+'/#':'' const BaseUrl = isNode?process.env['ELECTRON_RENDERER_URL']+'/#':''
const isDev = isNode?process.env.NODE_ENV !== 'production':'' const isDev = isNode?process.env.NODE_ENV !== 'production':''
// const toolState = useToolState() // 获取store状态
const appPath = isNode?Remote.app.getAppPath():'' // 应用目录 const appPath = isNode?Remote.app.getAppPath():'' // 应用目录
// 暴露Remote中的属性 // 暴露Remote中的属性
@ -221,6 +221,7 @@ export function toolWindow({url, isConsole, isWeb=true, option={}}) {
* @param {*} win 窗口对象 * @param {*} win 窗口对象
*/ */
const eventHandles = (type, win) => { const eventHandles = (type, win) => {
const toolState = useToolState() // 获取store状态
const winAll = Remote.BrowserWindow.getAllWindows() const winAll = Remote.BrowserWindow.getAllWindows()
const mainWin = winAll.find(o => o.type == 'main') // 主窗口对象 const mainWin = winAll.find(o => o.type == 'main') // 主窗口对象
// 公共方法 // 公共方法
@ -250,6 +251,9 @@ const eventHandles = (type, win) => {
Remote.ipcMain.removeHandler('tool-sphere:set:ignore', setIgnore) Remote.ipcMain.removeHandler('tool-sphere:set:ignore', setIgnore)
Remote.ipcMain.removeHandler('tool-sphere:reset') Remote.ipcMain.removeHandler('tool-sphere:reset')
// Remote.ipcMain.removeAllListeners() // 移除所有监听事件 // Remote.ipcMain.removeAllListeners() // 移除所有监听事件
// 设置状态(再次设置-防止未设置到)
if(toolState.isToolWin) toolState.isToolWin = false
// sessionStore.set('isToolWin', false)
} }
} }
publicMethods(on) // 加载公共方法 publicMethods(on) // 加载公共方法
@ -269,6 +273,8 @@ const eventHandles = (type, win) => {
const on = { const on = {
onClosed: () => { onClosed: () => {
Remote.ipcMain.removeHandler('open-PDF:minimize') Remote.ipcMain.removeHandler('open-PDF:minimize')
// 设置状态(再次设置-防止未设置到)
if(toolState.isPdfWin) toolState.isPdfWin = false
} }
} }
publicMethods(on) // 加载公共方法 publicMethods(on) // 加载公共方法

View File

@ -31,6 +31,7 @@ import { getSelfReserv } from '@/api/classManage'
import ReservItem from '@/views/classManage/reserv-item.vue' import ReservItem from '@/views/classManage/reserv-item.vue'
import Reserv from '@/views/prepare/container/reserv.vue' import Reserv from '@/views/prepare/container/reserv.vue'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { sessionStore } from '@/utils/tool'
const reservDialog = ref(null) const reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束']) const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中') const tabActive = ref('进行中')
@ -51,21 +52,27 @@ const doneDataList = computed(() => {
return item.status === '已结束' 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() const toolStore = useToolState()
watch( watch(
() => [dataList,toolStore.isToolWin], () => [dataList,toolStore.isToolWin],
() => { () => {
console.log('====',toolStore)
setTimeout(()=>{ setTimeout(()=>{
getSelfReserv().then((res) => { getData() //
dataList.value = [...res.data]
})
},300) },300)
} }
) )
onMounted(() => { onMounted(() => {
getSelfReserv().then((res) => { getData() //
dataList.value = res.data
})
}) })
</script> </script>

View File

@ -20,14 +20,14 @@
</div> </div>
</div> </div>
<div class="class-reserv-item-tool"> <div class="class-reserv-item-tool">
<el-button v-if="item.status !== '已结束'" type="primary" @click="startClassR(item)" <el-button v-if="item.status !== '已结束'" :disabled="toolStore.isToolWin" type="primary" @click="startClassR(item)"
>上课</el-button >{{item.status == '上课中'?'上课中':'上课'}}</el-button
> >
<el-button v-if="item.status === '未开始'" @click="openEdit">编辑</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 v-if="item.status === '上课中'" type="info" @click="endClassR(item)"
>下课</el-button >下课</el-button
>--> >-->
<el-button type="danger" @click="deleteReserv">删除</el-button> <el-button v-if="item.status!='上课中'" type="danger" @click="deleteReserv">删除</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -46,6 +46,7 @@ const props = defineProps({
} }
}) })
const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH
const toolStore = useToolState() // -tool
const openEdit = () => { const openEdit = () => {
emit('openEdit', props.item) emit('openEdit', props.item)
} }
@ -61,18 +62,20 @@ const deleteReserv = () => {
}) })
} }
const startClassR = (item) => { const startClassR = (item) => {
startClass(item.id).then((res) => { // startClass(item.id).then((res) => {
if (res.data === true) { // if (res.data === true) {
item.status = '上课中' // item.status = ''
openLesson() // openLesson()
} // }
}) // })
item.status = '上课中'
openLesson()
} }
// const toolStore = useToolState() // const toolStore = useToolState()
let wins = null; let wins = null;
// - // -
const openLesson = () => { const openLesson = () => {
startClass(props.item.id) // startClass(props.item.id)
listEntpcourse({ listEntpcourse({
evalid: props.item.ex2, evalid: props.item.ex2,
edituserid: useUserStore().user.userId, edituserid: useUserStore().user.userId,

View File

@ -20,11 +20,11 @@
</div> </div>
<el-button <el-button
:type="!curClassReserv.id ? 'info' : 'primary'" :type="!curClassReserv.id ? 'info' : 'primary'"
:disabled="!curClassReserv.id" :disabled="!curClassReserv.id||toolStore.isToolWin"
class="to-class-btn" class="to-class-btn"
@click="openLesson" @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.classDay }} {{ getWeekday1(curClassReserv.classDay) }}</label>
<label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label> <label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label>
</el-button> </el-button>
@ -630,6 +630,7 @@ export default {
cursor: pointer !important; cursor: pointer !important;
} }
& > :deep(span) { & > :deep(span) {
pointer-events: none;
flex-direction: column !important; flex-direction: column !important;
font-size: 12px; font-size: 12px;
} }

View File

@ -96,10 +96,11 @@ const getClassInfo = async () => {
const { data } = await classManageApi.getClassInfo(classObj.id) const { data } = await classManageApi.getClassInfo(classObj.id)
classObj.data = data classObj.data = data
// id // id
let timGroupId = data?.ex3 || '' let timGroupId = data?.ex3 || '@TGS#36AICW6O6'
console.log('获取群ID:', timGroupId) console.log('获取群ID:', timGroupId)
const chat = await imChatRef.value?.initImChat(timGroupId) // im-chat // const chat = await imChatRef.value?.initImChat(timGroupId) // im-chat
if (!timGroupId) timGroupId = chat?.timGroupId // if (!timGroupId) timGroupId = chat?.timGroupId
if (!timGroupId) return ElMessage.error('房间创建-失败')
classManageApi.startClass(classObj.id, timGroupId) // classManageApi.startClass(classObj.id, timGroupId) //
} }
// tab-change // tab-change