mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +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: {
|
computed: {
|
||||||
...mapState(['userId', 'userToken']),
|
...mapState(['ws', 'userId', 'userToken']),
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@ -83,7 +83,8 @@ export default {
|
|||||||
handler() {
|
handler() {
|
||||||
this.$store.dispatch("websocketConnection");
|
this.$store.dispatch("websocketConnection");
|
||||||
//
|
//
|
||||||
if (this.$isEEUiApp && this.userId > 0) {
|
if (this.userId > 0) {
|
||||||
|
if (this.$isEEUiApp) {
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
const webview = requireModuleJs("webview");
|
const webview = requireModuleJs("webview");
|
||||||
webview && webview.sendMessage({
|
webview && webview.sendMessage({
|
||||||
@ -94,6 +95,25 @@ export default {
|
|||||||
});
|
});
|
||||||
}, 6000)
|
}, 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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
@ -229,12 +249,22 @@ export default {
|
|||||||
}
|
}
|
||||||
// 页面失活
|
// 页面失活
|
||||||
window.__onPagePause = () => {
|
window.__onPagePause = () => {
|
||||||
|
if (this.openVlog) {
|
||||||
|
console.log('onPagePause');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 页面激活
|
// 页面激活
|
||||||
window.__onPageResume = (num) => {
|
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) {
|
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.$isSubElectron = false;
|
||||||
Vue.prototype.$isEEUiApp = isEEUiApp;
|
Vue.prototype.$isEEUiApp = isEEUiApp;
|
||||||
Vue.prototype.$isDesktop = $A.isDesktop();
|
Vue.prototype.$isDesktop = $A.isDesktop();
|
||||||
|
Vue.prototype.$openVlog = $A.getStorageString("vlog::open") === "open";
|
||||||
if (isElectron) {
|
if (isElectron) {
|
||||||
Vue.prototype.$Electron = electron;
|
Vue.prototype.$Electron = electron;
|
||||||
Vue.prototype.$Platform = /macintosh|mac os x/i.test(navigator.userAgent) ? "mac" : "win";
|
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.isSubElectron = app.$isSubElectron;
|
||||||
$A.isEEUiApp = app.$isEEUiApp;
|
$A.isEEUiApp = app.$isEEUiApp;
|
||||||
$A.isDesktop = app.$isDesktop;
|
$A.isDesktop = app.$isDesktop;
|
||||||
|
$A.openVlog = app.$openVlog;
|
||||||
$A.execMainDispatch = (action, data) => {
|
$A.execMainDispatch = (action, data) => {
|
||||||
if ($A.isSubElectron) {
|
if ($A.isSubElectron) {
|
||||||
$A.Electron.sendMessage('sendForwardMain', {
|
$A.Electron.sendMessage('sendForwardMain', {
|
||||||
|
|||||||
@ -679,11 +679,7 @@ export default {
|
|||||||
|
|
||||||
wsOpenNum(num) {
|
wsOpenNum(num) {
|
||||||
if (num <= 1) return
|
if (num <= 1) return
|
||||||
this.wsOpenTimeout && clearTimeout(this.wsOpenTimeout)
|
this.$store.dispatch("getBasicData", 5000).then(this.getReportUnread)
|
||||||
this.wsOpenTimeout = setTimeout(() => {
|
|
||||||
this.$store.dispatch("getBasicData")
|
|
||||||
this.getReportUnread()
|
|
||||||
}, 5000)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
workReportShow(show) {
|
workReportShow(show) {
|
||||||
|
|||||||
@ -258,6 +258,20 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
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) {
|
contactsKey(val) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.contactsKey == val) {
|
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 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("getProjects").catch(() => {});
|
||||||
dispatch("getDialogs").catch(() => {});
|
dispatch("getDialogs").catch(() => {});
|
||||||
dispatch("getTaskForDashboard");
|
dispatch("getTaskForDashboard");
|
||||||
@ -2214,16 +2225,17 @@ export default {
|
|||||||
url = url.replace("http://", "ws://");
|
url = url.replace("http://", "ws://");
|
||||||
url += "?action=web&token=" + state.userToken;
|
url += "?action=web&token=" + state.userToken;
|
||||||
//
|
//
|
||||||
|
const wgLog = $A.openVlog;
|
||||||
const wsRandom = $A.randomString(16);
|
const wsRandom = $A.randomString(16);
|
||||||
state.wsRandom = wsRandom;
|
state.wsRandom = wsRandom;
|
||||||
//
|
//
|
||||||
state.ws = new WebSocket(url);
|
state.ws = new WebSocket(url);
|
||||||
state.ws.onopen = (e) => {
|
state.ws.onopen = (e) => {
|
||||||
// console.log("[WS] Open", $A.formatDate())
|
wgLog && console.log("[WS] Open", e, $A.formatDate())
|
||||||
state.wsOpenNum++;
|
state.wsOpenNum++;
|
||||||
};
|
};
|
||||||
state.ws.onclose = (e) => {
|
state.ws.onclose = (e) => {
|
||||||
// console.log("[WS] Close", $A.formatDate())
|
wgLog && console.log("[WS] Close", e, $A.formatDate())
|
||||||
state.ws = null;
|
state.ws = null;
|
||||||
//
|
//
|
||||||
clearTimeout(state.wsTimeout);
|
clearTimeout(state.wsTimeout);
|
||||||
@ -2232,7 +2244,7 @@ export default {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
};
|
};
|
||||||
state.ws.onerror = (e) => {
|
state.ws.onerror = (e) => {
|
||||||
// console.log("[WS] Error", $A.formatDate())
|
wgLog && console.log("[WS] Error", e, $A.formatDate())
|
||||||
state.ws = null;
|
state.ws = null;
|
||||||
//
|
//
|
||||||
clearTimeout(state.wsTimeout);
|
clearTimeout(state.wsTimeout);
|
||||||
@ -2241,7 +2253,7 @@ export default {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
};
|
};
|
||||||
state.ws.onmessage = (e) => {
|
state.ws.onmessage = (e) => {
|
||||||
// console.log("[WS] Message", e);
|
wgLog && console.log("[WS] Message", e);
|
||||||
const msgDetail = $A.formatWebsocketMessageDetail($A.jsonParse(e.data));
|
const msgDetail = $A.formatWebsocketMessageDetail($A.jsonParse(e.data));
|
||||||
const {type, msgId} = msgDetail;
|
const {type, msgId} = msgDetail;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -2266,7 +2278,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
call(msgDetail);
|
call(msgDetail);
|
||||||
} catch (err) {
|
} 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