12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <template>
- <div id="app"><router-view /></div>
- </template>
- <script>
- import timeMixin from "./mixins/timeMixin";
- import { QUESTION_API } from "@/constants/constants";
- export default {
- name: "App",
- mixins: [timeMixin],
- data() {
- return {
- signalWaiting: false,
- };
- },
- watch: {
- $route: {
- immediate: true,
- handler(val) {
- const unSignalRoutes = ["Root", "Login", "NotFound", "CardBuild"];
- if (val.name && unSignalRoutes.includes(val.name)) {
- this.signalWaiting = false;
- this.clearSetTs();
- return;
- }
- this.onlineSignal();
- },
- },
- },
- beforeDestroy() {
- this.clearSetTs();
- },
- methods: {
- async onlineSignal() {
- if (this.signalWaiting) return;
- this.clearSetTs();
- this.signalWaiting = true;
- let result = true;
- await this.$httpWithoutBar
- .post(QUESTION_API + "/user/online/signal")
- .catch((error) => {
- result = false;
- console.log("signal error", error);
- });
- if (!result) {
- this.signalWaiting = false;
- return;
- }
- this.addSetTime(() => {
- this.signalWaiting = false;
- this.onlineSignal();
- }, 50 * 1000);
- },
- },
- };
- </script>
|