1
This commit is contained in:
parent
b4a3aa567e
commit
3d3564850c
@ -111,7 +111,7 @@ public class SecurityConfig
|
||||
.authorizeHttpRequests((requests) -> {
|
||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
requests.antMatchers("/login","/wxLogin", "/register", "/captchaImage","/sys/ueditor/exec").permitAll()
|
||||
requests.antMatchers("/login","/wxLogin", "/register", "/captchaImage","/sys/ueditor/exec","/ws/asset/**").permitAll()
|
||||
//相关配置参数可匿名访问
|
||||
.antMatchers("/base/config/getConfigByCode").permitAll()
|
||||
.antMatchers("/base/category/getByCodeInfo").permitAll()
|
||||
|
@ -7,10 +7,23 @@
|
||||
|
||||
<script>
|
||||
import ThemePicker from "@/components/ThemePicker";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
components: { ThemePicker },
|
||||
data(){
|
||||
return{
|
||||
b:false,
|
||||
}
|
||||
},
|
||||
destroyed: function () { // 离开页面生命周期函数
|
||||
this.$websocket.dispatch('websocket_close');
|
||||
},
|
||||
created () {
|
||||
const username = Cookies.get('username')
|
||||
this.$store.dispatch('websocket_init', "ws://localhost:8099/ws/asset/"+username)
|
||||
},
|
||||
metaInfo() {
|
||||
return {
|
||||
title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
|
||||
|
@ -37,6 +37,7 @@ import DictTag from '@/components/DictTag'
|
||||
import VueMeta from 'vue-meta'
|
||||
// 字典数据组件
|
||||
import DictData from '@/components/DictData'
|
||||
import websocket from "./store/websocket";
|
||||
|
||||
// 全局方法挂载
|
||||
Vue.prototype.getDicts = getDicts
|
||||
@ -48,6 +49,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.$websocket=websocket;
|
||||
|
||||
// 全局组件挂载
|
||||
Vue.component('DictTag', DictTag)
|
||||
|
@ -3,6 +3,7 @@ import Vuex from 'vuex'
|
||||
import app from './modules/app'
|
||||
import dict from './modules/dict'
|
||||
import user from './modules/user'
|
||||
import websocket from './modules/websocket'
|
||||
import tagsView from './modules/tagsView'
|
||||
import permission from './modules/permission'
|
||||
import settings from './modules/settings'
|
||||
@ -15,6 +16,7 @@ const store = new Vuex.Store({
|
||||
app,
|
||||
dict,
|
||||
user,
|
||||
websocket,
|
||||
tagsView,
|
||||
permission,
|
||||
settings
|
||||
|
60
dl_vue/src/store/modules/websocket.js
Normal file
60
dl_vue/src/store/modules/websocket.js
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
const websocket = {
|
||||
state: {
|
||||
websock:null,
|
||||
message:[],
|
||||
count:"0",
|
||||
notice:[]
|
||||
},
|
||||
|
||||
mutations: {
|
||||
WEBSOCKET_INIT(state,url){
|
||||
console.log(url);
|
||||
state.websock = new WebSocket(url);
|
||||
state.websock.onopen=function () {
|
||||
console.log("WebSocket连接成功");
|
||||
};
|
||||
state.websock.onmessage = function (e) {
|
||||
if (e.data.startsWith("C")) {
|
||||
state.count = e.data;
|
||||
|
||||
}
|
||||
else if (e.data.startsWith("系统通知")){
|
||||
state.notice.push(e.data);
|
||||
console.log(state.notice);
|
||||
}
|
||||
else {
|
||||
state.message.push(JSON.parse(e.data));
|
||||
// console.log(state.message);
|
||||
}
|
||||
|
||||
};
|
||||
state.websock.onerror= function () {
|
||||
console.log("WebSocket连接发生错误");
|
||||
};
|
||||
state.websock.onclose = function (e) {
|
||||
console.log("connection closed (" + e.code + ")");
|
||||
};
|
||||
},
|
||||
WEBSOCKET_SEND(state,msg){
|
||||
state.websock.send(msg);
|
||||
},
|
||||
WEBSOCKET_CLOSE(state){
|
||||
state.websock.close();
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
websocket_init({commit}, url) {
|
||||
commit('WEBSOCKET_INIT', url)
|
||||
},
|
||||
websocket_send({commit}, msg) {
|
||||
commit('WEBSOCKET_SEND', msg)
|
||||
},
|
||||
websocket_close({commit}){
|
||||
commit('WEBSOCKET_CLOSE')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default websocket
|
64
dl_vue/src/store/websocket.js
Normal file
64
dl_vue/src/store/websocket.js
Normal file
@ -0,0 +1,64 @@
|
||||
// import Vue from 'vue'
|
||||
// import Vuex from 'vuex'
|
||||
//
|
||||
// Vue.use(Vuex)
|
||||
//
|
||||
// export default new Vuex.Store({
|
||||
// //定义全局变量
|
||||
// state: {
|
||||
// websock:null,
|
||||
// message:[],
|
||||
// count:"0",
|
||||
// notice:[]
|
||||
// },
|
||||
// //改变state的值必须经过
|
||||
// mutations: {
|
||||
// WEBSOCKET_INIT(state,url){
|
||||
// console.log(url);
|
||||
// state.websock = new WebSocket(url);
|
||||
// state.websock.onopen=function () {
|
||||
// console.log("WebSocket连接成功");
|
||||
// };
|
||||
// state.websock.onmessage = function (e) {
|
||||
// if (e.data.startsWith("C")) {
|
||||
// state.count = e.data;
|
||||
//
|
||||
// }
|
||||
// else if (e.data.startsWith("系统通知")){
|
||||
// state.notice.push(e.data);
|
||||
// console.log(state.notice);
|
||||
// }
|
||||
// else {
|
||||
// state.message.push(JSON.parse(e.data));
|
||||
// // console.log(state.message);
|
||||
// }
|
||||
//
|
||||
// };
|
||||
// state.websock.onerror= function () {
|
||||
// console.log("WebSocket连接发生错误");
|
||||
// };
|
||||
// state.websock.onclose = function (e) {
|
||||
// console.log("connection closed (" + e.code + ")");
|
||||
// };
|
||||
// },
|
||||
// WEBSOCKET_SEND(state,msg){
|
||||
// state.websock.send(msg);
|
||||
// },
|
||||
// WEBSOCKET_CLOSE(state){
|
||||
// state.websock.close();
|
||||
// }
|
||||
// },
|
||||
// actions: {
|
||||
// websocket_init({commit}, url) {
|
||||
// commit('WEBSOCKET_INIT', url)
|
||||
// },
|
||||
// websocket_send({commit}, msg) {
|
||||
// commit('WEBSOCKET_SEND', msg)
|
||||
// },
|
||||
// websocket_close({commit}){
|
||||
// commit('WEBSOCKET_CLOSE')
|
||||
// }
|
||||
// },
|
||||
// modules: {
|
||||
// }
|
||||
// })
|
@ -189,6 +189,7 @@ export default {
|
||||
Cookies.remove('rememberMe')
|
||||
}
|
||||
this.$store.dispatch('Login', this.loginForm).then(() => {
|
||||
this.$store.dispatch('websocket_init', "ws://localhost:8099/ws/asset/"+this.loginForm.username)
|
||||
listAllSite().then(response => {
|
||||
if (response.data && response.data.length > 0) {
|
||||
response.data.map((item) => {
|
||||
|
Loading…
Reference in New Issue
Block a user