Browse Source

feat: 登录联调

main
xuziqiang 6 months ago
parent
commit
a67f48c770
  1. 52
      hx-ai-intelligent/src/config/app.config.ts
  2. 3
      hx-ai-intelligent/vite.config.ts
  3. 4
      lib/saas/router/guard/permission-guard.ts
  4. 9
      lib/saas/view/system/login.vue
  5. 5
      lib/util/http/axios.ts

52
hx-ai-intelligent/src/config/app.config.ts

@ -1,9 +1,15 @@
/** @format */
import { dateUtil } from '/nerv-lib/util/date-util';
import mockResource from './resource.json';
import { http } from '/nerv-lib/saas';
import { ref } from 'vue';
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 = {
projectType: 'web',
baseApi: '/api',
@ -21,6 +27,25 @@ export const appConfig = {
// },
// 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: {
component: 'NsSelect',
componentProps: {
@ -42,22 +67,17 @@ export const appConfig = {
return { data: mockResource.menus };
},
userInfoApi: () => {
return {
code: 200,
success: true,
data: {
accountCode: '1305107806187376793',
accountName: 'adm*n',
accountType: 'admin',
accountStatus: 1,
accountRealName: 'admin',
organizationCode: 'dingcloud',
authConfigList: [],
organizeResCode: [],
leadDepartmentUuidList: [],
},
};
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
const info = res.data;
const trD = transform(info, {
accountCode: 'userId',
accountName: 'realName',
accountRealName: 'realName',
});
return { data: { ...trD } };
});
},
useHistoryTag: false,
// 修改密码配置
updatePassWordInfo: {

3
hx-ai-intelligent/vite.config.ts

@ -12,8 +12,9 @@ const proxy = {
changeOrigin: true,
},
'/carbon-smart': {
target: 'http://192.168.100.115:8224/api',
target: 'http://192.168.100.115:8224/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/carbon-smart/, ''),
},
};
export default configFun({ dirname, proxy, serviceMode: 'saas', baseDir: '../' });

4
lib/saas/router/guard/permission-guard.ts

@ -42,9 +42,7 @@ export function createPermissionGuard(router: Router, whiteNameList: string[]) {
if (!initUserInfo && Cookies.get('nervsid')) {
try {
const info = await appConfig.userInfo();
info.success
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
: '';
info.data ? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data)) : '';
} catch (err) {
Cookies.remove('nervsid');
}

9
lib/saas/view/system/login.vue

@ -55,6 +55,7 @@
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
import { Cookies } from '/nerv-lib/util/cookie';
import { storeToRefs } from 'pinia';
import { http } from '/nerv-lib/util';
export default defineComponent({
name: 'UserLogin',
setup() {
@ -93,12 +94,12 @@
async function logins() {
try {
const res = await configStore.userLogin(JSON.parse(data));
if (res.success) {
if (res.data?.userToken) {
Cookies.set('token', res.data?.userToken);
if (res.data?.token) {
if (res.data?.token) {
Cookies.set('nervsid', res.data?.token);
}
const info = await configStore.userInfo();
info.success
info.data
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data))
: '';
loading.value = false;

5
lib/util/http/axios.ts

@ -50,7 +50,7 @@ export class NSAxios {
}
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(
(res: AxiosResponse) => {
console.log('success', res);
// todo
const code = res?.data?.retcode;
return res;
},
(error: any) => {

Loading…
Cancel
Save