forked from gulihua10010/wxmini-chatgpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
93 lines (83 loc) · 2.39 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script>
import initApp from '@/common/appInit.js';
import openApp from '@/common/openApp.js';
import WebSocket from '@/common/websocket.js';
// #ifdef H5
openApp() //创建在h5端全局悬浮引导用户下载app的功能
// #endif
import uniIdPageInit from '@/uni_modules/uni-id-pages/init.js';
export default {
globalData: {
searchText: '',
appVersion: "V1.0.0",
name: '微AI聊天',
github_: 'https://github.com/gulihua10010/wxmini-*****',
github: 'https://github.com/gulihua10010/wxmini-**********',
blog: 'https://jianwoo.cn',
blogDetail: 'https://jianwoo.cn/detail?id=3267583046918340611',
server: "http://192.168.0.103:8080/",
websocket: "ws://192.168.0.103:8080/"
},
onLaunch: function() {
console.log('App Launch')
this.globalData.$i18n = this.$i18n
this.globalData.$t = str => this.$t(str)
initApp();
uniIdPageInit()
uni.request({
url: this.globalData.server + '/status',
data: {},
success: (res) => {
console.log("status: " + res.data.state);
uni.setStorageSync('status', res.data.state);
if (res.data.state) {
// 连接socket
this.globalData.$socket = new WebSocket({
url: this.globalData.websocket + "/websocket"
})
}
},
fail: (res) => {}
});
uni.request({
url: this.globalData.server + '/cache/YhI86Yjjoko',
data: {},
success: (res) => {
console.log(res.data);
uni.setStorageSync('isDebug', res.data === 'TRUE');
},
fail: (res) => {}
});
// #ifdef APP-PLUS
// #endif
// #ifdef H5
// #endif
// #ifdef APP-PLUS
//idfa有需要的用户在应用首次启动时自己获取存储到storage中
/*var idfa = '';
var manager = plus.ios.invoke('ASIdentifierManager', 'sharedManager');
if(plus.ios.invoke(manager, 'isAdvertisingTrackingEnabled')){
var identifier = plus.ios.invoke(manager, 'advertisingIdentifier');
idfa = plus.ios.invoke(identifier, 'UUIDString');
plus.ios.deleteObject(identifier);
}
plus.ios.deleteObject(manager);
console.log('idfa = '+idfa);*/
// #endif
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
},
destroyed() {
console.log('App destroyed')
getApp().$socket.close();
}
}
</script>
<style lang="scss">
@import "@/static/icon/iconfont.css";
@import "@/uni_modules/uview-ui/index.scss";
</style>