mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 04:40:37 +00:00
vconsole
This commit is contained in:
parent
7033f00a0e
commit
b469069e92
10
public/js/vconsole.min.js
vendored
Normal file
10
public/js/vconsole.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -53,7 +53,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['userId', 'userToken']),
|
||||
...mapState(['ws', 'userId', 'userToken']),
|
||||
},
|
||||
|
||||
watch: {
|
||||
@ -83,16 +83,36 @@ export default {
|
||||
handler() {
|
||||
this.$store.dispatch("websocketConnection");
|
||||
//
|
||||
if (this.$isEEUiApp && this.userId > 0) {
|
||||
setTimeout(_ => {
|
||||
const webview = requireModuleJs("webview");
|
||||
webview && webview.sendMessage({
|
||||
action: 'setUmengAlias',
|
||||
userid: this.userId,
|
||||
token: this.userToken,
|
||||
url: $A.apiUrl('users/umeng/alias')
|
||||
if (this.userId > 0) {
|
||||
if (this.$isEEUiApp) {
|
||||
setTimeout(_ => {
|
||||
const webview = requireModuleJs("webview");
|
||||
webview && webview.sendMessage({
|
||||
action: 'setUmengAlias',
|
||||
userid: this.userId,
|
||||
token: this.userToken,
|
||||
url: $A.apiUrl('users/umeng/alias')
|
||||
});
|
||||
}, 6000)
|
||||
}
|
||||
//
|
||||
if (this.openVlog) {
|
||||
$A.loadScript('js/vconsole.min.js', (e) => {
|
||||
if (e !== null || typeof window.VConsole !== 'function') {
|
||||
$A.modalAlert("vConsole 组件加载失败!");
|
||||
return;
|
||||
}
|
||||
window.vConsole = new window.VConsole({
|
||||
onReady: () => {
|
||||
console.log('vConsole: onReady');
|
||||
},
|
||||
onClearLog: () => {
|
||||
console.log('vConsole: onClearLog');
|
||||
}
|
||||
});
|
||||
console.info('vConsole: Welcome');
|
||||
});
|
||||
}, 6000)
|
||||
}
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
@ -229,12 +249,22 @@ export default {
|
||||
}
|
||||
// 页面失活
|
||||
window.__onPagePause = () => {
|
||||
|
||||
if (this.openVlog) {
|
||||
console.log('onPagePause');
|
||||
}
|
||||
}
|
||||
// 页面激活
|
||||
window.__onPageResume = (num) => {
|
||||
if (this.openVlog) {
|
||||
console.log('onPageResume', num);
|
||||
console.log('ws', this.ws);
|
||||
console.log('ws.readyState', this.ws ? this.ws.readyState : null);
|
||||
}
|
||||
if (num > 0) {
|
||||
this.$store.state.ws === null && this.$store.dispatch("websocketConnection");
|
||||
if (this.ws === null || this.ws.readyState === WebSocket.CLOSED) {
|
||||
this.$store.dispatch("websocketConnection");
|
||||
}
|
||||
this.$store.dispatch("getBasicData", 5000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
resources/assets/js/app.js
vendored
2
resources/assets/js/app.js
vendored
@ -110,6 +110,7 @@ Vue.prototype.$isMainElectron = false;
|
||||
Vue.prototype.$isSubElectron = false;
|
||||
Vue.prototype.$isEEUiApp = isEEUiApp;
|
||||
Vue.prototype.$isDesktop = $A.isDesktop();
|
||||
Vue.prototype.$openVlog = $A.getStorageString("vlog::open") === "open";
|
||||
if (isElectron) {
|
||||
Vue.prototype.$Electron = electron;
|
||||
Vue.prototype.$Platform = /macintosh|mac os x/i.test(navigator.userAgent) ? "mac" : "win";
|
||||
@ -143,6 +144,7 @@ $A.isMainElectron = app.$isMainElectron;
|
||||
$A.isSubElectron = app.$isSubElectron;
|
||||
$A.isEEUiApp = app.$isEEUiApp;
|
||||
$A.isDesktop = app.$isDesktop;
|
||||
$A.openVlog = app.$openVlog;
|
||||
$A.execMainDispatch = (action, data) => {
|
||||
if ($A.isSubElectron) {
|
||||
$A.Electron.sendMessage('sendForwardMain', {
|
||||
|
||||
@ -679,11 +679,7 @@ export default {
|
||||
|
||||
wsOpenNum(num) {
|
||||
if (num <= 1) return
|
||||
this.wsOpenTimeout && clearTimeout(this.wsOpenTimeout)
|
||||
this.wsOpenTimeout = setTimeout(() => {
|
||||
this.$store.dispatch("getBasicData")
|
||||
this.getReportUnread()
|
||||
}, 5000)
|
||||
this.$store.dispatch("getBasicData", 5000).then(this.getReportUnread)
|
||||
},
|
||||
|
||||
workReportShow(show) {
|
||||
|
||||
@ -258,6 +258,20 @@ export default {
|
||||
},
|
||||
|
||||
watch: {
|
||||
dialogKey(val) {
|
||||
switch (val) {
|
||||
case 'vlog.open':
|
||||
case 'vlog:open':
|
||||
$A.setStorage("vlog::open", "open");
|
||||
$A.reloadUrl();
|
||||
break;
|
||||
case 'vlog.close':
|
||||
case 'vlog:close':
|
||||
$A.setStorage("vlog::open", "close");
|
||||
$A.reloadUrl();
|
||||
break;
|
||||
}
|
||||
},
|
||||
contactsKey(val) {
|
||||
setTimeout(() => {
|
||||
if (this.contactsKey == val) {
|
||||
|
||||
24
resources/assets/js/store/actions.js
vendored
24
resources/assets/js/store/actions.js
vendored
@ -252,8 +252,19 @@ export default {
|
||||
/**
|
||||
* 获取基本数据(项目、对话、仪表盘任务)
|
||||
* @param dispatch
|
||||
* @param timeout
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
getBasicData({dispatch}) {
|
||||
getBasicData({dispatch}, timeout) {
|
||||
if (typeof timeout === "number") {
|
||||
return new Promise(resolve => {
|
||||
window.__getBasicData && clearTimeout(window.__getBasicData)
|
||||
window.__getBasicData = setTimeout(() => {
|
||||
dispatch("getBasicData", null)
|
||||
resolve()
|
||||
}, timeout)
|
||||
});
|
||||
}
|
||||
dispatch("getProjects").catch(() => {});
|
||||
dispatch("getDialogs").catch(() => {});
|
||||
dispatch("getTaskForDashboard");
|
||||
@ -2214,16 +2225,17 @@ export default {
|
||||
url = url.replace("http://", "ws://");
|
||||
url += "?action=web&token=" + state.userToken;
|
||||
//
|
||||
const wgLog = $A.openVlog;
|
||||
const wsRandom = $A.randomString(16);
|
||||
state.wsRandom = wsRandom;
|
||||
//
|
||||
state.ws = new WebSocket(url);
|
||||
state.ws.onopen = (e) => {
|
||||
// console.log("[WS] Open", $A.formatDate())
|
||||
wgLog && console.log("[WS] Open", e, $A.formatDate())
|
||||
state.wsOpenNum++;
|
||||
};
|
||||
state.ws.onclose = (e) => {
|
||||
// console.log("[WS] Close", $A.formatDate())
|
||||
wgLog && console.log("[WS] Close", e, $A.formatDate())
|
||||
state.ws = null;
|
||||
//
|
||||
clearTimeout(state.wsTimeout);
|
||||
@ -2232,7 +2244,7 @@ export default {
|
||||
}, 3000);
|
||||
};
|
||||
state.ws.onerror = (e) => {
|
||||
// console.log("[WS] Error", $A.formatDate())
|
||||
wgLog && console.log("[WS] Error", e, $A.formatDate())
|
||||
state.ws = null;
|
||||
//
|
||||
clearTimeout(state.wsTimeout);
|
||||
@ -2241,7 +2253,7 @@ export default {
|
||||
}, 3000);
|
||||
};
|
||||
state.ws.onmessage = (e) => {
|
||||
// console.log("[WS] Message", e);
|
||||
wgLog && console.log("[WS] Message", e);
|
||||
const msgDetail = $A.formatWebsocketMessageDetail($A.jsonParse(e.data));
|
||||
const {type, msgId} = msgDetail;
|
||||
switch (type) {
|
||||
@ -2266,7 +2278,7 @@ export default {
|
||||
try {
|
||||
call(msgDetail);
|
||||
} catch (err) {
|
||||
// console.log("[WS] Callerr", err);
|
||||
wgLog && console.log("[WS] Callerr", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
10
resources/assets/statics/public/js/vconsole.min.js
vendored
Normal file
10
resources/assets/statics/public/js/vconsole.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user