|
|
@@ -5,27 +5,45 @@ import App from "./App.vue";
|
|
|
import router from "./router";
|
|
|
import store from "./store";
|
|
|
import md5 from "md5";
|
|
|
+import tcb from "./apis/cloudLogin";
|
|
|
+const db = tcb.database();
|
|
|
+const cloudConfig = db.collection("huihenduo_manage_config");
|
|
|
|
|
|
const app = createApp(App);
|
|
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
- let id = localStorage.id;
|
|
|
- if (id) {
|
|
|
- store.commit("changeLogin", true);
|
|
|
- if (0 === to.matched.length) {
|
|
|
- next("/cargoOwnerManage/cargoOwnerList");
|
|
|
- } else if (to.path == "/login" || to.path == "/") {
|
|
|
- next("/cargoOwnerManage/cargoOwnerList");
|
|
|
+ let res = await cloudConfig.doc("18ed09686196068205eeb77612d641c6").get();
|
|
|
+ let currentVersion = localStorage.version;
|
|
|
+ let { version } = res.data[0];
|
|
|
+ if (currentVersion == version) {
|
|
|
+ let id = localStorage.id;
|
|
|
+ if (id) {
|
|
|
+ store.commit("changeLogin", true);
|
|
|
+ if (0 === to.matched.length) {
|
|
|
+ next("/cargoOwnerManage/cargoOwnerList");
|
|
|
+ } else if (to.path == "/login" || to.path == "/") {
|
|
|
+ next("/cargoOwnerManage/cargoOwnerList");
|
|
|
+ } else {
|
|
|
+ next();
|
|
|
+ }
|
|
|
} else {
|
|
|
- next();
|
|
|
+ store.commit("changeLogin", false);
|
|
|
+ if (to.path == "/login") {
|
|
|
+ next();
|
|
|
+ } else {
|
|
|
+ next("/login");
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
+ localStorage.removeItem("staffPhone");
|
|
|
+ localStorage.removeItem("id");
|
|
|
+ localStorage.removeItem("status");
|
|
|
+ localStorage.removeItem("userType");
|
|
|
+ localStorage.removeItem("staffName");
|
|
|
+ localStorage.setItem("version", version);
|
|
|
+ location.reload();
|
|
|
store.commit("changeLogin", false);
|
|
|
- if (to.path == "/login") {
|
|
|
- next();
|
|
|
- } else {
|
|
|
- next("/login");
|
|
|
- }
|
|
|
+ next("/login");
|
|
|
}
|
|
|
});
|
|
|
router.afterEach((to, from) => {
|