ts_aimz/app.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

2025-03-21 09:02:29 +08:00
// app.js
2025-04-09 11:31:24 +08:00
import {
copyrightUrl
} from './net/http'
2025-03-21 09:02:29 +08:00
App({
globalData: {
userInfo: null,
isAdPopupVisible: false
},
onLaunch() {
2025-04-09 11:31:24 +08:00
// 全局事件对象
// this.eventBus = {}
// // 监听事件
// this.on = function (eventName, callback) {
// if (!this.eventBus[eventName]) {
// this.eventBus[eventName] = []
// }
// this.eventBus[eventName].push(callback)
// }
// // 触发事件
// this.emit = function (eventName, data) {
// const callbacks = this.eventBus[eventName]
// if (callbacks) {
// callbacks.forEach(callback => {
// callback(data)
// })
// }
// }
// this.initSse()
2025-03-21 09:02:29 +08:00
},
2025-04-09 11:31:24 +08:00
// initSse() {
// const req = wx.request({
// url: copyrightUrl + '/api/sse/connect',
// method: 'GET',
// enableChunked: true,
// header: {
// 'Cache-Control': 'no-cache',
// 'Accept': 'text/event-stream'
// },
// success: (res) => {
// console.log('SSE 连接成功', res);
// },
// fail: (err) => {
// console.error('SSE 连接失败', err);
// }
// })
// const listener = data => {
// // data为返回的数据可以在此对数据进行处理
// console.log(data)
// }
// // 监听服务端返回的数据
// req.onChunkReceived(listener)
// }
2025-03-21 09:02:29 +08:00
})