|
@@ -1,12 +1,12 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="app-container dark-theme" @contextmenu.prevent>
|
|
|
|
|
- <!-- 中文配置 -->
|
|
|
|
|
- <a-config-provider :locale="zhCN">
|
|
|
|
|
- <a-spin :tip="tip" :spinning="spinning" size="large">
|
|
|
|
|
- <router-view />
|
|
|
|
|
- </a-spin>
|
|
|
|
|
- </a-config-provider>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div class="app-container dark-theme" @contextmenu.prevent>
|
|
|
|
|
+ <!-- 中文配置 -->
|
|
|
|
|
+ <a-config-provider :locale="zhCN">
|
|
|
|
|
+ <a-spin :tip="tip" :spinning="spinning" size="large">
|
|
|
|
|
+ <router-view />
|
|
|
|
|
+ </a-spin>
|
|
|
|
|
+ </a-config-provider>
|
|
|
|
|
+ </div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
@@ -26,126 +26,127 @@ import { defineComponent, onMounted, provide, ref, watchEffect } from 'vue';
|
|
|
let lastTime = new Date().getTime();
|
|
let lastTime = new Date().getTime();
|
|
|
|
|
|
|
|
function logoutAction() {
|
|
function logoutAction() {
|
|
|
- logout();
|
|
|
|
|
- APP.closeServer();
|
|
|
|
|
- Router.replace('/login');
|
|
|
|
|
|
|
+ logout();
|
|
|
|
|
+ APP.closeServer();
|
|
|
|
|
+ APP.closeQuote();
|
|
|
|
|
+ Router.replace('/login');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置太久没有操作界面,自动退出界面功能
|
|
// 设置太久没有操作界面,自动退出界面功能
|
|
|
function setOvertime() {
|
|
function setOvertime() {
|
|
|
- window.addEventListener('mousemove', () => {
|
|
|
|
|
- lastTime = new Date().getTime(); //更新当前时间
|
|
|
|
|
- });
|
|
|
|
|
- const mimut = 30;
|
|
|
|
|
- const timeOut = mimut * 60 * 1000; //设置超时时间: 5分钟
|
|
|
|
|
- TimerUtils.setInterval(
|
|
|
|
|
- () => {
|
|
|
|
|
- const currentTime = new Date().getTime();
|
|
|
|
|
- if (currentTime - lastTime > timeOut) {
|
|
|
|
|
- //判断是否超时
|
|
|
|
|
- if (isLogin()) {
|
|
|
|
|
- Modal.info({
|
|
|
|
|
- title: '系统提示:',
|
|
|
|
|
- content: `您已超过${mimut}分钟没有进行任何操作,已自动退出登录!`,
|
|
|
|
|
- okType: 'primary',
|
|
|
|
|
- okText: '确定',
|
|
|
|
|
- keyboard: false,
|
|
|
|
|
- });
|
|
|
|
|
- logoutAction();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- timeOut,
|
|
|
|
|
- 'overtimeInterval'
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ window.addEventListener('mousemove', () => {
|
|
|
|
|
+ lastTime = new Date().getTime(); //更新当前时间
|
|
|
|
|
+ });
|
|
|
|
|
+ const mimut = 30;
|
|
|
|
|
+ const timeOut = mimut * 60 * 1000; //设置超时时间: 5分钟
|
|
|
|
|
+ TimerUtils.setInterval(
|
|
|
|
|
+ () => {
|
|
|
|
|
+ const currentTime = new Date().getTime();
|
|
|
|
|
+ if (currentTime - lastTime > timeOut) {
|
|
|
|
|
+ //判断是否超时
|
|
|
|
|
+ if (isLogin()) {
|
|
|
|
|
+ Modal.info({
|
|
|
|
|
+ title: '系统提示:',
|
|
|
|
|
+ content: `您已超过${mimut}分钟没有进行任何操作,已自动退出登录!`,
|
|
|
|
|
+ okType: 'primary',
|
|
|
|
|
+ okText: '确定',
|
|
|
|
|
+ keyboard: false,
|
|
|
|
|
+ });
|
|
|
|
|
+ logoutAction();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ timeOut,
|
|
|
|
|
+ 'overtimeInterval'
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 设置 ico
|
|
// 设置 ico
|
|
|
async function setIcon() {
|
|
async function setIcon() {
|
|
|
- const link: any = document.querySelector("link[rel*='icon']") || document.createElement('link');
|
|
|
|
|
- const obj = {
|
|
|
|
|
- type: 'image/x-icon',
|
|
|
|
|
- rel: 'shortcut icon',
|
|
|
|
|
- href: './favicon.ico',
|
|
|
|
|
- }
|
|
|
|
|
- Object.assign(link, obj)
|
|
|
|
|
- const config = await getAppConfig();
|
|
|
|
|
- document.title = config.data.icoTitle
|
|
|
|
|
- document.getElementsByTagName('head')[0].appendChild(link);
|
|
|
|
|
|
|
+ const link: any = document.querySelector("link[rel*='icon']") || document.createElement('link');
|
|
|
|
|
+ const obj = {
|
|
|
|
|
+ type: 'image/x-icon',
|
|
|
|
|
+ rel: 'shortcut icon',
|
|
|
|
|
+ href: './favicon.ico',
|
|
|
|
|
+ }
|
|
|
|
|
+ Object.assign(link, obj)
|
|
|
|
|
+ const config = await getAppConfig();
|
|
|
|
|
+ document.title = config.data.icoTitle
|
|
|
|
|
+ document.getElementsByTagName('head')[0].appendChild(link);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
- name: 'app',
|
|
|
|
|
- components: {},
|
|
|
|
|
- setup() {
|
|
|
|
|
- initTheme();
|
|
|
|
|
- let spinning = ref<boolean>(false);
|
|
|
|
|
- const tip = ref<string>('');
|
|
|
|
|
- // 登出状态展示
|
|
|
|
|
- eventBus.$onOnly('logout', () => {
|
|
|
|
|
- tip.value = '跳转中...';
|
|
|
|
|
- spinning.value = true;
|
|
|
|
|
- TimerUtils.setTimeout(
|
|
|
|
|
- () => {
|
|
|
|
|
- spinning.value = false;
|
|
|
|
|
- logoutAction();
|
|
|
|
|
- },
|
|
|
|
|
- 1000,
|
|
|
|
|
- 'logoutTimer'
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
- onMounted(() => {
|
|
|
|
|
- setIcon();
|
|
|
|
|
- });
|
|
|
|
|
- // 登录成功
|
|
|
|
|
- // eventBus.$onOnly('loginSuccess', setOvertime);
|
|
|
|
|
- // 监听路由的变化
|
|
|
|
|
- watchEffect(() => Router.currentRoute && provide('current-route', Router.currentRoute));
|
|
|
|
|
|
|
+ name: 'app',
|
|
|
|
|
+ components: {},
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ initTheme();
|
|
|
|
|
+ let spinning = ref<boolean>(false);
|
|
|
|
|
+ const tip = ref<string>('');
|
|
|
|
|
+ // 登出状态展示
|
|
|
|
|
+ eventBus.$onOnly('logout', () => {
|
|
|
|
|
+ tip.value = '跳转中...';
|
|
|
|
|
+ spinning.value = true;
|
|
|
|
|
+ TimerUtils.setTimeout(
|
|
|
|
|
+ () => {
|
|
|
|
|
+ spinning.value = false;
|
|
|
|
|
+ logoutAction();
|
|
|
|
|
+ },
|
|
|
|
|
+ 1000,
|
|
|
|
|
+ 'logoutTimer'
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
|
|
+ onMounted(() => {
|
|
|
|
|
+ setIcon();
|
|
|
|
|
+ });
|
|
|
|
|
+ // 登录成功
|
|
|
|
|
+ // eventBus.$onOnly('loginSuccess', setOvertime);
|
|
|
|
|
+ // 监听路由的变化
|
|
|
|
|
+ watchEffect(() => Router.currentRoute && provide('current-route', Router.currentRoute));
|
|
|
|
|
|
|
|
- // 监听刷新事件
|
|
|
|
|
- window.addEventListener(
|
|
|
|
|
- 'load',
|
|
|
|
|
- () => {
|
|
|
|
|
- tip.value = '数据初始化...';
|
|
|
|
|
- lastTime = new Date().getTime(); //更新当前时间
|
|
|
|
|
- spinning.value = true;
|
|
|
|
|
- // 注册全局loadComplete事件 保证loadComplete变量及时更新
|
|
|
|
|
- setLoadComplete(false);
|
|
|
|
|
- globalDataRefresh()
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
- setLoadComplete(true);
|
|
|
|
|
- eventBus.$emit('loadComplete');
|
|
|
|
|
- spinning.value = false;
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- console.error(err);
|
|
|
|
|
- spinning.value = false;
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- true
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ // 监听刷新事件
|
|
|
|
|
+ window.addEventListener(
|
|
|
|
|
+ 'load',
|
|
|
|
|
+ () => {
|
|
|
|
|
+ tip.value = '数据初始化...';
|
|
|
|
|
+ lastTime = new Date().getTime(); //更新当前时间
|
|
|
|
|
+ spinning.value = true;
|
|
|
|
|
+ // 注册全局loadComplete事件 保证loadComplete变量及时更新
|
|
|
|
|
+ setLoadComplete(false);
|
|
|
|
|
+ globalDataRefresh()
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ setLoadComplete(true);
|
|
|
|
|
+ eventBus.$emit('loadComplete');
|
|
|
|
|
+ spinning.value = false;
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.error(err);
|
|
|
|
|
+ spinning.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ true
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- // setOvertime();
|
|
|
|
|
- // 订阅交易通知
|
|
|
|
|
- notice((msg: string) => {
|
|
|
|
|
- Modal.info({
|
|
|
|
|
- title: '系统提示:',
|
|
|
|
|
- content: `${msg},请重新登录。`,
|
|
|
|
|
- okType: 'primary',
|
|
|
|
|
- okText: '确定',
|
|
|
|
|
- keyboard: false,
|
|
|
|
|
- onOk() {
|
|
|
|
|
- Router.replace('/login');
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // setOvertime();
|
|
|
|
|
+ // 订阅交易通知
|
|
|
|
|
+ notice((msg: string) => {
|
|
|
|
|
+ Modal.info({
|
|
|
|
|
+ title: '系统提示:',
|
|
|
|
|
+ content: `${msg},请重新登录。`,
|
|
|
|
|
+ okType: 'primary',
|
|
|
|
|
+ okText: '确定',
|
|
|
|
|
+ keyboard: false,
|
|
|
|
|
+ onOk() {
|
|
|
|
|
+ Router.replace('/login');
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- return {
|
|
|
|
|
- tip,
|
|
|
|
|
- spinning,
|
|
|
|
|
- zhCN,
|
|
|
|
|
- };
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ tip,
|
|
|
|
|
+ spinning,
|
|
|
|
|
+ zhCN,
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|