ts_aimz/app.js
2025-04-09 11:31:24 +08:00

54 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// app.js
import {
copyrightUrl
} from './net/http'
App({
globalData: {
userInfo: null,
isAdPopupVisible: false
},
onLaunch() {
// 全局事件对象
// 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()
},
// 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)
// }
})