feat: 登录联调
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
import { dateUtil } from '/nerv-lib/util/date-util';
|
import { dateUtil } from '/nerv-lib/util/date-util';
|
||||||
import mockResource from './resource.json';
|
import mockResource from './resource.json';
|
||||||
|
import { http } from '/nerv-lib/saas';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
const value = ref('1');
|
const value = ref('1');
|
||||||
|
const transform = (data, map) => {
|
||||||
|
return Object.keys(map).reduce((pre, cur) => {
|
||||||
|
pre[cur] = data[map[cur]];
|
||||||
|
return pre;
|
||||||
|
}, {});
|
||||||
|
};
|
||||||
export const appConfig = {
|
export const appConfig = {
|
||||||
projectType: 'web',
|
projectType: 'web',
|
||||||
baseApi: '/api',
|
baseApi: '/api',
|
||||||
@@ -21,6 +27,25 @@ export const appConfig = {
|
|||||||
// },
|
// },
|
||||||
|
|
||||||
// customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),
|
// customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),
|
||||||
|
|
||||||
|
// userInfoApi: () => {
|
||||||
|
// return {
|
||||||
|
// code: 200,
|
||||||
|
// success: true,
|
||||||
|
// data: {
|
||||||
|
// accountCode: '1305107806187376793',
|
||||||
|
// accountName: 'adm*n',
|
||||||
|
// accountType: 'admin',
|
||||||
|
// accountStatus: 1,
|
||||||
|
// accountRealName: 'admin',
|
||||||
|
// organizationCode: 'dingcloud',
|
||||||
|
// authConfigList: [],
|
||||||
|
// organizeResCode: [],
|
||||||
|
// leadDepartmentUuidList: [],
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
// },
|
||||||
|
|
||||||
headerSlotConfig: {
|
headerSlotConfig: {
|
||||||
component: 'NsSelect',
|
component: 'NsSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
@@ -42,22 +67,17 @@ export const appConfig = {
|
|||||||
return { data: mockResource.menus };
|
return { data: mockResource.menus };
|
||||||
},
|
},
|
||||||
userInfoApi: () => {
|
userInfoApi: () => {
|
||||||
return {
|
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
|
||||||
code: 200,
|
const info = res.data;
|
||||||
success: true,
|
const trD = transform(info, {
|
||||||
data: {
|
accountCode: 'userId',
|
||||||
accountCode: '1305107806187376793',
|
accountName: 'realName',
|
||||||
accountName: 'adm*n',
|
accountRealName: 'realName',
|
||||||
accountType: 'admin',
|
});
|
||||||
accountStatus: 1,
|
return { data: { ...trD } };
|
||||||
accountRealName: 'admin',
|
});
|
||||||
organizationCode: 'dingcloud',
|
|
||||||
authConfigList: [],
|
|
||||||
organizeResCode: [],
|
|
||||||
leadDepartmentUuidList: [],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
useHistoryTag: false,
|
useHistoryTag: false,
|
||||||
// 修改密码配置
|
// 修改密码配置
|
||||||
updatePassWordInfo: {
|
updatePassWordInfo: {
|
||||||
|
@@ -12,8 +12,9 @@ const proxy = {
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/carbon-smart': {
|
'/carbon-smart': {
|
||||||
target: 'http://192.168.100.115:8224/api',
|
target: 'http://192.168.100.115:8224/',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/carbon-smart/, ''),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
export default configFun({ dirname, proxy, serviceMode: 'saas', baseDir: '../' });
|
export default configFun({ dirname, proxy, serviceMode: 'saas', baseDir: '../' });
|
||||||
|
@@ -42,9 +42,7 @@ export function createPermissionGuard(router: Router, whiteNameList: string[]) {
|
|||||||
if (!initUserInfo && Cookies.get('nervsid')) {
|
if (!initUserInfo && Cookies.get('nervsid')) {
|
||||||
try {
|
try {
|
||||||
const info = await appConfig.userInfo();
|
const info = await appConfig.userInfo();
|
||||||
info.success
|
info.data ? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data)) : '';
|
||||||
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
|
||||||
: '';
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Cookies.remove('nervsid');
|
Cookies.remove('nervsid');
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,7 @@
|
|||||||
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
|
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
|
||||||
import { Cookies } from '/nerv-lib/util/cookie';
|
import { Cookies } from '/nerv-lib/util/cookie';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { http } from '/nerv-lib/util';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'UserLogin',
|
name: 'UserLogin',
|
||||||
setup() {
|
setup() {
|
||||||
@@ -93,12 +94,12 @@
|
|||||||
async function logins() {
|
async function logins() {
|
||||||
try {
|
try {
|
||||||
const res = await configStore.userLogin(JSON.parse(data));
|
const res = await configStore.userLogin(JSON.parse(data));
|
||||||
if (res.success) {
|
if (res.data?.token) {
|
||||||
if (res.data?.userToken) {
|
if (res.data?.token) {
|
||||||
Cookies.set('token', res.data?.userToken);
|
Cookies.set('nervsid', res.data?.token);
|
||||||
}
|
}
|
||||||
const info = await configStore.userInfo();
|
const info = await configStore.userInfo();
|
||||||
info.success
|
info.data
|
||||||
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
|
||||||
: '';
|
: '';
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
@@ -50,7 +50,7 @@ export class NSAxios {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Cookies.get('nervsid')) {
|
if (Cookies.get('nervsid')) {
|
||||||
config.headers['x-token'] = Cookies.get('nervsid');
|
config.headers['token'] = Cookies.get('nervsid');
|
||||||
}
|
}
|
||||||
|
|
||||||
//暂时停用后端自己处理
|
//暂时停用后端自己处理
|
||||||
@@ -90,6 +90,9 @@ export class NSAxios {
|
|||||||
|
|
||||||
this.instance.interceptors.response.use(
|
this.instance.interceptors.response.use(
|
||||||
(res: AxiosResponse) => {
|
(res: AxiosResponse) => {
|
||||||
|
console.log('success', res);
|
||||||
|
// todo
|
||||||
|
const code = res?.data?.retcode;
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
|
Reference in New Issue
Block a user