Commit b6b0768b authored by 耿迪迪's avatar 耿迪迪
parents acd69670 8b7949d5
...@@ -192,8 +192,22 @@ ...@@ -192,8 +192,22 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.3.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
\ No newline at end of file
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
}, },
created(){ created(){
//登录成功后创建websocket //登录成功后创建websocket
this.$websocket.initWebSocket("ws://localhost:8668/precisionEffect/webSocket/" + this.$store.state.user.roles.join(",") + "/" + this.$store.state.user.userId); this.$websocket.initWebSocket("ws://36.139.131.221:8668/precisionEffect/webSocket/" + this.$store.state.user.roles.join(",") + "/" + this.$store.state.user.userId);
this.$websocket.addEvent("onmessage",(msg) =>{ this.$websocket.addEvent("onmessage",(msg) =>{
if(msg.data){ if(msg.data){
console.log("您有新的消息请注意接收:", JSON.parse(msg.data)); console.log("您有新的消息请注意接收:", JSON.parse(msg.data));
......
import router from './router' import router from "./router";
import store from './store' import store from "./store";
import { Message } from 'element-ui' import { Message } from "element-ui";
import NProgress from 'nprogress' import NProgress from "nprogress";
import 'nprogress/nprogress.css' import "nprogress/nprogress.css";
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
NProgress.configure({ showSpinner: false }) NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] const whiteList = ["/login", "/auth-redirect", "/bind", "/register"];
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start();
if (getToken()) { if (getToken()) {
/* has token*/ /* has token*/
if (to.path === '/login') { if (to.path === "/login") {
next({ path: '/' }) next({ path: "/" });
NProgress.done() NProgress.done();
} else { } else {
if (store.getters.roles.length === 0) { if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息 // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(() => { store
store.dispatch('GenerateRoutes').then(accessRoutes => { .dispatch("GetInfo")
// 根据roles权限生成可访问的路由表 .then(() => {
router.addRoutes(accessRoutes) // 动态添加可访问路由表 store.dispatch("GenerateRoutes").then((accessRoutes) => {
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 // 根据roles权限生成可访问的路由表
}) router.addRoutes(accessRoutes); // 动态添加可访问路由表
}).catch(err => { // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
store.dispatch('LogOut').then(() => { const origin = router.options.routes.find((item) => {
Message.error(err) return item.redirect === "index";
next({ path: '/' }) });
}) // 隐藏
origin.children[0].hidden = true;
// 挑战
if (accessRoutes[0].children) {
next({ ...accessRoutes[0].children[0] });
}
// console.log('accessRoutes[0].children',accessRoutes)
});
}) })
.catch((err) => {
store.dispatch("LogOut").then(() => {
Message.error(err);
next({ path: "/" });
});
});
} else { } else {
next() next();
} }
} }
} else { } else {
// 没有token // 没有token
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next() next();
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
NProgress.done() NProgress.done();
} }
} }
}) });
router.afterEach(() => { router.afterEach(() => {
NProgress.done() NProgress.done();
}) });
...@@ -65,8 +65,8 @@ export default { ...@@ -65,8 +65,8 @@ export default {
codeUrl: "", codeUrl: "",
cookiePassword: "", cookiePassword: "",
loginForm: { loginForm: {
username: "admin", username: "",
password: "admin123", password: "",
rememberMe: false, rememberMe: false,
code: "", code: "",
uuid: "" uuid: ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment