Compare commits

..

No commits in common. "99ee438fd7fe3ebdf1ca861e794425b815921589" and "7fc7135d7306dfeebce405e2eba6319e05750f30" have entirely different histories.

44 changed files with 276 additions and 2095 deletions

View File

@ -1,11 +1,7 @@
appId: com.electron.app appId: com.electron.app
productName: AIx productName: AIx
directories: directories:
output: dist
buildResources: build buildResources: build
win:
executableName: AIx
icon: resources/logo2.ico
files: files:
- '!**/.vscode/*' - '!**/.vscode/*'
- '!src/*' - '!src/*'
@ -14,6 +10,9 @@ files:
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}' - '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
asarUnpack: asarUnpack:
- resources/** - resources/**
win:
executableName: AIx
icon: resources/logo2.ico
nsis: nsis:
oneClick: false oneClick: false
allowToChangeInstallationDirectory: true allowToChangeInstallationDirectory: true
@ -46,9 +45,3 @@ publish:
url: https://prev.ysaix.com:7868/src/assets/smarttalk/ url: https://prev.ysaix.com:7868/src/assets/smarttalk/
electronDownload: electronDownload:
mirror: https://npmmirror.com/mirrors/electron/ mirror: https://npmmirror.com/mirrors/electron/
# 额外依赖打包到输出目录
extraFiles:
- from: ./node_modules/im_electron_sdk/lib/
to: ./resources
filter:
- '**/*'

View File

@ -45,9 +45,3 @@ publish:
url: http://localhost:3000 url: http://localhost:3000
electronDownload: electronDownload:
mirror: https://npmmirror.com/mirrors/electron/ mirror: https://npmmirror.com/mirrors/electron/
# 额外依赖打包到输出目录
extraFiles:
- from: ./node_modules/im_electron_sdk/lib/
to: ./resources
filter:
- '**/*'

View File

@ -13,11 +13,6 @@ asarUnpack:
win: win:
executableName: AIx executableName: AIx
icon: resources/logo2.ico icon: resources/logo2.ico
extraFiles:
- from: ./node_modules/im_electron_sdk/lib/
to: ./resources
filter:
- '**/*'
nsis: nsis:
oneClick: false oneClick: false
allowToChangeInstallationDirectory: true allowToChangeInstallationDirectory: true

View File

@ -62,18 +62,5 @@
"vite-plugin-windicss": "^1.9.3", "vite-plugin-windicss": "^1.9.3",
"vue": "^3.4.30", "vue": "^3.4.30",
"windicss": "^3.5.6" "windicss": "^3.5.6"
},
"build": {
"win": {
"extraFiles": [
{
"from": "./node_modules/im_electron_sdk/lib/",
"to": "./resources",
"filter": [
"**/*"
]
}
]
}
} }
} }

View File

@ -230,6 +230,7 @@ app.on('window-all-closed', () => {
// 监听全局事件 // 监听全局事件
function handleAll() { function handleAll() {
// chat.initialize() // im-chat 实例
const chatInstance = chat.initialize() // im-chat 实例 const chatInstance = chat.initialize() // im-chat 实例
// 新窗口创建-监听 // 新窗口创建-监听
ipcMain.on('new-window', (e, data) => { ipcMain.on('new-window', (e, data) => {

View File

@ -13,11 +13,9 @@ export class ApiService {
if (!!data) config[method=='get'?'params':'data'] = data if (!!data) config[method=='get'?'params':'data'] = data
if (!!option) Object.assign(config, option) if (!!option) Object.assign(config, option)
// 特殊格式处理 // 特殊格式处理
let headers if (type == 'file') config.headers = { 'Content-Type': 'multipart/form-data' }
if (type == 'file') headers = { 'Content-Type': 'multipart/form-data' } else if (type == 'json') config.headers = { 'Content-Type': 'application/json' }
else if (type == 'json') headers = { 'Content-Type': 'application/json' } else if (type == 'form') config.headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
else if (type == 'form') headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
headers && (config.headers = { ...config.headers, ...headers })
return request(config) return request(config)
} }
} }

View File

@ -160,12 +160,10 @@ export function deleteSmartReserv(id) {
}) })
} }
export function startClass(id, ex3) { export function startClass(id, ex3) {
const params = {id}
!!ex3 && (params.ex3 = ex3)
return request({ return request({
url: '/smarttalk/classReserv/startClass', url: '/smarttalk/classReserv/startClass',
method: 'get', method: 'get',
params params: {id, ex3}
}) })
} }
export function endClass(id) { export function endClass(id) {

View File

@ -1,64 +0,0 @@
//查询第三方课件的接口
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
})
}

View File

