54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
// 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)
|
||
// }
|
||
}) |