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)
}
// 监听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
@ -124,5 +136,10 @@ const filterByKey = (obj, key, value) => {
}
return res;
}
// 获取对象值
const getObjValue = (obj, key) => {
}
// 对象克隆
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 { ipcRenderer } = isNode?require('electron'):window.electron || {}
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 // 持久化存储
import store from './store'
// 常用变量
const BaseUrl = isNode?process.env['ELECTRON_RENDERER_URL']+'/#':''
const isDev = isNode?process.env.NODE_ENV !== 'production':''
// const toolState = useToolState() // 获取store状态
const appPath = isNode?Remote.app.getAppPath():'' // 应用目录
// 暴露Remote中的属性
@ -221,6 +221,7 @@ export function toolWindow({url, isConsole, isWeb=true, option={}}) {
* @param {*} win 窗口对象
*/
const eventHandles = (type, win) => {
const toolState = useToolState() // 获取store状态
const winAll = Remote.BrowserWindow.getAllWindows()
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:reset')
// Remote.ipcMain.removeAllListeners() // 移除所有监听事件
// 设置状态(再次设置-防止未设置到)
if(toolState.isToolWin) toolState.isToolWin = false
// sessionStore.set('isToolWin', false)
}
}
publicMethods(on) // 加载公共方法
@ -269,6 +273,8 @@ const eventHandles = (type, win) => {
const on = {
onClosed: () => {
Remote.ipcMain.removeHandler('open-PDF:minimize')
// 设置状态(再次设置-防止未设置到)
if(toolState.isPdfWin) toolState.isPdfWin = false
}
}
publicMethods(on) // 加载公共方法

View File

@ -31,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('进行中')
@ -51,21 +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(
() => [dataList,toolStore.isToolWin],
() => {
console.log('====',toolStore)
setTimeout(()=>{
getSelfReserv().then((res) => {
dataList.value = [...res.data]
})
getData() //
},300)
}
)
onMounted(() => {
getSelfReserv().then((res) => {
dataList.value = res.data
})
getData() //
})
</script>

View File

@ -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,18 +62,20 @@ const deleteReserv = () => {
})
}
const startClassR = (item) => {
startClass(item.id).then((res) => {
if (res.data === true) {
// 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)
// startClass(props.item.id)
listEntpcourse({
evalid: props.item.ex2,
edituserid: useUserStore().user.userId,

View File

@ -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>
@ -630,6 +630,7 @@ export default {
cursor: pointer !important;
}
& > :deep(span) {
pointer-events: none;
flex-direction: column !important;
font-size: 12px;
}

View File

@ -96,10 +96,11 @@ const getClassInfo = async () => {
const { data } = await classManageApi.getClassInfo(classObj.id)
classObj.data = data
// id
let timGroupId = data?.ex3 || ''
let timGroupId = data?.ex3 || '@TGS#36AICW6O6'
console.log('获取群ID:', timGroupId)
const chat = await imChatRef.value?.initImChat(timGroupId) // im-chat
if (!timGroupId) timGroupId = chat?.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