实现单点登录

main
jinna 2 years ago
parent ddf5b860fc
commit ba92438b91
  1. 245
      src/api/user.js
  2. 18
      src/api/wirelessintrusion/wirelessintrusion.js
  3. 40
      src/config/website.js
  4. 55
      src/page/login/userlogin.vue
  5. 412
      src/store/modules/user.js
  6. 4
      vue.config.js

@ -1,126 +1,147 @@
import request from '@/router/axios';
import request from "@/router/axios";
import website from "@/config/website";
export const loginByUsername = (tenantId, deptId, roleId, username, password, type, key, code) => request({
url: '/api/blade-auth/oauth/token',
method: 'post',
headers: {
'Tenant-Id': tenantId,
'Dept-Id': (website.switchMode ? deptId : ''),
'Role-Id': (website.switchMode ? roleId : ''),
'Captcha-Key': key,
'Captcha-Code': code,
},
params: {
tenantId,
username,
password,
grant_type: (website.captchaMode ? "captcha" : "password"),
scope: "all",
type
}
});
export const loginByUsername = (
tenantId,
deptId,
roleId,
username,
password,
type,
key,
code
) =>
request({
url: "/api/blade-auth/oauth/token",
method: "post",
headers: {
"Tenant-Id": tenantId,
"Dept-Id": website.switchMode ? deptId : "",
"Role-Id": website.switchMode ? roleId : "",
"Captcha-Key": key,
"Captcha-Code": code,
},
params: {
tenantId,
username,
password,
grant_type: website.isTokenMode ? "nopassword" : "password",
scope: "all",
type,
},
});
export const loginBySocial = (tenantId, source, code, state) => request({
url: '/api/blade-auth/oauth/token',
method: 'post',
headers: {
'Tenant-Id': tenantId
},
params: {
tenantId,
source,
code,
state,
grant_type: "social",
scope: "all",
}
})
export const loginBySocial = (tenantId, source, code, state) =>
request({
url: "/api/blade-auth/oauth/token",
method: "post",
headers: {
"Tenant-Id": tenantId,
},
params: {
tenantId,
source,
code,
state,
grant_type: "social",
scope: "all",
},
});
export const loginBySso = (state, code) => request({
url: '/api/blade-auth/oauth/token',
method: 'post',
headers: {
'Tenant-Id': state
},
params: {
tenantId: state,
code,
grant_type: "authorization_code",
scope: "all",
redirect_uri: website.redirectUri,
}
})
export const loginBySso = (state, code) =>
request({
url: "/api/blade-auth/oauth/token",
method: "post",
headers: {
"Tenant-Id": state,
},
params: {
tenantId: state,
code,
grant_type: "authorization_code",
scope: "all",
redirect_uri: website.redirectUri,
},
});
export const refreshToken = (refresh_token, tenantId, deptId, roleId) => request({
url: '/api/blade-auth/oauth/token',
method: 'post',
headers: {
'Tenant-Id': tenantId,
'Dept-Id': (website.switchMode ? deptId : ''),
'Role-Id': (website.switchMode ? roleId : '')
},
params: {
tenantId,
refresh_token,
grant_type: "refresh_token",
scope: "all",
}
});
export const refreshToken = (refresh_token, tenantId, deptId, roleId) =>
request({
url: "/api/blade-auth/oauth/token",
method: "post",
headers: {
"Tenant-Id": tenantId,
"Dept-Id": website.switchMode ? deptId : "",
"Role-Id": website.switchMode ? roleId : "",
},
params: {
tenantId,
refresh_token,
grant_type: "refresh_token",
scope: "all",
},
});
export const registerGuest = (form, oauthId) => request({
url: '/api/blade-system/user/register-guest',
method: 'post',
params: {
tenantId: form.tenantId,
name: form.name,
account: form.account,
password: form.password,
oauthId
}
});
export const registerGuest = (form, oauthId) =>
request({
url: "/api/blade-system/user/register-guest",
method: "post",
params: {
tenantId: form.tenantId,
name: form.name,
account: form.account,
password: form.password,
oauthId,
},
});
export const getButtons = () => request({
url: '/api/blade-system/menu/buttons',
method: 'get'
});
export const getButtons = () =>
request({
url: "/api/blade-system/menu/buttons",
method: "get",
});
export const getCaptcha = () => request({
url: '/api/blade-auth/oauth/captcha',
method: 'get',
authorization: false
});
export const getCaptcha = () =>
request({
url: "/api/blade-auth/oauth/captcha",
method: "get",
authorization: false,
});
export const logout = () => request({
url: '/api/blade-auth/oauth/logout',
method: 'get',
authorization: false
});
export const logout = () =>
request({
url: "/api/blade-auth/oauth/logout",
method: "get",
authorization: false,
});
export const getUserInfo = () => request({
url: '/api/blade-auth/oauth/user-info',
method: 'get'
});
export const getUserInfo = () =>
request({
url: "/api/blade-auth/oauth/user-info",
method: "get",
});
export const sendLogs = (list) => request({
url: '/api/blade-auth/oauth/logout',
method: 'post',
data: list
});
export const sendLogs = (list) =>
request({
url: "/api/blade-auth/oauth/logout",
method: "post",
data: list,
});
export const clearCache = () => request({
url: '/api/blade-auth/oauth/clear-cache',
method: 'get',
authorization: false
});
export const clearCache = () =>
request({
url: "/api/blade-auth/oauth/clear-cache",
method: "get",
authorization: false,
});
//授权登录
export const loginByAuth = (applyType, username, password) => request({
url: '/authApi/system/sys-sub/login',
method: 'post',
data: {
applyType,
username,
password
}
});
export const loginByAuth = (applyType, username, password) =>
request({
url: "/authApi/system/sys-sub/login",
method: "post",
data: {
applyType,
username,
password,
},
});

