Merge branch 'test' of https://codeup.aliyun.com/zsmarter/sac/server/smarterFramework into test
This commit is contained in:
commit
6b9f0bbf9c
@ -11,6 +11,7 @@ const getters = {
|
||||
introduction: state => state.user.introduction,
|
||||
roles: state => state.user.roles,
|
||||
permissions: state => state.user.permissions,
|
||||
applicationId: state => state.user.applicationId,
|
||||
permission_routes: state => state.permission.routes,
|
||||
topbarRouters:state => state.permission.topbarRouters,
|
||||
defaultRoutes:state => state.permission.defaultRoutes,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import { getApplicationId, setApplicationId, removeApplicationId } from '@/utils/application'
|
||||
|
||||
const user = {
|
||||
state: {
|
||||
@ -7,7 +8,9 @@ const user = {
|
||||
name: '',
|
||||
avatar: '',
|
||||
roles: [],
|
||||
permissions: []
|
||||
permissions: [],
|
||||
applicationId: getApplicationId(),
|
||||
applicationInfo: {}, // 用户选中的项目/应用
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@ -25,7 +28,12 @@ const user = {
|
||||
},
|
||||
SET_PERMISSIONS: (state, permissions) => {
|
||||
state.permissions = permissions
|
||||
}
|
||||
},
|
||||
SET_APPLICATION: (state, applicationInfo) => {
|
||||
const { id } = applicationInfo;
|
||||
state.applicationId = id;
|
||||
state.applicationInfo = applicationInfo;
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
@ -74,6 +82,8 @@ const user = {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
commit('SET_APPLICATION', {})
|
||||
removeApplicationId()
|
||||
removeToken()
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
@ -86,9 +96,17 @@ const user = {
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_APPLICATION', {})
|
||||
removeApplicationId()
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
|
||||
// 设置选中的项目应用信息
|
||||
SetApplication({ commit }, applicationInfo) {
|
||||
commit('SET_APPLICATION', applicationInfo)
|
||||
setApplicationId(applicationInfo?.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
sf-ui/src/utils/application.js
Normal file
30
sf-ui/src/utils/application.js
Normal file
@ -0,0 +1,30 @@
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const ApplicationKey = "Admin-Application-Id";
|
||||
|
||||
/**
|
||||
* 获取应用项目ID
|
||||
* 该函数从Cookie中检索与应用项目相关的关键信息。
|
||||
* @returns {string} 返回从Cookie中获取的应用项目ID。
|
||||
*/
|
||||
export function getApplicationId() {
|
||||
return Cookies.get(ApplicationKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置应用项目ID到Cookie中
|
||||
* @param {string} ApplicationId - 需要设置的应用项目ID。
|
||||
* @return {boolean|Object} 返回Cookie设置的结果。成功则返回true,失败则返回设置失败的对象。
|
||||
*/
|
||||
export function setApplicationId(ApplicationId) {
|
||||
return Cookies.set(ApplicationKey, ApplicationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除应用ID的Cookie
|
||||
* 本函数用于删除与应用相关的ID Cookie。
|
||||
* @returns {boolean} 返回删除操作的结果。如果删除成功,则返回true;如果删除失败,则返回false。
|
||||
*/
|
||||
export function removeApplicationId() {
|
||||
return Cookies.remove(ApplicationKey);
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
:size="100"
|
||||
/> -->
|
||||
<div class="content ml20">
|
||||
<div class="title">{{item.appName}}</div>
|
||||
<div class="card-title">{{item.appName}}</div>
|
||||
<div class="time">{{item.createTime}}</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -75,12 +75,13 @@ export default {
|
||||
flex-flow: column;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.title {
|
||||
.card-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #707070;
|
||||
}
|
||||
.time {
|
||||
font-size: 14px;
|
||||
|
@ -163,8 +163,7 @@ export default {
|
||||
// });
|
||||
// },
|
||||
async handleEnter(row) {
|
||||
// TODO
|
||||
// 此处需要储存项目id,供后续的网关服务、部署服务使用
|
||||
this.$store.dispatch('SetApplication', row);
|
||||
let routes = this.routes;
|
||||
if (this.routes.length === 0) {
|
||||
routes = await this.$store.dispatch('GenerateRoutes');
|
||||
|
Loading…
x
Reference in New Issue
Block a user