@ -1,9 +1,9 @@
@font-face { @font-face {
font-family: "iconfont"; /* Project id 2794390 */ font-family: "iconfont"; /* Project id 2794390 */
src: url('iconfont.woff2?t=1724212790213') format('woff2'), src: url('iconfont.woff2?t=1723453634574') format('woff2'),
url('iconfont.woff?t=1724212790213') format('woff'), url('iconfont.woff?t=1723453634574') format('woff'),
url('iconfont.ttf?t=1724212790213') format('truetype'), url('iconfont.ttf?t=1723453634574') format('truetype'),
url('iconfont.svg?t=1724212790213#iconfont') format('svg'); url('iconfont.svg?t=1723453634574#iconfont') format('svg');
} }
.iconfont { .iconfont {
@ -14,90 +14,6 @@
-moz-osx-font-smoothing: grayscale; -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 { .icon-arrangement:before {
content: "\e656"; content: "\e656";
} }

File diff suppressed because one or more lines are too long

View File

@ -5,153 +5,6 @@
"css_prefix_text": "icon-", "css_prefix_text": "icon-",
"description": "", "description": "",
"glyphs": [ "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", "icon_id": "4978988",
"name": "作业-布置作业", "name": "作业-布置作业",

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 337 KiB

After

Width:  |  Height:  |  Size: 264 KiB

View File

@ -75,7 +75,8 @@ const curBookImg = ref('')
const curBookPath = ref('') const curBookPath = ref('')
// //
const volumeOne = ref([]) const volumeOne = ref([])
//
const volumeTwo = ref([])
// //
const currentNode = reactive({ const currentNode = reactive({
data:{} data:{}
@ -110,11 +111,9 @@ const getSubjectContent = async () => {
// //
await getSubject() await getSubject()
// //
/** volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
* 不区分上下册 //
* 2024/08/20调整 volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
*/
volumeOne.value = data.filter(item => item.level == 1)
getTreeData() getTreeData()
} }
@ -133,8 +132,12 @@ const changeBook = ({ id, itemtitle, avartar, fileurl }) => {
const getTreeData = () => { const getTreeData = () => {
// //
let upData = transData(volumeOne.value) let upData = transData(volumeOne.value)
if(upData.length){ let downData = transData(volumeTwo.value)
treeData.value = [...upData] if(upData.length && downData.length){
treeData.value = [...upData,...downData]
}
else if(upData.length || downData.length){
treeData.value = upData.length ? upData : downData
} }
else{ else{
treeData.value = [] treeData.value = []

View File

@ -1,288 +0,0 @@
<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'
const useThird = useThirdStore()
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(() => {
const info = localStorage.getItem('selectBookInfo')
if(info){
const {gradeName,subjectName} = JSON.parse(info)
titleName.value = `${gradeName}-${subjectName}`
}
treeLoading.value = true
})
//
watch(() => useThird,() => {
titleName.value = `${useThird.gradeName}-${useThird.subjectName}`
},{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>

View File

@ -1,67 +0,0 @@
<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">
<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'
const useThird = useThirdStore()
const emit = defineEmits(['getVertion'])
const active = ref(useThird.activeGrade || gradeList[0].value)
//
const subjectList = ref([])
//id
const textbookVersionId = ref(0)
const handleClick = (tab) => {
getSubject(tab)
}
//
const getSubject = (value) => {
getSubjects({stage:value}).then(res => {
if(res.code === 200){
subjectList.value = [...res.data]
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})
localStorage.setItem('selectBookInfo',JSON.stringify({...item,activeGrade:active.value,gradeName:gradeList[currentIndex].label}))
}
})
}
onMounted(() => {
//
handleClick(active.value)
//
const info = localStorage.getItem('selectBookInfo')
if(info){
const {activeGrade,subjectId,subjectName} = JSON.parse(info)
active.value = activeGrade
//
getTagId({subjectId:subjectId,subjectName:subjectName})
}
})
</script>
<style scoped>
</style>

View File

@ -1,30 +0,0 @@
<template>
<template v-for="item in subjectList" :key="item.subjectId">
<el-tag
type="primary"
effect="dark"
round
style="cursor: pointer;margin-right: 5px;margin-top: 5px;"
@click="clickTag(item)"
>
{{ item.subjectName }}
</el-tag>
</template>
</template>
<script setup name="selectSubject">
const props = defineProps({
subjectList: {
type: Array,
default: () => []
}
})
const emit = defineEmits(['clickTag'])
const clickTag = (item) => {
emit('clickTag',item)
}
</script>
<style scoped>
</style>

View File

@ -88,6 +88,8 @@ const curBookId = ref(-1)
const curBookName = ref('') const curBookName = ref('')
// //
const volumeOne = ref([]) const volumeOne = ref([])
//
const volumeTwo = ref([])
// //
const currentNode = reactive({ const currentNode = reactive({
data: {} data: {}
@ -125,12 +127,9 @@ const getSubjectContent = async () => {
// //
getSubject() getSubject()
// //
/** volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
* 不区分上下册 //
* 2024/08/20调整 volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
*/
volumeOne.value = data.filter(item => item.level == 1)
getTreeData() getTreeData()
} }
@ -161,8 +160,13 @@ const isHaveUnit = (id) => {
const getTreeData = () => { const getTreeData = () => {
// //
let upData = transData(volumeOne.value) let upData = transData(volumeOne.value)
if(upData.length){ let downData = transData(volumeTwo.value)
treeData.value = [...upData]
if(upData.length && downData.length){
treeData.value = [...upData,...downData]
}
else if(upData.length || downData.length){
treeData.value = upData.length ? upData : downData
} }
else{ else{
treeData.value = [] treeData.value = []

View File

@ -100,17 +100,12 @@ const renderPage = async (canvasobj) => {
}) })
} }
// //
const savaDataStore = (type) => { const savaDataStore = () => {
if(!toolState.isToolWin){ if(!toolState.isToolWin){
toolState.isPdfWin=false toolState.isPdfWin=false
toolState.showBoardAll=true // toolState.showBoardAll=true //
if(type=='rest'){ ipcRenderer.invoke('tool-sphere:reset') //tool
ipcRenderer.invoke('tool-sphere:reset') //tool ipcRenderer.send('open-PDF:minimize')
ipcRenderer.send('open-PDF:close')
}else{
ipcRenderer.invoke('open-PDF:minimize')
}
return return
} }
imgarr.value.forEach((a) => { imgarr.value.forEach((a) => {
@ -144,15 +139,8 @@ const savaDataStore = (type) => {
Promise.all(promises).then(res=>{ Promise.all(promises).then(res=>{
toolState.isPdfWin=false toolState.isPdfWin=false
toolState.showBoardAll=true // toolState.showBoardAll=true //
// ipcRenderer.send('open-PDF:minimize') ipcRenderer.invoke('tool-sphere:reset') //tool
if(type=='rest'){ ipcRenderer.send('open-PDF:minimize')
ipcRenderer.invoke('tool-sphere:reset') //tool
ipcRenderer.send('open-PDF:close')
}else{
ipcRenderer.send('open-PDF:minimize')
}
// ipcRenderer.send('open-PDF:close')
}) })
} }
const updatePage = (canvasobj) => { const updatePage = (canvasobj) => {

View File

@ -381,14 +381,14 @@ const TIMResult= {
* *
* | 名称 | 含义 | number | * | 名称 | 含义 | number |
* | ---- | ---- | ---- | * | ---- | ---- | ---- |
* | kTIMLog_Off | 关闭日志输出 | 0 | * | kTIMLog_Off | 关闭日志输出 | 0 |
* | kTIMLog_Test | 全量日志 | 1 | * | kTIMLog_Test | 失败IM SDK未初始化 | 1 |
* | kTIMLog_Verbose| 开发调试过程中一些详细信息日志 | 2 | * | kTIMLog_Verbose | 失败IM SDK未初始化 | 2 |
* | kTIMLog_Debug | 调试日志 | 3 | * | kTIMLog_Debug | 接口调用失败错误的Json格式或Json Key | 3 |
* | kTIMLog_Info | 信息日志 | 4 | * | kTIMLog_Info | 接口调用失败参数错误 | 4 |
* | kTIMLog_Warn | 警告日志 | 5 | * | kTIMLog_Warn | 接口调用失败无效的会话 | 5 |
* | kTIMLog_Error | 错误日志 | 6 | * | kTIMLog_Error | 接口调用失败无效的群组 | 6 |
* | kTIMLog_Assert | 断言日志 | 7 | * | kTIMLog_Assert | 断言日志| 7 |
*/ */
const TIMLogLevel= { const TIMLogLevel= {
kTIMLog_Off : 0, kTIMLog_Off : 0,

View File

@ -1,420 +0,0 @@
/**
* @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_OTHERS6208开发者也可以选择忽略这次错误再次登录即可
* > 用户在线情况下的互踢情况
* + 用户在设备1登录保持在线状态下该用户又在设备2登录这时用户会在设备1上强制下线收到 TIMKickedOfflineCallback 回调
* 用户在设备1上收到回调后提示用户可继续调用login上线强制设备2下线这里是在线情况下互踢过程
* > 用户离线状态互踢:
* + 用户在设备1登录没有进行logout情况下进程退出该用户在设备2登录此时由于用户不在线无法感知此事件
* 为了显式提醒用户避免无感知的互踢用户在设备1重新登录时会返回ERR_IMSDK_KICKED_BY_OTHERS6208错误码表明之前被踢是否需要把对方踢下线
* 如果需要则再次调用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设备都登录了同一帐号的ImSDKA设备添加了好友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设备都登录了同一帐号的ImSDKA设备删除了好友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设备都登录了同一帐号的ImSDKA设备更新了好友资料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 }

View File

@ -8,8 +8,6 @@
// const TimRender = require('im_electron_sdk/dist/render') // const TimRender = require('im_electron_sdk/dist/render')
import * as TYPES from './enumbers' // sdk相关枚举 import * as TYPES from './enumbers' // sdk相关枚举
import MsgEnum from './msgEnum' // 消息相关枚举(自定义) import MsgEnum from './msgEnum' // 消息相关枚举(自定义)
import IMListeners from './imLiseners' // im消息-监听器
// @ts-ignore
const API = window.api const API = window.api
// TIM生成签名 // TIM生成签名
// import * as GenerateUserSig from './userSig' // 引入签名生成器 // import * as GenerateUserSig from './userSig' // 引入签名生成器
@ -26,33 +24,29 @@ export class ImChat {
} }
defOption = { // 默认配置 defOption = { // 默认配置
// 日志等级-全量日志 // 日志等级-全量日志
log_level: TYPES.TIMLogLevel.kTIMLog_Off, log_level: TYPES.TIMLogLevel.kTIMLog_Test,
// 群组类型-会议群Meeting成员上限 6000 人 // 群组类型-会议群Meeting成员上限 6000 人
group_type: TYPES.TIMGroupType.kTIMGroup_ChatRoom, group_type: TYPES.TIMGroupType.kTIMGroup_ChatRoom,
} }
/**
* @description 构造函数
* @param {number} SDKAppID
* @param {string} userSig
* @param {string} userID
* @param {boolean} isInit
*/
constructor(SDKAppID, userSig, userID, isInit) { constructor(SDKAppID, userSig, userID, isInit) {
this.SDKAppID = SDKAppID this.SDKAppID = SDKAppID
this.userSig = userSig this.userSig = userSig
// const sig = 'eJwtjN0KgjAYQN9l16Vzcz8I3RhE9J*JV94IW-ZV6nASWfTurfTynAPnjdLNyXvoFkWIeBhN-gxK1x2cYdCMTQnlYmxW3QpjQKEo4BhjGgrKh6KfBlrtPGOMuDTYDqqfE26BWUjEeIHSrW1cL-SulHd5KI7zxDbpdh1cX0nuX7JK7HtroNerZhnnPpYz9PkCe5Mx1w__'
// this.userSig = sig
this.userID = userID this.userID = userID
// window.test = this window.test = this
if (isInit) this.init() // this.timGroupId = '@TGS#3CYWMK2ON' // 测试使用
if (isInit) return this.init()
} }
// 设置配置 // 设置配置
async setConfig() { async setConfig() {
await this.timChat.TIMSetConfig({ // TIMSetConfigParam await this.timChat.TIMSetConfig({ // TIMSetConfigParam
json_config: { // JSONCongfig json_config: { // JSONCongfig
set_config_log_level: TYPES.TIMLogLevel.kTIMLog_Test, set_config_log_level: this.defOption.log_level,
set_config_callback_log_level: TYPES.TIMLogLevel.kTIMLog_Error, set_config_callback_log_level: this.defOption.log_level,
set_config_is_log_output_console: true, // set_config_is_log_output_console: true,
// set_config_user_config: { // 用户配置 // set_config_user_config: { // 用户配置
// user_config_is_read_receipt: true, // true表示要收已读回执事件 // user_config_is_read_receipt: true, // true表示要收已读回执事件
// user_config_is_sync_report: true, // true表示服务端要删掉已读状态 // user_config_is_sync_report: true, // true表示服务端要删掉已读状态
@ -68,6 +62,7 @@ export class ImChat {
// 日志监听 // 日志监听
this.timChat.TIMSetLogCallback({ this.timChat.TIMSetLogCallback({
callback: data => { callback: data => {
// console.log('[im-chat]', data[1])
this.setConsole('%cchat-log ', data[1]) this.setConsole('%cchat-log ', data[1])
}, },
user_data: '' user_data: ''
@ -78,57 +73,42 @@ export class ImChat {
return new Promise(async(resolve, reject) => { return new Promise(async(resolve, reject) => {
try { try {
if(!API) reject('preload api获取失败, 初始化-未完成') if(!API) reject('preload api获取失败, 初始化-未完成')
// this.timChat = await API.getTimRender() this.timChat = await API.getTimRender()
this.timChat = IMListeners.timRenderInstance await this.timChat.TIMInit()
const code = await this.timChat.TIMInit() console.log('[im-chat]:初始化成功')
if (code == 0) { // 初始化成功 this.status.isConnect = true
this.setConsole('%cim-chat: init', '初始化成功') this.setConfig() // 设置日志级别
this.status.isConnect = true resolve(this)
this.setConfig() // 设置日志级别
resolve(this)
} else { // 失败具体请看code
console.error('[im-chat]:初始化失败', code)
reject(code)
}
} catch (error) {reject(error)} } catch (error) {reject(error)}
}) })
} }
// 生成签名 // 生成签名
genTestUserSig() { genTestUserSig() {
// const options = { const options = {
// SDKAppID: this.SDKAppID, SDKAppID: this.SDKAppID,
// secretKey: this.secretKey, secretKey: this.secretKey,
// userID: this.userID, 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', '监听失败, 未连接')
} }
const { userSig } = GenerateUserSig.genTestUserSig(options)
this.userSig = userSig
}
// 监听
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)
},
})
} }
// 登录 // 登录
login() { login() {
@ -145,19 +125,18 @@ export class ImChat {
const res = await this.timChat.TIMLogin(option) const res = await this.timChat.TIMLogin(option)
if (res && res.code == 0) { if (res && res.code == 0) {
// console.log('登录成功', res) // console.log('登录成功', res)
this.setConsole('%cim-chat: login', '登录成功')
this.status.isLogin = true this.status.isLogin = true
resolve({status:0, msg:'登录成功', data:res}) resolve({status:0, msg:'登录成功', data:res})
} else reject(res) } else reject(res)
} else { } else {
if (status == 1) { // 已登录 if (status == 1) { // 已登录
this.setConsole('%cim-chat: login', '已登录') console.log('已登录')
resolve({status, msg:'已登录'}) resolve({status, msg:'已登录'})
} else if (status == 2) { // 登录中 } else if (status == 2) { // 登录中
this.setConsole('%cim-chat: login', '登录中') console.log('登录中')
resolve({status, msg:'登录中'}) resolve({status, msg:'登录中'})
} else if (status == 4) { // 登出中 } else if (status == 4) { // 登出中
this.setConsole('%cim-chat: login', '登出中') console.log('登出中')
resolve({status, msg:'登出中'}) resolve({status, msg:'登出中'})
} }
} }
@ -171,18 +150,13 @@ export class ImChat {
return this.timChat.TIMLogout().then(res => { return this.timChat.TIMLogout().then(res => {
console.log('登出成功', res) console.log('登出成功', res)
this.status.isLogin = false this.status.isLogin = false
this.timChat.TIMUninit() // 反初始化
return res return res
}).catch(error => { }).catch(error => {
console.log('登出失败', error) console.log('登出失败', error)
return error return error
}) })
} }
/** // 创建群组 群名和初始成员 userID
* @description 创建群组 群名和初始成员 userID
* @param {any} name
* @param {any[]} memberList
*/
createGroup(name, memberList=[]) { createGroup(name, memberList=[]) {
if (!this.timChat) return if (!this.timChat) return
if (!!this.timGroupId) return console.log('群组已存在') if (!!this.timGroupId) return console.log('群组已存在')
@ -212,10 +186,9 @@ export class ImChat {
// @TGS#3XVNI6ZOG // @TGS#3XVNI6ZOG
return this.timChat.TIMGroupCreate(option).then(res => { return this.timChat.TIMGroupCreate(option).then(res => {
if (res && res.code == 0) { if (res && res.code == 0) {
this.setConsole('%c创建群组成功', res)
const timGroupId = res?.json_param?.create_group_result_groupid const timGroupId = res?.json_param?.create_group_result_groupid
if (!!timGroupId && timGroupId != 'undefined'){ if (!!timGroupId && timGroupId != 'undefined'){
// this.setConsole('%c创建群组成功', timGroupId) this.setConsole('%c创建群组成功', timGroupId)
this.timGroupId = timGroupId this.timGroupId = timGroupId
// this.setGroupMsgReceive() // this.setGroupMsgReceive()
} }
@ -231,10 +204,7 @@ export class ImChat {
data: '', // 用户自定义数据 data: '', // 用户自定义数据
}) })
} }
/** // 设置群消息接收
* @description 设置群消息接收
* @param {string} timGroupId
*/
setGroupMsgReceive(timGroupId) { setGroupMsgReceive(timGroupId) {
if (!this.timGroupId) this.timGroupId = timGroupId || '' if (!this.timGroupId) this.timGroupId = timGroupId || ''
if (!this.timGroupId) return console.log('timGroupId为空') if (!this.timGroupId) return console.log('timGroupId为空')
@ -254,11 +224,7 @@ export class ImChat {
return error return error
}) })
} }
/** // 发送消息
* @description 发送消息
* @param {any} conv_id
* @param {any} msg
*/
sendMsg(conv_id, msg) { sendMsg(conv_id, msg) {
if (!conv_id) return console.log('conv_id为空') if (!conv_id) return console.log('conv_id为空')
if (typeof msg == 'object') msg = JSON.stringify(msg) if (typeof msg == 'object') msg = JSON.stringify(msg)
@ -277,33 +243,15 @@ export class ImChat {
user_data: '', // 用户自定义数据 user_data: '', // 用户自定义数据
// callback: (data) => {} // callback: (data) => {}
} }
// console.log('发送消息', option) console.log('发送消息', option)
this.setConsole('%cim-chat: 发送消息', option)
return this.timChat.TIMMsgSendMessageV2(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(){ sendMsgClosed(){
const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课') const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课', MsgEnum.TYPES.TEACHER)
return this.sendMsg(this.timGroupId, msg) 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={}) { getMsgObj(msgHead, msg, type, sender, option={}) {
if (!msgHead) throw new Error('msgHead is required') if (!msgHead) throw new Error('msgHead is required')
if (!msg) throw new Error('msg is required') if (!msg) throw new Error('msg is required')
@ -311,27 +259,19 @@ export class ImChat {
return { return {
msgKey: msgHead, msgKey: msgHead,
msgcontent: msg, msgcontent: msg,
msgType: type || MsgEnum.TYPES.TEACHER, // 默认为老师 msgType: type ?? MsgEnum.TYPES.STUDENT, // 默认为学生
senduserid: sender ?? this.userID, senduserid: sender ?? this.userID,
...option ...option
} }
} }
/** // 设置控制台样式
* @description 设置控制台样式
* @param {string} hearStr
* @param {string[]} args
*/
setConsole(hearStr,...args) { setConsole(hearStr,...args) {
const css = 'color: #fff;background-color:#2ccb92;padding:3px 5px;border-radius:3px;' const css = 'color: #fff;background-color:#2ccb92;padding:3px 5px;border-radius:3px;'
const time = new Date().toLocaleTimeString() const time = new Date().toLocaleTimeString()
if (!hearStr) hearStr = '%c' + time if (!hearStr) hearStr = '%c' + time
console.log(hearStr, css, ...args) console.log(hearStr, css, ...args)
} }
/** // 获取数据字符串
* @description 获取数据字符串
* @param {*} data
* @returns
*/
toStr = (data) => { toStr = (data) => {
if (typeof data === 'string') data = {type: data} if (typeof data === 'string') data = {type: data}
return JSON.stringify(data) return JSON.stringify(data)

File diff suppressed because one or more lines are too long

View File

@ -95,7 +95,6 @@ export class MsgEnum {
// === 新定义-消息头 === // === 新定义-消息头 ===
/** @desc: 点赞 */ /** @desc: 点赞 */
MSG_0001: 0x0001, MSG_0001: 0x0001,
/** @desc: 疑惑 */
MSG_0002: 0x0002, MSG_0002: 0x0002,
MSG_0003: 0x0003, MSG_0003: 0x0003,
MSG_0004: 0x0004, MSG_0004: 0x0004,
@ -110,7 +109,6 @@ export class MsgEnum {
MSG_0013: 0x000d, MSG_0013: 0x000d,
MSG_0014: 0x000e, MSG_0014: 0x000e,
MSG_0015: 0x000f, MSG_0015: 0x000f,
/** @desc: 作业推送 */
MSG_0016: 0x0010, MSG_0016: 0x0010,
MSG_0017: 0x0011, MSG_0017: 0x0011,
MSG_0018: 0x0012, MSG_0018: 0x0012,

View File

@ -0,0 +1,44 @@
/**
* @description: 生成签名|客户端计算 UserSig
* @author: zdg
* @date 2021-07-05 14:07:01
*/
// TIM生成签名
import LibGenerateTestUserSig from './lib-generate-test-usersig-es.min.js';
/**
* Signature expiration time, which should not be too short
* Time unit: second
* Default time: 7 * 24 * 60 * 60 = 604800 = 7days
*/
const EXPIRETIME = 604800;
/**
* Module: GenerateTestUserSig
*
* Description: Generates UserSig for testing. UserSig is a security signature designed by Tencent Cloud for its cloud services.
* It is calculated based on `SDKAppID`, `UserID`, and `EXPIRETIME` using the HMAC-SHA256 encryption algorithm.
*
* Attention: For the following reasons, do not use the code below in your commercial application.
*
* The code may be able to calculate UserSig correctly, but it is only for quick testing of the SDKs basic features, not for commercial applications.
* `SECRETKEY` in client code can be easily decompiled and reversed, especially on web.
* Once your key is disclosed, attackers will be able to steal your Tencent Cloud traffic.
*
* The correct method is to deploy the `UserSig` calculation code and encryption key on your project server so that your application can request from your server a `UserSig` that is calculated whenever one is needed.
* Given that it is more difficult to hack a server than a client application, server-end calculation can better protect your key.
*
* Reference: https://cloud.tencent.com/document/product/647/17275#Server
*/
function genTestUserSig(options) {
const { SDKAppID, secretKey, userID } = options;
const generator = new LibGenerateTestUserSig(SDKAppID, secretKey, EXPIRETIME);
const userSig = generator.genTestUserSig(userID);
return {
SDKAppID,
userSig,
};
}
export { genTestUserSig, EXPIRETIME };

View File

@ -12,15 +12,13 @@ export function shareStorePlugin({store}) {
// console.log('store.$subscribe', mutation) // console.log('store.$subscribe', mutation)
// 在存储变化的时候执行 // 在存储变化的时候执行
// const storeName = store.$id // const storeName = store.$id
const storeName = mutation.storeId // const storeName = mutation.storeId
const { storeId: storeName, payload, events, type } = mutation // direct
// if (!Object.keys(payload).length) return
if (type != 'direct') return
// 用于多窗口共享(需要共享的状态名称) // 用于多窗口共享(需要共享的状态名称)
const names = ['tool'] const names = ['tool']
if (names.includes(storeName)) { if (names.includes(storeName)) stateSync(storeName, events.key, events.newValue) // 需要同步
const { storeId: storeName, payload, events, type } = mutation // direct
// if (!Object.keys(payload).length) return
if (type != 'direct' || !events || Array.isArray(events) || !events.key) return
stateSync(storeName, events.key, events.newValue) // 需要同步
}
}) })
// 暴露方法-手动同步 // 暴露方法-手动同步
store.stateSync = (storeName, key, value) => { store.stateSync = (storeName, key, value) => {
@ -36,15 +34,11 @@ export function shareStorePlugin({store}) {
// 同步数据-发送给主线程-单独 // 同步数据-发送给主线程-单独
function stateSync(storeName, key, value) { function stateSync(storeName, key, value) {
// console.log('state-change', storeName, key, value) // console.log('state-change', storeName, key, value)
try { let jsonStr = ''
let jsonStr = '' if (typeof key === 'string') jsonStr = JSON.stringify({[key]:value})
if (typeof key === 'string') jsonStr = JSON.stringify({[key]:value}) else if (typeof value === 'object') jsonStr = JSON.stringify(key)
else if (typeof value === 'object') jsonStr = JSON.stringify(key) // 通知主线程更新
// 通知主线程更新 ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
} catch (error) {
console.log('state-change-error', error)
}
} }
// 同步数据-发送给主线程-全量更新 // 同步数据-发送给主线程-全量更新

View File

@ -1,23 +0,0 @@
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

View File

@ -7,6 +7,7 @@ export const hasPermission = (value, def = true) => {
if (!value) { if (!value) {
return def return def
} }
const allCodeList = useUserStore().roles const allCodeList = useUserStore().roles
// 如果不是数组直接判断pinia里的权限数组有没有相同的元素即可 // 如果不是数组直接判断pinia里的权限数组有没有相同的元素即可
if (!Array.isArray(value)) { if (!Array.isArray(value)) {

View File

@ -6,11 +6,7 @@ export const tabs = [
{ {
label: '校本资源', label: '校本资源',
value: '校本' value: '校本'
}, }
{
label: '第三方资源',
value: '第三方'
},
] ]
@ -71,41 +67,3 @@ export const resourceType = [
value: '教案' value: '教案'
} }
] ]
// 年级划分
export const gradeList = [
{
label:'小学',
value:1
},
{
label:'初中',
value:2
},
{
label:'高中',
value:3
},
]
//课件类别
export const coursewareTypeList = [
{
label:'课件',
value:3
},
{
label:'教案',
value:8
},
{
label:'试卷',
value:7
},
{
label:'学案',
value:4
},
{
label:'素材',
value:6
},
]

View File

@ -110,21 +110,11 @@ export const createWindow = async (type, data) => {
wins_tool.setIgnoreMouseEvents(true, {forward: true}) // 忽略鼠标事件但是事件继续传递给窗口 wins_tool.setIgnoreMouseEvents(true, {forward: true}) // 忽略鼠标事件但是事件继续传递给窗口
wins_tool.setAlwaysOnTop(true,'screen-saver') // 将窗口设置为顶层窗口 wins_tool.setAlwaysOnTop(true,'screen-saver') // 将窗口设置为顶层窗口
wins_tool.setVisibleOnAllWorkspaces(true) // 如果窗口在所有工作区都可见 wins_tool.setVisibleOnAllWorkspaces(true) // 如果窗口在所有工作区都可见
// wins_tool.webContents.openDevTools() // 打开调试工具 // win.webContents.openDevTools() // 打开调试工具
eventHandles(type, wins_tool) // 事件监听处理 eventHandles(type, wins_tool) // 事件监听处理
return wins_tool return wins_tool
} }
case 'open-PDF': { //课本展示-pdf case 'open-PDF': { //课本展示-pdf
if(winPdf){ //判断是否已经打开
if (winPdf.isMinimized()){
winPdf.restore();
} else{
winPdf.focus();
toolState.isPdfWin=true
}
return
}
const option = data.option||{} const option = data.option||{}
const defOption = { const defOption = {
frame: false, // 要创建无边框窗口 frame: false, // 要创建无边框窗口
@ -133,6 +123,12 @@ export const createWindow = async (type, data) => {
} }
data.isConsole = true // 是否开启控制台 data.isConsole = true // 是否开启控制台
data.option = {...defOption, ...option} data.option = {...defOption, ...option}
if(winPdf){ //判断是否已经打开
// if (winPdf.isMinimized()) winPdf.restore();
winPdf.focus();
// toolState.isPdfWin=true
return
}
const win = await toolWindow(data) const win = await toolWindow(data)
win.type = type // 唯一标识 win.type = type // 唯一标识
win.show() win.show()
@ -194,10 +190,7 @@ export function toolWindow({url, isConsole, isWeb=true, option={}}) {
// 内部监听器-是否打印 // 内部监听器-是否打印
if (!!isConsole) { if (!!isConsole) {
win.webContents.on('console-message', (e,leve,m,lin,s) => { win.webContents.on('console-message', (e,leve,m,lin,s) => {
if(m.startsWith('%c')){ // 特殊打印 console.log(`[${win.type}]`,m)
const arr = m.match(/(%c[^ ]+)(?:\s+(.*;))(.*)/)
console.log(arr[1],arr[2],arr[3])
} else console.log(`[${win.type}]`,m)
}) })
} }
}) })
@ -243,34 +236,24 @@ const eventHandles = (type, win) => {
break} break}
case 'open-PDF': { case 'open-PDF': {
// 最小化窗口 minimize() // 最小化窗口 minimize()
Remote.ipcMain.handle('open-PDF:minimize', () => { Remote.ipcMain.once('open-PDF:minimize', () => {
// winPdf=null
// win&&win.destroy()
win&&win.minimize(); //缩小功能
})
// 关闭窗口
Remote.ipcMain.once('open-PDF:close', () => {
winPdf=null winPdf=null
win&&win.destroy() win&&win.destroy()
// win&&win.minimize(); //缩小功能
}) })
const on = { publicMethods() // 加载公共方法
onClosed: () => {
Remote.ipcMain.removeHandler('open-PDF:minimize')
}
}
publicMethods(on) // 加载公共方法
break} break}
default: default:
break break
} }
} }
// const taskHandles = () => { const taskHandles = () => {
// // 设置任务栏上下文菜单 // // 设置任务栏上下文菜单
// const contextMenu = new Remote.Menu() // const contextMenu = new Remote.Menu()
// contextMenu.append(new Remote.MenuItem({ // contextMenu.append(new Remote.MenuItem({
// label: '关闭', // label: '关闭',
// click: () => {Remote.app.quit()} // click: () => {Remote.app.quit()}
// })) // }))
// } }

View File

@ -26,10 +26,7 @@
<i class="iconfont icon-xiayiye"></i> <i class="iconfont icon-xiayiye"></i>
<span class="texts">下一页</span> <span class="texts">下一页</span>
</el-button> </el-button>
</div>
<div class="pdf-btn-right">
<el-button @click="minimize" >最小化</el-button> <el-button @click="minimize" >最小化</el-button>
<el-button @click="minimize('rest')" >关闭</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -75,10 +72,9 @@ const navtopage = (type) => {
pdfCanvaslist.value.initPdf('rest') pdfCanvaslist.value.initPdf('rest')
} }
// //
const minimize = async (type='minimize') => { const minimize = async () => {
await pdfCanvaslist.value.savaDataStore(type) await pdfCanvaslist.value.savaDataStore()
} }
const handleUpdate = (data) => { const handleUpdate = (data) => {
numPagesTotal.value = data numPagesTotal.value = data
if (numPagesTotal.value == 1) { if (numPagesTotal.value == 1) {
@ -142,8 +138,7 @@ const getUniqueArrayByLastOccurrence=(array)=> {
flex-wrap: wrap; flex-wrap: wrap;
.pdf-btn { .pdf-btn {
position: absolute; position: absolute;
// right: 0; right: 0;
left: 0;
bottom: 0; bottom: 0;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5); box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
border-radius: 5px 0 0 0; border-radius: 5px 0 0 0;
@ -168,28 +163,5 @@ 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> </style>

View File

@ -493,7 +493,7 @@ export default {
// PDF- // PDF-
async navtoPdf() { async navtoPdf() {
// if (toolStore.isPdfWin) return this.$message.error('') if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
let path = await this.getBookPathFromServer() let path = await this.getBookPathFromServer()
createWindow('open-PDF', { createWindow('open-PDF', {
url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path
@ -501,7 +501,7 @@ export default {
}, },
// - // -
async openLesson() { async openLesson() {
// await startClass(this.curClassReserv.id) await startClass(this.curClassReserv.id)
createWindow('tool-sphere', { createWindow('tool-sphere', {
url: url:
'/tool/sphere?entpcourseid=' + '/tool/sphere?entpcourseid=' +

View File

@ -7,30 +7,12 @@
@click="sourceStore.changeTab(item.value)">{{ item.label @click="sourceStore.changeTab(item.value)">{{ item.label
}}</el-button> }}</el-button>
</el-col> </el-col>
<el-col :span="12" class="search-box flex">
<el-col :span="12" class="search-box flex" v-if="isThird"> <el-input v-model="sourceStore.query.fileName" @input="sourceStore.changeName" style="width: 240px"
<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="请输入关键词" /> placeholder="请输入关键词" />
</el-col> </el-col>
</el-row> </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"> <el-col :span="24" class="query-row flex">
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix" <div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix"
style="width: 110px"> style="width: 110px">
@ -48,33 +30,13 @@
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
<script setup> <script setup>
import {watch,ref} from 'vue'
import useResoureStore from '../store' 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()
}
watch(() => sourceStore.query.fileSource,() => { const sourceStore = useResoureStore()
sourceStore.query.fileSource === '第三方'?isThird.value = true:isThird.value = false
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.resoure-search { .resoure-search {

View File

@ -1,260 +0,0 @@
<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'); // 01
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>

View File

@ -1,8 +1,7 @@
<template> <template>
<div class="page-resource flex"> <div class="page-resource flex">
<!--左侧 教材 目录--> <!--左侧 教材 目录-->
<Third v-if="isThird" @node-click="getDataOther"></Third> <ChooseTextbook @change-book="getData" @node-click="getData" />
<ChooseTextbook v-else @change-book="getData" @node-click="getData" />
<div class="page-right"> <div class="page-right">
<!-- 搜索 --> <!-- 搜索 -->
@ -19,9 +18,7 @@
> >
</ResoureSearch> </ResoureSearch>
<!-- 列表 --> <!-- 列表 -->
<!-- 第三方列表--> <ResoureList />
<ThirdList v-if="isThird" />
<ResoureList v-else />
</div> </div>
</div> </div>
<!-- 上传弹窗 --> <!-- 上传弹窗 -->
@ -29,13 +26,11 @@
</template> </template>
<script setup> <script setup>
import { onMounted, ref, toRaw,watch } from 'vue' import { onMounted, ref, toRaw } from 'vue'
import useResoureStore from './store' import useResoureStore from './store'
import ChooseTextbook from '@/components/choose-textbook/index.vue' import ChooseTextbook from '@/components/choose-textbook/index.vue'
import Third from '@/components/choose-textbook/third.vue'
import ResoureSearch from './container/resoure-search.vue' import ResoureSearch from './container/resoure-search.vue'
import ResoureList from './container/resoure-list.vue' import ResoureList from './container/resoure-list.vue'
import ThirdList from './container/third-list.vue'
import uploadDialog from '@/components/upload-dialog/index.vue' import uploadDialog from '@/components/upload-dialog/index.vue'
import uploaderState from '@/store/modules/uploader' import uploaderState from '@/store/modules/uploader'
import { createWindow } from '@/utils/tool' import { createWindow } from '@/utils/tool'
@ -46,8 +41,9 @@ const toolStore = useToolState()
const openDialog = () => { const openDialog = () => {
isDialogOpen.value = true isDialogOpen.value = true
} }
// // onMounted(async () => {
const isThird = ref(false) // console.log('toolStore: ', toolStore.windowState)
// })
// //
const getData = (data) => { const getData = (data) => {
@ -71,13 +67,6 @@ const getData = (data) => {
} }
sourceStore.handleQuery() sourceStore.handleQuery()
} }
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()
}
// //
const submitFile = (data) => { const submitFile = (data) => {
@ -103,9 +92,6 @@ const fileCallBack = (res) => {
onMounted(() => { onMounted(() => {
sourceStore.getCreate() sourceStore.getCreate()
}) })
watch(() => sourceStore.query.fileSource,() => {
sourceStore.query.fileSource === '第三方'?isThird.value = true:isThird.value = false
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -1,6 +1,5 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { getSmarttalkPage } from '@/api/file/index' import { getSmarttalkPage } from '@/api/file/index'
import { getBookList } from '@/api/file/third'
import { tabs, resourceType, resourceFormat } from '@/utils/resourceDict' import { tabs, resourceType, resourceFormat } from '@/utils/resourceDict'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { hasPermission } from '@/utils/hasPermission' import { hasPermission } from '@/utils/hasPermission'
@ -61,56 +60,23 @@ export default defineStore('resource', {
isAsc: 'desc', isAsc: 'desc',
...structQuery ...structQuery
}, },
//第三方的查询条件
thirdQuery:{
page:1,
perPage:20,
chapterId:0,
bookId:0,
stage:0,
subjectId:0,
type:3,
title:''
},
result: { result: {
list: [], list: [],
total: 0 total: 0
}, }
//第三方的数据单独处理
thirdResult:{
list: [],
total: 0,
},
}), }),
actions: { actions: {
handleQuery() { handleQuery() {
try { try {
this.loading = true this.loading = true
if(this.query.fileSource !== '第三方'){ let data = { ...this.query }
let data = { ...this.query } if (data.fileSuffix == -1) {
if (data.fileSuffix == -1) { data.fileSuffix = ''
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 { } finally {
this.loading = false this.loading = false
} }
@ -124,11 +90,6 @@ export default defineStore('resource', {
this.query.fileFlag = val this.query.fileFlag = val
this.handleQuery() this.handleQuery()
}, },
thirdChangeType(val) {
this.thirdQuery.type = val
this.handleQuery()
},
//第三方的切换类型区别开
changeSuffix(val) { changeSuffix(val) {
this.query.fileSuffix = val this.query.fileSuffix = val
this.handleQuery() this.handleQuery()
@ -138,12 +99,12 @@ export default defineStore('resource', {
this.handleQuery() this.handleQuery()
}, },
getCreate(){ getCreate(){
if(this.query.fileSource == '平台' || this.query.fileSource == '第三方' ){ if(this.query.fileSource == '平台'){
this.isCreate = hasPermission(['platformmanager']) this.isCreate = hasPermission(['platformmanager'])
} }
else{ else{
this.isCreate = hasPermission(['schoolteacher','headmaster']) this.isCreate = hasPermission(['schoolteacher','headmaster'])
} }
}, }
} }
}) })

View File

@ -77,14 +77,14 @@ import { getSmarttalkPage, getPrepareById } from '@/api/file'
import SetHomework from '@/views/prepare/container/set-homework.vue' import SetHomework from '@/views/prepare/container/set-homework.vue'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { useGetHomework } from '@/hooks/useGetHomework' import { useGetHomework } from '@/hooks/useGetHomework'
import { ipcMsgSend, ipcMsgInvoke } from '@/utils/tool' import { ipcMsgSend } from '@/utils/tool'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { asyncLocalFile } from '@/utils/talkFile' import { asyncLocalFile } from '@/utils/talkFile'
import Lesson from './lesson.vue'; import Lesson from './lesson.vue';
import { parseCataByNode } from '@/utils/talkFile' import { parseCataByNode } from '@/utils/talkFile'
import outLink from '@/utils/linkConfig' import outLink from '@/utils/linkConfig'
import MsgEnum from '@/plugins/imChat/msgEnum' //
import { ipcMsgSend2 } from '@/utils/tool'
const route = useRoute(); const route = useRoute();
const usertore = useUserStore().user const usertore = useUserStore().user
const toolStore = useToolState() const toolStore = useToolState()
@ -110,10 +110,8 @@ const sendHomework = (row) => {
setDialog.value = true setDialog.value = true
} }
// //
const closeHomework = async() => { const closeHomework = () => {
ipcMsgSend('tool-sphere:set:ignore', true) ipcMsgSend('tool-sphere:set:ignore', true)
// im-(app|)
await ipcMsgInvoke('im-chat:msg', curRow.value.id, MsgEnum.HEADS.MSG_0016)
setDialog.value = false setDialog.value = false
} }

View File

@ -4,7 +4,7 @@ import { onMounted, ref, reactive, watchEffect } from 'vue'
import { ImChat } from '@/plugins/imChat' import { ImChat } from '@/plugins/imChat'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import * as http from '@/api/apiService' // api service import * as http from '@/api/apiService' // api service
import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' // // import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' //
const userStore = useUserStore() const userStore = useUserStore()
const emits = defineEmits(['change']) const emits = defineEmits(['change'])
const props = defineProps({ const props = defineProps({
@ -12,10 +12,11 @@ const props = defineProps({
}) })
const imChatObj = reactive({imChat:null}) const imChatObj = reactive({imChat:null})
onMounted(() => { onMounted(() => {
ipcMainHandle() // -ipcMain im // console.log(imChatObj)
initImChat()
}) })
// im-chat // im-chat
const initImChat = async (timGroupId) => { const initImChat = async () => {
// console.log('im-chat', userStore.user.timuserid) // console.log('im-chat', userStore.user.timuserid)
try { try {
const { timuserid, deptId, userId } = userStore.user const { timuserid, deptId, userId } = userStore.user
@ -30,59 +31,29 @@ const initImChat = async (timGroupId) => {
imChatObj.imChat = new ImChat(sdkAppId, sign, timuserid) imChatObj.imChat = new ImChat(sdkAppId, sign, timuserid)
// im-chat // im-chat
await imChatObj.imChat.init() await imChatObj.imChat.init()
// im-chat
await imChatObj.imChat.login()
// im-chat // im-chat
imChatObj.imChat.watch((res) => { imChatObj.imChat.watch((res) => {
imChatObj.imChat.setConsole('%cchat-msg', res) const [msg] = res[0]?JSON.parse(res[0]):[]
msgHandle(res) // imChatObj.imChat.setConsole('%cchat-msg', msg)
//
if(msg.message_sender == '@TIM#SYSTEM'){
emits('change', 'msg-system', null, msg)
} else { // -
(msg?.message_elem_array||[]).forEach(o => {
const msgData = !!o.text_elem_content ? JSON.parse(o.text_elem_content)||'' : ''
emits('change', 'msg', msgData, msg)
})
}
}) })
// im-chat(-)
await imChatObj.imChat.login()
// //
if (!timGroupId||props.isGroup) { // if (props.isGroup) await createGroup(groupName)
await createGroup(groupName)
} else { // -id
imChatObj.imChat.timGroupId = timGroupId
}
return imChatObj.imChat
} }
} catch (error) { } catch (error) {
console.log('im-error: ', 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) => { const createGroup = async (groupName) => {
if (!imChatObj.imChat) return if (!imChatObj.imChat) return
@ -94,15 +65,7 @@ const logout = () => imChatObj.imChat?.logout()
// //
const deleteGroup = () => imChatObj.imChat?.deleteGroup() const deleteGroup = () => imChatObj.imChat?.deleteGroup()
// -ipcMain im defineExpose({ logout, deleteGroup, imChatObj })
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> </script>
<template> <template>

View File

@ -42,17 +42,18 @@ const getTreeData = () => {
evaluationList.value = JSON.parse(localStorage.getItem('evaluationList')) evaluationList.value = JSON.parse(localStorage.getItem('evaluationList'))
// //
/** let volumeOne = evaluationList.value.filter(item => item.level == 1 && item.semester == '上册')
* 不区分上下册 //
* 2024/08/20调整 let volumeTwo = evaluationList.value.filter(item => item.level == 1 && item.semester == '下册')
*/
let volumeOne = evaluationList.value.filter(item => item.level == 1)
// //
let upData = transData(volumeOne) let upData = transData(volumeOne)
if(upData.length){ let downData = transData(volumeTwo)
treeData.value = [...upData] if(upData.length && downData.length){
treeData.value = [...upData,...downData]
}
else if(upData.length || downData.length){
treeData.value = upData.length ? upData : downData
} }
else{ else{
treeData.value = [] treeData.value = []

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="warp" ref="btnRef" :style="isFold?'min-height:auto;':''"> <div class="warp" ref="btnRef">
<slot name="start"></slot> <slot name="start"></slot>
<!-- 工具按钮 --> <!-- 工具按钮 -->
<el-space direction="vertical" v-show="!isFold"> <el-space direction="vertical">
<template v-for="(item,index) in list"> <template v-for="(item,index) in list">
<slot :name="item.prop" :item="item" :index="index"> <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)"> <div class="c-btn flex flex-col items-center gap-2 p-2" @click.stop="clickHandel(item,$event)">
@ -13,11 +13,7 @@
</template> </template>
<slot name="append"></slot> <slot name="append"></slot>
</el-space> </el-space>
<slot name="end"> <slot name="end"></slot>
<span class="fold" @click="isFold=!isFold" :style="isFold?'margin: 5px;':''">
{{isFold?'<<<':'>>>'}}
</span>
</slot>
<!-- 内容部分 --> <!-- 内容部分 -->
<transition name="el-fade-in"> <transition name="el-fade-in">
<div class="c-popover" :style="`--top: ${topPos}px;--height:${hPost}px;`" v-show="isVisible"> <div class="c-popover" :style="`--top: ${topPos}px;--height:${hPost}px;`" v-show="isVisible">
@ -58,7 +54,6 @@ const activeObj = ref(null) // 当前激活的按钮
const btnRef = ref(null) // -ref 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) //
let posBtnAll = {} // let posBtnAll = {} //
// === === // === ===
const list = computed(() => props.data.map((o,i) => { const list = computed(() => props.data.map((o,i) => {
@ -105,7 +100,7 @@ const clickHandel = (o, e) => {
min-width: 4em; min-width: 4em;
border-radius: 4em; border-radius: 4em;
background-color: #121212; background-color: #121212;
.el-space{margin: 20px 0 0;} .el-space{margin: 20px 0;}
.c-btn{ .c-btn{
color: #d9dce3; color: #d9dce3;
cursor: pointer; cursor: pointer;
@ -118,20 +113,6 @@ const clickHandel = (o, e) => {
background: #454545fa; 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{ .c-popover{
--top: 30px; --top: 30px;

View File

@ -1,50 +1,28 @@
<template> <template>
<div v-if="props.test"> <el-button v-if="props.test" type="primary" @click="trigger">测试</el-button>
<el-button type="primary" @click="trigger">点赞</el-button>
<el-button type="primary" @click="trigger(1, '学生A')">疑惑</el-button>
</div>
<div ref="warpRef" class="c-warp"> <div ref="warpRef" class="c-warp">
<template v-for="(item, index) in iconCache.list"> <template v-for="i in sum">
<slot> <slot><el-icon><Star /></el-icon></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> </template>
</div> </div>
</template> </template>
<script setup> <script setup>
// - // -
import { ref, nextTick, useSlots, reactive } from 'vue' import { nextTick, ref } from 'vue'
import {Star} from '@element-plus/icons-vue' import {Star} from '@element-plus/icons-vue'
const warpRef = ref(null) const warpRef = ref(null)
const props = defineProps({ test: Boolean, def: Boolean }) const props = defineProps({ test: Boolean })
const slots = useSlots() // const sum = ref(0)
let iconCache = reactive({list:[]}) // // === ===
const isSlot = !!Object.keys(slots).length // 使 const trigger = () => {
// === type 1 def === sum.value++
const trigger = async (type, name) => {
if (typeof type == 'string') { name = type; type = 1 } //
iconCache.list.push({
name,
icon: isSlot||props.def ? '' : getRandomIcon(type) //
})
nextTick(() => { nextTick(() => {
const el = warpRef.value.lastElementChild // const el = warpRef.value.lastElementChild //
const tipEl = el.querySelector('.tip') // animInit(el)
// console.log(el)
animInit(el, tipEl, type)
}) })
} }
// //
const animInit = (el, tipEl, type) => { const animInit = (el) => {
const { height, width } = el.getBoundingClientRect() const { height, width } = el.getBoundingClientRect()
const sumH = warpRef.value.clientHeight const sumH = warpRef.value.clientHeight
const sumW = warpRef.value.clientWidth const sumW = warpRef.value.clientWidth
@ -54,25 +32,15 @@ const animInit = (el, tipEl, type) => {
let opacity = 0 // let opacity = 0 //
let scale = 0 // let scale = 0 //
let transform = '' // let transform = '' //
let transform2 = '' // -
let right = getRandom(5, maxw, false, true) // - let right = getRandom(5, maxw, false, true) // -
let isPlus = getRandomBool()?'':'-' // - let isPlus = getRandomBool()?'':'-' // -
let isPlus2 = isPlus ? '' : '-' // --
let rotate = getRandom(0, 60, false, true) // - let rotate = getRandom(0, 60, false, true) // -
let scaleMax = getRandom(0.5, 1.5, true, true)+1 // - let scaleMax = getRandom(0, 1, true, true)+1 // -
setStatic(el,'position','absolute') // - setStatic(el,'position','absolute') // -
setStatic(el, 'right', right, 'px') // - 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; const amFn = () => { // opacity: 0.5;
// if (bottom == 130) return
// - // -
if (bottom > maxH) {el.remove();resetIconCache();return} if (bottom > maxH) {el.remove();return}
// : - // : -
if (bottom < 101 && opacity < 1) opacity = toNumber(opacity + 0.01) if (bottom < 101 && opacity < 1) opacity = toNumber(opacity + 0.01)
else if (bottom > maxH - 100 && opacity > 0) opacity = toNumber(opacity - 0.01) else if (bottom > maxH - 100 && opacity > 0) opacity = toNumber(opacity - 0.01)
@ -81,45 +49,18 @@ const animInit = (el, tipEl, type) => {
// 退- // 退-
else if (bottom > maxH - (scaleMax/0.1) && scale > 0) scale = toNumber(scale - 0.1) else if (bottom > maxH - (scaleMax/0.1) && scale > 0) scale = toNumber(scale - 0.1)
bottom++ bottom++
// console.log('zdg: ', scale) rotate(${isPlus2}${rotate}deg) // console.log('zdg: ', scale)
// //
transform = `rotate(${isPlus}${rotate}deg) scale(${scale})` transform = `rotate(${isPlus}${rotate}deg) scale(${scale})`
setStatic(el, 'bottom', bottom, 'px') setStatic(el, 'bottom', bottom, 'px')
setStatic(el, 'opacity', opacity) setStatic(el, 'opacity', opacity)
setStatic(el, 'transform', transform) setStatic(el, 'transform', transform)
if (!!tipEl && type) {
transform2 = `rotate(${isPlus2}${rotate}deg) scale(${toNumber(1/scale)})`
setStatic(tipEl, 'transform', transform2)
}
requestAnimationFrame(amFn) requestAnimationFrame(amFn)
} }
amFn() // amFn() //
} }
// - // -
const setStatic = (el, type, val, end) => el.style[type] = val + (end || '') 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 1: // 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 // isFloat isMax
const getRandom = (min, max, isFloat, isMax, pos=2) => { const getRandom = (min, max, isFloat, isMax, pos=2) => {
const maxVal = isMax ? max - min + 1 : max - min const maxVal = isMax ? max - min + 1 : max - min
@ -130,8 +71,6 @@ const getRandom = (min, max, isFloat, isMax, pos=2) => {
const getRandomBool = () => Math.random() > 0.5 const getRandomBool = () => Math.random() > 0.5
// -() // -()
const toNumber = (v, pos = 2) => Number(v.toFixed(pos)) const toNumber = (v, pos = 2) => Number(v.toFixed(pos))
//
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
// //
defineExpose({ trigger }) defineExpose({ trigger })
</script> </script>
@ -144,39 +83,5 @@ defineExpose({ trigger })
width: 30%; width: 30%;
height: 50%; height: 50%;
pointer-events: none; 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);
}
}
}
} }
</style> </style>

View File

@ -66,7 +66,6 @@ const classObj = reactive({ // 课程相关
id: route.query.reservId, // id id: route.query.reservId, // id
data: {} // data: {} //
}) })
const msgIds = [] // id
const btnList = [ // const btnList = [ //
{ label: '选择', value: 'select', icon: 'icon-mouse' }, { label: '选择', value: 'select', icon: 'icon-mouse' },
{ label: '画笔', value: 'brush', icon: 'icon-huabi' }, { label: '画笔', value: 'brush', icon: 'icon-huabi' },
@ -78,8 +77,8 @@ const btnList = [ // 工具栏按钮列表
] ]
// === === // === ===
onMounted(async() => { onMounted(async() => {
getClassInfo() // ex3
setTimeout(() => { setTimeout(() => {
getClassInfo() // ex3
resetStatus() // - resetStatus() // -
}, 200); }, 200);
}) })
@ -89,12 +88,15 @@ 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
// id if(!data.ex3 || data.ex3 == 'undefined') { //
let timGroupId = data?.ex3 || '' await imChatRef.value.imChatObj.imChat.createGroup(data.className)
console.log('获取群ID:', timGroupId) const timGroupId = imChatRef.value.imChatObj.imChat.timGroupId
const chat = await imChatRef.value?.initImChat(timGroupId) // im-chat classManageApi.startClass(classObj.id, timGroupId) //
if (!timGroupId) timGroupId = chat?.timGroupId } else { //
classManageApi.startClass(classObj.id, timGroupId) // // console.log(': ', data.ex3)
imChatRef.value.imChatObj.imChat.timGroupId = data.ex3
// imChatRef.value.imChatObj.imChat.setGroupMsgReceive(data.ex3)
}
} }
// tab-change // tab-change
const tabChange = (val) => { const tabChange = (val) => {
@ -117,22 +119,17 @@ const mouseChange = (bool) => {
setIgnore(resBool) setIgnore(resBool)
} }
// im-chat: {type, data} // im-chat: {type, data}
const chatChange = (type, data, ...args) => { const chatChange = (type, data) => {
if (type == 'createGroup') { // - if (type == 'createGroup') { // -
console.log('创建群:', data) console.log('创建群:', data)
!!data && classManageApi.startClass(classObj.id, data) !!data && classManageApi.startClass(classObj.id, data)
} else if (type == 'msg') { // im-chat } else if (type == 'msg') { // im-chat
if (!data) return // msg message_msg_id if (!data) return // msg
const msgId = (args||[])[0].message_msg_id
const { msgKey:head, msgcontent:msg, senduserid:sendId, msgType } = data const { msgKey:head, msgcontent:msg, senduserid:sendId, msgType } = data
switch(head) { switch(head) {
case MsgEnum.HEADS.MSG_0001: // case MsgEnum.HEADS.MSG_0001:
case MsgEnum.HEADS.MSG_0002: //
// console.log(':', data) // console.log(':', data)
if(msgIds.includes(msgId)) return // - upvoteRef.value.trigger()
upvoteRef.value.trigger(data.name) // |
if (msgIds.length >= 100) msgIds.shift() //
msgIds.push(msgId) //
break break
default: default:
console.log('未知消息:', data) console.log('未知消息:', data)
@ -147,7 +144,6 @@ const setIgnore = (bool) => {ipcMsgSend('tool-sphere:set:ignore', bool)}
// : | // : |
const resetStatus = () => { const resetStatus = () => {
if (toolStore.isToolWin) return // - if (toolStore.isToolWin) return // -
ipcMain?.removeHandler('tool-sphere:reset') //
ipcMain?.handle?.('tool-sphere:reset', () => { ipcMain?.handle?.('tool-sphere:reset', () => {
setTimeout(() => { setTimeout(() => {
boardVueRef.value.handleMode(tabActive.value) boardVueRef.value.handleMode(tabActive.value)
@ -185,16 +181,16 @@ const sideChange = async o => {
}).then(async() => { }).then(async() => {
await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() // await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() //
// const elMsg = ElMessage.warning({duration:0,message:'...'}) // const elMsg = ElMessage.warning({duration:0,message:'...'})
// const elMsg = ElLoading.service({lock: true, text: '...', background: 'rgba(0, 0, 0, 0.7)'}) const elMsg = ElLoading.service({lock: true, text: '正在下课...', background: 'rgba(0, 0, 0, 0.7)'})
// 2 // 2
setTimeout(async() => { setTimeout(async() => {
// elMsg.close() elMsg.close()
toolStore.isToolWin = false toolStore.isToolWin = false
await classManageApi.endClass(route.query.reservId)
await imChatRef.value?.deleteGroup() // await imChatRef.value?.deleteGroup() //
await imChatRef.value?.logout() // 退im await imChatRef.value?.logout() // 退im
await classManageApi.endClass(route.query.reservId)
ipcMsgSend('tool-sphere:close') // ipcMsgSend('tool-sphere:close') //
}, 500); }, 2000);
// isOver.value = false // isOver.value = false
// setIgnore(true) // -穿 // setIgnore(true) // -穿