@ -261,3 +261,21 @@ export const closeDecive = (data) => {
params: data,
});
};
// // 根据token获取用户名
// export const getUserAccount = (query) => {
// return request({
// url: "http://171.16.8.58:82/homepageapi/system/sys-sub/token/checkToken",
// method: "get",
// params: query,
// });
// };
// 根据用户名获取密码
export const getPassword = (query) => {
return request({
url: "/api/alarmInformation/getPassword",
method: "get",
params: query,
});
};

@ -4,17 +4,18 @@
export default {
title: "saber",
logo: "S",
key: 'saber',//配置主键,目前用于存储
indexTitle: '入侵报警系统',
clientId: 'saber', // 客户端id
clientSecret: 'saber_secret', // 客户端密钥
key: "saber", //配置主键,目前用于存储
indexTitle: "入侵报警系统",
clientId: "saber", // 客户端id
clientSecret: "saber_secret", // 客户端密钥
tenantMode: false, // 是否开启租户模式
tenantId: "000000", // 管理组租户编号
captchaMode: false, // 是否开启验证码模式
isTokenMode: true, // 是否开启验证码模式
switchMode: false, // 是否开启部门切换模式
lockPage: '/lock',
lockPage: "/lock",
tokenTime: 3000,
tokenHeader: 'Blade-Auth',
tokenHeader: "Blade-Auth",
//http的status默认放行列表
statusWhiteList: [],
//配置首页不可关闭
@ -25,27 +26,28 @@ export default {
params: {},
query: {},
meta: {
i18n: 'dashboard'
i18n: "dashboard",
},
group: [],
close: false
close: false,
},
//配置菜单的属性
menu: {
iconDefault: 'iconfont icon-caidan',
iconDefault: "iconfont icon-caidan",
props: {
label: 'name',
path: 'path',
icon: 'source',
children: 'children'
}
label: "name",
path: "path",
icon: "source",
children: "children",
},
},
// 第三方系统授权地址
authUrl: 'http://localhost/blade-auth/oauth/render',
authUrl: "http://localhost/blade-auth/oauth/render",
// 报表设计器地址(cloud端口为8108,boot端口为80)
reportUrl: 'http://localhost:8108/ureport',
reportUrl: "http://localhost:8108/ureport",
// 单点登录系统认证(blade-auth服务的地)
ssoUrl: 'http://localhost:8100/oauth/authorize?client_id=saber&response_type=code&redirect_uri=',
ssoUrl:
"http://localhost:8100/oauth/authorize?client_id=saber&response_type=code&redirect_uri=",
// 单点登录回调地址(Saber服务的地址)
redirectUri: 'http://localhost:1888',
}
redirectUri: "http://localhost:1888",
};

