|
@@ -12,16 +12,23 @@ import Certs from "./components/Certs.vue";
|
|
|
const app = createApp(App);
|
|
const app = createApp(App);
|
|
|
app.component("Certs", Certs);
|
|
app.component("Certs", Certs);
|
|
|
app.component("Uploader", Uploader);
|
|
app.component("Uploader", Uploader);
|
|
|
|
|
+
|
|
|
|
|
+let userId = localStorage.userId;
|
|
|
|
|
+if (userId) {
|
|
|
|
|
+ store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
|
|
|
|
|
+ store.dispatch("GetUserPermission", localStorage.loginAccountId);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
- let userId = localStorage.userId;
|
|
|
|
|
- if (userId) {
|
|
|
|
|
|
|
+ if (localStorage.userId) {
|
|
|
store.commit("changeLogin", true);
|
|
store.commit("changeLogin", true);
|
|
|
- store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
|
|
|
|
|
- store.dispatch("GetUserPermission", localStorage.loginAccountId);
|
|
|
|
|
|
|
+ let rolePermission = localStorage.rolePermission?.split(",") || [];
|
|
|
if (0 === to.matched.length) {
|
|
if (0 === to.matched.length) {
|
|
|
next("/voyage/voyageList");
|
|
next("/voyage/voyageList");
|
|
|
} else if (to.path == "/login" || to.path == "/") {
|
|
} else if (to.path == "/login" || to.path == "/") {
|
|
|
next("/voyage/voyageList");
|
|
next("/voyage/voyageList");
|
|
|
|
|
+ } else if (rolePermission?.indexOf(to.meta.code) == -1) {
|
|
|
|
|
+ next("/voyage/voyageList");
|
|
|
} else {
|
|
} else {
|
|
|
next();
|
|
next();
|
|
|
}
|
|
}
|
|
@@ -40,13 +47,10 @@ router.afterEach((to, from) => {
|
|
|
store.commit("setCurrentMenuItem", to.path);
|
|
store.commit("setCurrentMenuItem", to.path);
|
|
|
store.commit("changefirstTitle", title);
|
|
store.commit("changefirstTitle", title);
|
|
|
});
|
|
});
|
|
|
-app.config.globalProperties.check = () => {
|
|
|
|
|
- console.log("check");
|
|
|
|
|
-};
|
|
|
|
|
|
|
|
|
|
app.directive("auth", {
|
|
app.directive("auth", {
|
|
|
mounted(el, bind) {
|
|
mounted(el, bind) {
|
|
|
- let permissions = store.state.userPermission;
|
|
|
|
|
|
|
+ let permissions = localStorage.rolePermission?.split(",");
|
|
|
if (permissions.indexOf(bind.value) == -1) {
|
|
if (permissions.indexOf(bind.value) == -1) {
|
|
|
el.parentNode.removeChild(el);
|
|
el.parentNode.removeChild(el);
|
|
|
}
|
|
}
|