p975i2czf 3 months ago
parent 8f9f05b4ed
commit eebbef6e78

@ -53,6 +53,7 @@
"@dcloudio/uni-ui": "^1.5.7", "@dcloudio/uni-ui": "^1.5.7",
"@hyoga/uni-socket.io": "^3.0.4", "@hyoga/uni-socket.io": "^3.0.4",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"pinia": "^3.0.2",
"vue": "^3.4.21", "vue": "^3.4.21",
"vue-i18n": "^9.1.9" "vue-i18n": "^9.1.9"
}, },

File diff suppressed because it is too large Load Diff

@ -4,43 +4,86 @@
<h3 > <h3 >
上课 上课
</h3> </h3>
<view v-if="kctivityAndPPT.length > 0">
<H4>课堂活动与 PPT 列表</H4>
<ul >
<li v-for="item in kctivityAndPPT" :key="item.id">
展示{{ item.name }}
<view v-if="item.lx=='ppt'">
<image
:src="item.src"
mode="aspectFit"
/>
</view>
<view v-else-if="item.lx=='activity'">
</view>
</li>
</ul>
</view>
<view v-else>
<p>暂无课堂活动或 PPT 数据</p>
</view>
</view> </view>
</template> </template>
<script setup>
//
</script>
<script > <script setup>
import { onMounted, onUnmounted } from 'vue'
import io from '@hyoga/uni-socket.io' import io from '@hyoga/uni-socket.io'
export default { import { ref } from 'vue'
onLoad(options) {
// // and PPT
const kctivityAndPPT = ref([
{lx:'ppt',id:1,name:'PPT展示1',src:'https://img11.360buyimg.com/n1/s720x720_jfs/t1/303510/33/1806/82651/6815a7a6F2e5d77b6/08d231a86927b0ce.jpg'},
{lx :'activity',id:2,name:'课堂活动1',src:'https://img11.360buyimg.com/n1/s720x720_jfs/t1/303510/33/1806/82651/6815a7a6F2e5d77b6/08d231a86927b0ce.jpg'}
])
// socket
let socket
//
onMounted((options) => {
console.log(options) console.log(options)
this.socket = io('ws://localhost:3400', { transports: ['websocket'],auth:{ socket = io('ws://localhost:3400', {
xuehao:"202413501062", transports: ['websocket'],
sf:"stu", auth: {
kch:options.kch, xuehao: "202413501062",
kctime:options.kctime, sf: "stu",
k_id:options.uuid, kch: options.kch,
} }) kctime: options.kctime,
// k_id: options.uuid,
}
})
this.socket.on('connect', () => console.log('Socket 已连接')) //
this.socket.on('server', data => { socket.on('connect', () => console.log('Socket 已连接'))
socket.on('server', (data) => {
console.log(data) console.log(data)
}) })
this.socket.on('message', data => this.handleMessage(data)) socket.on('message', (data) => handleMessage(data))
}, })
onUnload() {
// //
this.socket.off('message') onUnmounted(() => {
this.socket.disconnect() if (socket) {
}, socket.off('message')
methods: { socket.disconnect()
handleMessage(data) { /* 处理消息 */ },
sendData() {
this.socket.emit('chat', { text: 'Hello' })
} }
})
//
const handleMessage = (data) => {
//
console.log('处理消息:', data)
}
//
const sendData = () => {
if (socket) {
socket.emit('chat', { text: 'Hello' })
} }
} }
</script> </script>

Loading…
Cancel
Save