@ -74,6 +74,7 @@
import {info} from "@/api/system/tenant";
import {getCaptcha, loginByAuth} from "@/api/user";
import {getTopUrl} from "@/util/util";
import {getUserAccount,getPassword} from "@/api/wirelessintrusion/wirelessintrusion";
export default {
name: "userlogin",
@ -159,12 +160,63 @@
}],
},
]
}
},
isToken:false
};
},
created() {
// this.getTenant();
// this.refreshCode();
console.log('token ==========>',this.$route.query.token)
if(this.$route.query.token){
// getUserAccount({token:this.$route.query.token,appId:123,tripartiteVoucher:'u7PgmMH5m6jK71yAg1Gi9Rid1SeSnc9J'}).then(res =>{
// console.log('account ===>',res)
// if(res.data.code == 0){
getPassword({token:this.$route.query.token}).then(res =>{
console.log('pass =========>',res)
console.log('pass =========>',res.data.code)
if(res.data.code == 200){
let params = {
tenantId:this.loginForm.tenantId,
image: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
type: "account",
deptId: "",
roleId: "",
username: res.data.data.username,
password: res.data.data.password,
code: "",
key: "",
isToken:true
}
console.log('params ====>',params)
this.$store.dispatch("LoginByUsername",params).then(() => {
console.log('login =======> 登录成功')
// if (this.website.switchMode) {
// const deptId = this.userInfo.dept_id;
// const roleId = this.userInfo.role_id;
// if (deptId.includes(",") || roleId.includes(",")) {
// this.loginForm.deptId = deptId;
// this.loginForm.roleId = roleId;
// this.userBox = true;
// this.$store.dispatch("LogOut").then(() => {
// // loading.close();
// });
// return false;
// }
// }
this.$router.push({path: this.tagWel.value});
// loading.close();
}).catch(() => {
// loading.close();
// this.refreshCode();
});
}
})
// }
// })
}
},
mounted() {
},
@ -225,6 +277,7 @@
text: '登录中,请稍后。。。',
spinner: "el-icon-loading"
});
this.website.isTokenMode = false
this.$store.dispatch("LoginByUsername", this.loginForm).then(() => {
if (this.website.switchMode) {
const deptId = this.userInfo.dept_id;

@ -1,272 +1,345 @@
import {setToken, setRefreshToken, removeToken, removeRefreshToken} from '@/util/auth'
import {Message} from 'element-ui'
import {setStore, getStore} from '@/util/store'
import {isURL, validatenull} from '@/util/validate'
import {deepClone} from '@/util/util'
import website from '@/config/website'
import {loginByUsername, loginBySocial, loginBySso, getUserInfo, logout, refreshToken, getButtons} from '@/api/user'
import {getTopMenu, getRoutes} from '@/api/system/menu'
import md5 from 'js-md5'
import {
setToken,
setRefreshToken,
removeToken,
removeRefreshToken,
} from "@/util/auth";
import { Message } from "element-ui";
import { setStore, getStore } from "@/util/store";
import { isURL, validatenull } from "@/util/validate";
import { deepClone } from "@/util/util";
import website from "@/config/website";
import {
loginByUsername,
loginBySocial,
loginBySso,
getUserInfo,
logout,
refreshToken,
getButtons,
} from "@/api/user";
import { getTopMenu, getRoutes } from "@/api/system/menu";
import md5 from "js-md5";
function addPath(ele, first) {
const menu = website.menu;
const propsConfig = menu.props;
const propsDefault = {
label: propsConfig.label || 'name',
path: propsConfig.path || 'path',
icon: propsConfig.icon || 'icon',
children: propsConfig.children || 'children'
}
label: propsConfig.label || "name",
path: propsConfig.path || "path",
icon: propsConfig.icon || "icon",
children: propsConfig.children || "children",
};
const icon = ele[propsDefault.icon];
ele[propsDefault.icon] = validatenull(icon) ? menu.iconDefault : icon;
const isChild = ele[propsDefault.children] && ele[propsDefault.children].length !== 0;
const isChild =
ele[propsDefault.children] && ele[propsDefault.children].length !== 0;
if (!isChild) ele[propsDefault.children] = [];
if (!isChild && first && !isURL(ele[propsDefault.path])) {
ele[propsDefault.path] = ele[propsDefault.path] + '/index'
ele[propsDefault.path] = ele[propsDefault.path] + "/index";
} else {
ele[propsDefault.children].forEach(child => {
ele[propsDefault.children].forEach((child) => {
addPath(child);
})
});
}
}
const user = {
state: {
tenantId: getStore({name: 'tenantId'}) || '',
userInfo: getStore({name: 'userInfo'}) || [],
permission: getStore({name: 'permission'}) || {},
tenantId: getStore({ name: "tenantId" }) || "",
userInfo: getStore({ name: "userInfo" }) || [],
permission: getStore({ name: "permission" }) || {},
roles: [],
menuId: {},
menu: getStore({name: 'menu'}) || [],
menuAll: getStore({name: 'menuAll'}) || [],
token: getStore({name: 'token'}) || '',
refreshToken: getStore({name: 'refreshToken'}) || '',
menu: getStore({ name: "menu" }) || [],
menuAll: getStore({ name: "menuAll" }) || [],
token: getStore({ name: "token" }) || "",
refreshToken: getStore({ name: "refreshToken" }) || "",
},
actions: {
//根据用户名登录
LoginByUsername({commit}, userInfo) {
LoginByUsername({ commit }, userInfo, isToken) {
return new Promise((resolve, reject) => {
loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key, userInfo.code).then(res => {
const data = res.data;
if (data.error_description) {
Message({
message: data.error_description,
type: 'error'
if (userInfo.isToken) {
loginByUsername(
userInfo.tenantId,
userInfo.deptId,
userInfo.roleId,
userInfo.username,
userInfo.password,
userInfo.type,
userInfo.key,
userInfo.code
)
.then((res) => {
const data = res.data;
if (data.error_description) {
Message({
message: data.error_description,
type: "error",
});
} else {
commit("SET_TOKEN", data.access_token);
commit("SET_REFRESH_TOKEN", data.refresh_token);
commit("SET_TENANT_ID", data.tenant_id);
commit("SET_USER_INFO", data);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
}
resolve();
})
} else {
commit('SET_TOKEN', data.access_token);
commit('SET_REFRESH_TOKEN', data.refresh_token);
commit('SET_TENANT_ID', data.tenant_id);
commit('SET_USER_INFO', data);
commit('DEL_ALL_TAG');
commit('CLEAR_LOCK');
}
resolve();
}).catch(error => {
reject(error);
})
})
.catch((error) => {
reject(error);
});
} else {
loginByUsername(
userInfo.tenantId,
userInfo.deptId,
userInfo.roleId,
userInfo.username,
md5(userInfo.password),
userInfo.type,
userInfo.key,
userInfo.code
)
.then((res) => {
const data = res.data;
if (data.error_description) {
Message({
message: data.error_description,
type: "error",
});
} else {
commit("SET_TOKEN", data.access_token);
commit("SET_REFRESH_TOKEN", data.refresh_token);
commit("SET_TENANT_ID", data.tenant_id);
commit("SET_USER_INFO", data);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
}
resolve();
})
.catch((error) => {
reject(error);
});
}
});
},
//根据手机号登录
LoginByPhone({commit}, userInfo) {
LoginByPhone({ commit }, userInfo) {
return new Promise((resolve) => {
loginByUsername(userInfo.phone, userInfo.code).then(res => {
loginByUsername(userInfo.phone, userInfo.code).then((res) => {
const data = res.data.data;
commit('SET_TOKEN', data);
commit('DEL_ALL_TAG');
commit('CLEAR_LOCK');
commit("SET_TOKEN", data);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
resolve();
})
})
});
});
},
//根据第三方信息登录
LoginBySocial({commit}, userInfo) {
LoginBySocial({ commit }, userInfo) {
return new Promise((resolve) => {
loginBySocial(userInfo.tenantId, userInfo.source, userInfo.code, userInfo.state).then(res => {
loginBySocial(
userInfo.tenantId,
userInfo.source,
userInfo.code,
userInfo.state
).then((res) => {
const data = res.data;
if (data.error_description) {
Message({
message: data.error_description,
type: 'error'
})
type: "error",
});
} else {
commit('SET_TOKEN', data.access_token);
commit('SET_REFRESH_TOKEN', data.refresh_token);
commit('SET_USER_INFO', data);
commit('SET_TENANT_ID', data.tenant_id);
commit('DEL_ALL_TAG');
commit('CLEAR_LOCK');
commit("SET_TOKEN", data.access_token);
commit("SET_REFRESH_TOKEN", data.refresh_token);
commit("SET_USER_INFO", data);
commit("SET_TENANT_ID", data.tenant_id);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
}
resolve();
})
})
});
});
},
//根据单点信息登录
LoginBySso({commit}, userInfo) {
LoginBySso({ commit }, userInfo) {
return new Promise((resolve) => {
loginBySso(userInfo.state, userInfo.code).then(res => {
loginBySso(userInfo.state, userInfo.code).then((res) => {
const data = res.data;
if (data.error_description) {
Message({
message: data.error_description,
type: 'error'
})
type: "error",
});
} else {
commit('SET_TOKEN', data.access_token);
commit('SET_REFRESH_TOKEN', data.refresh_token);
commit('SET_USER_INFO', data);
commit('SET_TENANT_ID', data.tenant_id);
commit('DEL_ALL_TAG');
commit('CLEAR_LOCK');
commit("SET_TOKEN", data.access_token);
commit("SET_REFRESH_TOKEN", data.refresh_token);
commit("SET_USER_INFO", data);
commit("SET_TENANT_ID", data.tenant_id);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
}
resolve();
})
})
});
});
},
//获取用户信息
GetUserInfo({commit}) {
GetUserInfo({ commit }) {
return new Promise((resolve, reject) => {
getUserInfo().then((res) => {
const data = res.data.data;
commit('SET_ROLES', data.roles);
resolve(data);
}).catch(err => {
reject(err);
})
})
getUserInfo()
.then((res) => {
const data = res.data.data;
commit("SET_ROLES", data.roles);
resolve(data);
})
.catch((err) => {
reject(err);
});
});
},
//刷新token
refreshToken({state, commit}, userInfo) {
window.console.log('handle refresh token');
refreshToken({ state, commit }, userInfo) {
window.console.log("handle refresh token");
return new Promise((resolve, reject) => {
refreshToken(state.refreshToken, state.tenantId,
refreshToken(
state.refreshToken,
state.tenantId,
!validatenull(userInfo) ? userInfo.deptId : state.userInfo.dept_id,
!validatenull(userInfo) ? userInfo.roleId : state.userInfo.role_id
).then(res => {
const data = res.data;
commit('SET_TOKEN', data.access_token);
commit('SET_REFRESH_TOKEN', data.refresh_token);
commit('SET_USER_INFO', data);
resolve();
}).catch(error => {
reject(error)
})
})
)
.then((res) => {
const data = res.data;
commit("SET_TOKEN", data.access_token);
commit("SET_REFRESH_TOKEN", data.refresh_token);
commit("SET_USER_INFO", data);
resolve();
})
.catch((error) => {
reject(error);
});
});
},
// 登出
LogOut({commit}) {
LogOut({ commit }) {
return new Promise((resolve, reject) => {
logout().then(() => {
commit('SET_TOKEN', '');
commit('SET_MENU', []);
commit('SET_MENU_ALL_NULL', []);
commit('SET_ROLES', []);
commit('SET_TAG_LIST', []);
commit('DEL_ALL_TAG');
commit('CLEAR_LOCK');
removeToken();
removeRefreshToken();
resolve();
}).catch(error => {
reject(error)
})
})
logout()
.then(() => {
commit("SET_TOKEN", "");
commit("SET_MENU", []);
commit("SET_MENU_ALL_NULL", []);
commit("SET_ROLES", []);
commit("SET_TAG_LIST", []);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
removeToken();
removeRefreshToken();
resolve();
})
.catch((error) => {
reject(error);
});
});
},
//注销session
FedLogOut({commit}) {
return new Promise(resolve => {
commit('SET_TOKEN', '');
commit('SET_MENU_ALL_NULL', []);
commit('SET_MENU', []);
commit('SET_ROLES', []);
commit('SET_TAG_LIST', []);
commit('DEL_ALL_TAG');
commit('CLEAR_LOCK');
FedLogOut({ commit }) {
return new Promise((resolve) => {
commit("SET_TOKEN", "");
commit("SET_MENU_ALL_NULL", []);
commit("SET_MENU", []);
commit("SET_ROLES", []);
commit("SET_TAG_LIST", []);
commit("DEL_ALL_TAG");
commit("CLEAR_LOCK");
removeToken();
removeRefreshToken();
resolve();
})
});
},
//获取顶部菜单
GetTopMenu() {
return new Promise(resolve => {
return new Promise((resolve) => {
getTopMenu().then((res) => {
const data = res.data.data || [];
resolve(data)
})
})
resolve(data);
});
});
},
//获取系统菜单
GetMenu({commit, dispatch}, topMenuId) {
return new Promise(resolve => {
GetMenu({ commit, dispatch }, topMenuId) {
return new Promise((resolve) => {
getRoutes(topMenuId).then((res) => {
const data = res.data.data
const data = res.data.data;
let menu = deepClone(data);
menu.forEach(ele => {
menu.forEach((ele) => {
addPath(ele, true);
});
commit('SET_MENU_ALL', menu)
commit('SET_MENU', menu)
dispatch('GetButtons');
resolve(menu)
})
})
commit("SET_MENU_ALL", menu);
commit("SET_MENU", menu);
dispatch("GetButtons");
resolve(menu);
});
});
},
//获取系统按钮
GetButtons({commit}) {
GetButtons({ commit }) {
return new Promise((resolve) => {
getButtons().then(res => {
getButtons().then((res) => {
const data = res.data.data;
commit('SET_PERMISSION', data);
commit("SET_PERMISSION", data);
resolve();
})
})
});
});
},
},
mutations: {
SET_TOKEN: (state, token) => {
setToken(token);
state.token = token;
setStore({name: 'token', content: state.token})
setStore({ name: "token", content: state.token });
},
SET_MENU_ID(state, menuId) {
state.menuId = menuId;
},
SET_MENU_ALL: (state, menuAll) => {
let menu = state.menuAll;
menuAll.forEach(ele => {
if (!menu.find(item => item.label === ele.label && item.path === ele.path)) {
menuAll.forEach((ele) => {
if (
!menu.find(
(item) => item.label === ele.label && item.path === ele.path
)
) {
menu.push(ele);
}
})
state.menuAll = menu
setStore({ name: 'menuAll', content: state.menuAll })
});
state.menuAll = menu;
setStore({ name: "menuAll", content: state.menuAll });
},
SET_MENU_ALL_NULL: (state) => {
state.menuAll = []
setStore({ name: 'menuAll', content: state.menuAll })
state.menuAll = [];
setStore({ name: "menuAll", content: state.menuAll });
},
SET_MENU: (state, menu) => {
state.menu = menu
setStore({ name: 'menu', content: state.menu })
state.menu = menu;
setStore({ name: "menu", content: state.menu });
},
SET_REFRESH_TOKEN: (state, refreshToken) => {
setRefreshToken(refreshToken)
setRefreshToken(refreshToken);
state.refreshToken = refreshToken;
setStore({name: 'refreshToken', content: state.refreshToken})
setStore({ name: "refreshToken", content: state.refreshToken });
},
SET_TENANT_ID: (state, tenantId) => {
state.tenantId = tenantId;
setStore({name: 'tenantId', content: state.tenantId})
setStore({ name: "tenantId", content: state.tenantId });
},
SET_USER_INFO: (state, userInfo) => {
if (validatenull(userInfo.avatar)) {
userInfo.avatar = "/img/bg/img-logo.png";
}
state.userInfo = userInfo;
setStore({name: 'userInfo', content: state.userInfo})
setStore({ name: "userInfo", content: state.userInfo });
},
SET_ROLES: (state, roles) => {
state.roles = roles;
@ -275,27 +348,26 @@ const user = {
let result = [];
function getCode(list) {
list.forEach(ele => {
if (typeof (ele) === 'object') {
list.forEach((ele) => {
if (typeof ele === "object") {
const chiildren = ele.children;
const code = ele.code;
if (chiildren) {
getCode(chiildren)
getCode(chiildren);
} else {
result.push(code);
}
}
})
});
}
getCode(permission);
state.permission = {};
result.forEach(ele => {
result.forEach((ele) => {
state.permission[ele] = true;
});
setStore({name: 'permission', content: state.permission})
}
}
}
export default user
setStore({ name: "permission", content: state.permission });
},
},
};
export default user;

@ -39,9 +39,9 @@ module.exports = {
proxy: {
"/api": {
//本地服务接口地址
target: "http://192.168.1.34:81", //测试环境
// target: "http://192.168.1.34:81", //测试环境
// target: "http://192.168.3.32:81", //李涛-wifi
// target: "http://192.168.1.102:81",
target: "http://192.168.1.102:81",
ws: true,
pathRewrite: {
"^/api": "/",

Loading…
Cancel
Save