Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Fix: redirect to install page
Browse files Browse the repository at this point in the history
  • Loading branch information
yumao233 committed Aug 27, 2022
1 parent f2512e4 commit 84e4b05
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
19 changes: 18 additions & 1 deletion src/app/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,31 @@ export default {
async created() {
let needToRoot = false;

try {
// Get current panel status information
const statusInfo = await requestPanelStatus();
if (statusInfo.language) {
console.log("SET_LANGUAGE:", statusInfo.language, statusInfo);
this.$i18n.locale = statusInfo.language;
} else {
this.$i18n.locale = "en_us";
}
// If not installed, must route to /install
if (statusInfo?.isInstall === false) {
return router.push({ path: "/install" });
}
} catch (error) {
alert(`Err: ${error}, Please refresh!`);
}

try {
// After the first refresh, try to get user data once
// If it fails, navigate to / view to further decide the jump route
await setupUserInfo();
const userInfo = this.$store.state.userInfo;
if (!userInfo || !userInfo.uuid) throw new Error("userInfo.uuid is null");
} catch (error) {
console.log(error);
console.log("App.vue redirected to root.vue");
needToRoot = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import zh_cn from "../language/zh_cn"
import en_us from "../language/en_us"

const i18n = createI18n({
locale: 'zh_cn',
locale: 'en_us',
fallbackLocale: 'en_us',
messages: {
zh_cn,
Expand Down
17 changes: 1 addition & 16 deletions src/app/views/Root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<script>
import Panel from "../../components/Panel";
import router from "../router";
import { requestPanelStatus, setupUserInfo } from "../service/protocol";
import { setupUserInfo } from "../service/protocol";

export default {
components: { Panel },
Expand All @@ -30,21 +30,6 @@ export default {
}
},
async init() {
try {
// Get current panel status information
const statusInfo = await requestPanelStatus();
if (statusInfo.language) {
console.log("SET_LANGUAGE:", statusInfo.language, statusInfo);
this.$i18n.locale = statusInfo.language;
} else {
this.$i18n.locale = "en_us";
}
// If not installed, must route to /install
if (statusInfo?.isInstall === false) return router.push({ path: "/install" });
} catch (error) {
alert(`Err: ${error}, Please refresh!`);
}

try {
// In order to adapt to seamless login, data must be requested again here
if (this.$store.state.userInfo?.permission && this.$store.state.userInfo?.uuid)
Expand Down

0 comments on commit 84e4b05

Please sign in to comment.