Browse Source

fix: 修改同项目登录信息污染

deploy-dev
xuziqiang 5 months ago
parent
commit
6137aaa4b6
  1. 4
      hx-ai-intelligent/src/App.vue
  2. 4
      hx-ai-intelligent/src/api/deviceManage.ts
  3. 2
      hx-ai-intelligent/src/config/app.config.ts
  4. 2
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  5. 2
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
  6. 75
      hx-ai-intelligent/src/view/equipmentManage/group/config.ts
  7. 98
      hx-ai-intelligent/src/view/equipmentManage/group/edit.vue
  8. 27
      hx-ai-intelligent/src/view/equipmentManage/group/index.vue
  9. 2
      hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue
  10. 2
      hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts
  11. 4
      hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue
  12. 1
      lib/component/drawer/drawer.vue
  13. 2
      lib/saas/config/router.config.ts
  14. 30
      lib/saas/router/guard/permission-guard.ts
  15. 2
      lib/saas/view/service/updatePassWord.vue
  16. 15
      lib/saas/view/system/layout/customHeader.vue
  17. 17
      lib/saas/view/system/layout/header.vue
  18. 9
      lib/saas/view/system/login.vue
  19. 6
      lib/util/http/axios.ts

4
hx-ai-intelligent/src/App.vue

@ -21,12 +21,12 @@
// watch( // watch(
// () => router.currentRoute.value, // () => router.currentRoute.value,
// (e) => { // (e) => {
// // if (Cookies.get('nervsid') === undefined && e.fullPath !== '/login') { // // if (Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`) === undefined && e.fullPath !== '/login') {
// // message.warn('!', 1); // // message.warn('!', 1);
// // router.push('/login'); // // router.push('/login');
// // } // // }
// // } else { // // } else {
// // if (Cookies.get('nervsid') !== undefined && e === '/login') { // // if (Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`) !== undefined && e === '/login') {
// // let url = window.sessionStorage.getItem('url'); // // let url = window.sessionStorage.getItem('url');
// // url === null ? window.sessionStorage.setItem('url', '/doorway/visitor/audit') : ''; // // url === null ? window.sessionStorage.setItem('url', '/doorway/visitor/audit') : '';
// // router.push(url === null ? '/doorway' : url); // // router.push(url === null ? '/doorway' : url);

4
hx-ai-intelligent/src/api/deviceManage.ts

@ -11,4 +11,8 @@ export enum group {
creatOrUpdate = `${BASE_URL}/deviceGroup/creatOrUpdate`, // 左侧树节点新增编辑 creatOrUpdate = `${BASE_URL}/deviceGroup/creatOrUpdate`, // 左侧树节点新增编辑
del = `${BASE_URL}/deviceGroup/del`, del = `${BASE_URL}/deviceGroup/del`,
move = `${BASE_URL}/deviceGroup/move`, move = `${BASE_URL}/deviceGroup/move`,
queryEditGroup = `${BASE_URL}/deviceGroup/queryEditGroup`, // 分组树
queryGroupPage = `${BASE_URL}/deviceGroup/queryGroupPage`, // 分组列表
saveGroupList = `${BASE_URL}/deviceGroup/saveGroupList`, // 分组保存
delGroupList = `${BASE_URL}/deviceGroup/delGroupList`, // 分组删除
} }

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

@ -71,7 +71,7 @@ export const appConfig = {
// 解决初始化登录select无初始值的问题 // 解决初始化登录select无初始值的问题
selectDefaultValue.value = finalId; selectDefaultValue.value = finalId;
const userInfo = JSON.parse(sessionStorage.getItem('userInfo')!); const userInfo = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)!);
const ownOrgInfo = userInfo.linkList?.filter(({ orgId: id }) => id === finalId)[0]; const ownOrgInfo = userInfo.linkList?.filter(({ orgId: id }) => id === finalId)[0];
return http.post('/carbon-smart/user/login/logInPermission', ownOrgInfo).then((res) => { return http.post('/carbon-smart/user/login/logInPermission', ownOrgInfo).then((res) => {

2
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue

@ -135,7 +135,7 @@ import { log } from 'node:console';
const casData = ref([]); const casData = ref([]);
const treeData = ref([]); const treeData = ref([]);
const userAuthList = ref([]); const userAuthList = ref([]);
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId; const orgId = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)).orgId;
const dynamicDisabled = computed(() => { const dynamicDisabled = computed(() => {
return formRef.value?.validateResult && userAuthList.value?.length; return formRef.value?.validateResult && userAuthList.value?.length;
}); });

2
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue

@ -104,7 +104,7 @@
name: 'EnergyConsumption', // name name: 'EnergyConsumption', // name
}); });
const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId; const orgId = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)).orgId;
const fetch = (api, params = { orgId }) => { const fetch = (api, params = { orgId }) => {
return http.post(api, params); return http.post(api, params);
}; };

75
hx-ai-intelligent/src/view/equipmentManage/group/config.ts

@ -4,10 +4,13 @@ import { http } from '/nerv-lib/util';
import { ref } from 'vue'; import { ref } from 'vue';
import { group } from '/@/api/deviceManage'; import { group } from '/@/api/deviceManage';
import { dict } from '/@/api'; import { dict } from '/@/api';
const tableKeyMap = [ import { origanizemanage } from '/@/api/origanizemanage';
const tableCalKeyMap = [
{ {
title: '来源企业', title: '来源企业',
dataIndex: 'id', dataIndex: 'orgName',
// textEllipsis: true,
// textNumber: 4,
}, },
{ {
title: '设备id', title: '设备id',
@ -32,20 +35,18 @@ const tableKeyMap = [
dataIndex: 'position', dataIndex: 'position',
}, },
]; ];
const tableCalKeyMap = [ const tableKeyMap = [
{ {
title: '来源企业', title: '来源企业',
dataIndex: 'id', dataIndex: 'orgName',
}, },
{ {
title: '节点编号', title: '节点编号',
dataIndex: 'deviceName', dataIndex: 'pointNum',
textNumber: 8,
textEllipsis: true,
}, },
{ {
title: '节点路径', title: '节点路径',
dataIndex: 'position', dataIndex: 'routeName',
}, },
]; ];
const doWnload = (url) => { const doWnload = (url) => {
@ -125,6 +126,26 @@ export const formSchema = [
], ],
}, },
]; ];
export const editTreeConfig = (orgId) => ({
selectedKeys: ['0-0'],
defaultExpandAll: true,
api: group.queryEditGroup,
params: { orgId },
resultField: 'data.orgInfos',
fieldNames: { title: 'orgName', key: 'orgId' },
formConfig: {
schemas: [
{
field: 'orgName',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入企业名称',
},
},
],
},
});
export const treeConfig = (orgId) => { export const treeConfig = (orgId) => {
return { return {
defaultExpandAll: true, defaultExpandAll: true,
@ -133,15 +154,8 @@ export const treeConfig = (orgId) => {
title: '能耗分组', title: '能耗分组',
}, },
params: { orgId }, params: { orgId },
showLine: { showLeafIcon: false },
api: group.queryDeviceGroupTree, api: group.queryDeviceGroupTree,
// api: () => {
// return new Promise((resolve) => {
// setTimeout(() => {
// resolve({ data: [{ title: '全部', key: 'all', children: data.data }] });
// }, 100);
// });
// },
transform: (data) => { transform: (data) => {
return [{ pointName: '全部', id: 'all', selectable: false, children: data }]; return [{ pointName: '全部', id: 'all', selectable: false, children: data }];
}, },
@ -176,12 +190,11 @@ export const treeConfig = (orgId) => {
}, },
}; };
}; };
export const tableConfig = (el, elGroup, elFormula) => { export const tableConfig = (el, elGroup, elFormula, defaultParams) => {
return { return {
title: '点位信息', title: '点位信息',
// api: '/carbon_emission/device/getDeviceList', api: group.queryGroupPage,
value: mockData.value, params: defaultParams.value,
headerActions: [ headerActions: [
{ {
label: '编辑', label: '编辑',
@ -193,7 +206,7 @@ export const tableConfig = (el, elGroup, elFormula) => {
}, },
{ {
label: '批量删除', label: '批量删除',
name: 'groupTemDownload', name: 'groupBatDelete',
type: 'primary', type: 'primary',
dynamicDisabled: (data: any) => { dynamicDisabled: (data: any) => {
return data.list.length === 0; return data.list.length === 0;
@ -244,7 +257,7 @@ export const tableConfig = (el, elGroup, elFormula) => {
{ {
label: '批量分组', label: '批量分组',
name: 'groupTemDownload', name: 'groupBatGroup',
type: 'primary', type: 'primary',
handle: () => { handle: () => {
elGroup.value.toggle(); elGroup.value.toggle();
@ -252,7 +265,7 @@ export const tableConfig = (el, elGroup, elFormula) => {
}, },
{ {
label: '公式编辑', label: '公式编辑',
name: 'groupTemDownload', name: 'groupFormulaEdit',
type: 'primary', type: 'primary',
handle: () => { handle: () => {
elFormula.value.toggle(); elFormula.value.toggle();
@ -265,7 +278,7 @@ export const tableConfig = (el, elGroup, elFormula) => {
actions: [ actions: [
{ {
label: '删除', label: '删除',
name: 'FeedBackDetail', name: 'groupDelete',
dynamicParams: ['uuid', 'appealType'], dynamicParams: ['uuid', 'appealType'],
confirm: true, confirm: true,
handle: () => { handle: () => {
@ -341,11 +354,13 @@ export const tableConfig = (el, elGroup, elFormula) => {
}; };
}; };
export const tableConfigCal = (el, elGroup, elFormula) => { export const tableConfigCal = (el, elGroup, elFormula, defaultParams) => {
// 分组节点
return { return {
title: '点位信息', title: '点位信息',
// api: '/carbon_emission/device/getDeviceList', // api: '/carbon_emission/device/getDeviceList',
value: mockData.value, value: mockData.value,
params: defaultParams,
headerActions: [ headerActions: [
{ {
@ -413,12 +428,12 @@ export const tableConfigCal = (el, elGroup, elFormula) => {
actions: [ actions: [
{ {
label: '删除', label: '删除',
name: 'FeedBackDetail', name: 'groupDelete',
dynamicParams: ['uuid', 'appealType'], dynamicParams: 'id',
confirm: true, confirm: true,
handle: () => { isReload: true,
mockData.value.splice(0, 1); isClearCheck: true,
}, api: group.delGroupList,
}, },
], ],
}, },

98
hx-ai-intelligent/src/view/equipmentManage/group/edit.vue

@ -1,53 +1,72 @@
<template> <template>
<ns-drawer <ns-drawer
v-model:visible="visible" v-model:visible="visible"
size="large" :width="800"
class="custom-class" class="custom-class"
title="编辑" title=" "
destroyOnClose
:ok="btnClick" :ok="btnClick"
:cancel="() => (visible = false)" :cancel="() => (visible = false)"
placement="right"> placement="right">
<div class="drawerContainer"> <div class="drawerContainer">
<ns-tree-api v-bind="treeConfig" @select="treeSelect" /> <ns-tree-api v-bind="config" @select="treeSelect" />
<a-transfer <a-transfer
v-model:target-keys="targetKeys" v-model:target-keys="targetKeys"
:data-source="mockData" :data-source="dataSource"
style="height: 100%; width: 66%" style="height: 100%; width: 66%"
oneWay
:listStyle="listStyle" :listStyle="listStyle"
show-search show-search
:render="(item) => item.title"
:filter-option="filterOption" :filter-option="filterOption"
:render="(item) => item.title" /> @change="handleChange" />
</div> </div>
</ns-drawer> </ns-drawer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import { treeConfig } from './config'; import { editTreeConfig } from './config';
import { group } from '/@/api/deviceManage';
const visible = ref(false); import { http } from '/nerv-lib/util/http';
const mockData = ref([]); const props = defineProps({ params: Object });
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
const config = computed(() => {
return editTreeConfig(result);
});
const visible = ref(true);
const dataSource = ref([]);
const listStyle = { const listStyle = {
height: '100%', height: '100%',
width: '100%', width: '100%',
}; };
const targetKeys = ref<string[]>([]); const targetKeys = ref([]);
const currentId = ref('');
const toggle = () => { const toggle = () => {
visible.value = !visible.value; visible.value = !visible.value;
}; };
const handleChange = (nextTargetKeys: string[], direction: string, moveKeys: string[]) => {
console.log('targetKeys: ', nextTargetKeys);
console.log('direction: ', direction);
console.log('moveKeys: ', moveKeys);
};
onMounted(() => { const filterOption = (inputValue: string, option: any) => {
getMock('上海公司'); return option?.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
});
const filterOption = (inputValue: string, option: MockData) => {
return option.description.indexOf(inputValue) > -1;
}; };
const btnClick = () => { const btnClick = () => {
visible.value = false; // visible.value = false;
NsMessage.success('编辑成功');
http
.post(group.saveGroupList, {
...props.params,
saveOrgId: currentId.value,
saveGroupIds: targetKeys.value,
})
.then(() => {
NsMessage.success('操作成功');
});
}; };
function treeSelect( function treeSelect(
selectedKeys: never[], selectedKeys: never[],
@ -62,26 +81,27 @@
const { const {
dataRef: { title }, dataRef: { title },
} = e.node; } = e.node;
currentId.value = selectedKeys[0];
getMock(title); getData(currentId.value);
} }
const getMock = (company) => { const getData = (id) => {
const keys = []; http
const mData = []; .post(group.queryEditGroup, {
for (let i = 0; i < 60; i++) { orgId: result,
const data = { queryOrgId: id,
key: i.toString(), ...props.params,
title: `A00${i + 1}总用电量(${company})`, // energyType: props.params.energyType,
description: `description of content${i + 1}`, })
chosen: Math.random() * 2 > 1, .then((res) => {
}; dataSource.value = res.data.groups?.map((item) => {
if (data.chosen) { item['title'] = item.pointName;
keys.push(data.key); item['key'] = item.id.toString();
} return item;
mData.push(data); });
} targetKeys.value = res.data.linkGroups.map((item) => {
mockData.value = mData; return item.id;
targetKeys.value = keys; });
});
}; };
defineExpose({ defineExpose({
toggle, toggle,

27
hx-ai-intelligent/src/view/equipmentManage/group/index.vue

@ -1,5 +1,5 @@
<template> <template>
<editDrawer ref="editDrawerRef" /> <editDrawer ref="editDrawerRef" :params="defaultParams" />
<editGroup ref="editGroupRef" /> <editGroup ref="editGroupRef" />
<editFormula ref="editFormulaRef" /> <editFormula ref="editFormulaRef" />
@ -34,8 +34,8 @@
</template> </template>
</ns-tree-api> </ns-tree-api>
</div> </div>
<ns-view-list-table v-show="defaultType" class="table" v-bind="config" /> <ns-view-list-table v-if="defaultType" class="table" v-bind="config" ref="tableRef" />
<ns-view-list-table v-show="!defaultType" class="table" v-bind="configCal" /> <ns-view-list-table v-else class="table" v-bind="configCal" ref="tableCalRef" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -53,14 +53,18 @@
type opType = 'up' | 'down'; type opType = 'up' | 'down';
const { getParams } = useParams(); const { getParams } = useParams();
const modalFormRef = ref(); const modalFormRef = ref();
const tableRef = ref();
const tableCalRef = ref();
const editDrawerRef = ref(); const editDrawerRef = ref();
const editGroupRef = ref(); const editGroupRef = ref();
const editFormulaRef = ref(); const editFormulaRef = ref();
const treeRef = ref(); const treeRef = ref();
const defaultType = ref(true); const defaultType = ref(true);
const result = JSON.parse(sessionStorage.getItem('ORGID')!); const result = JSON.parse(sessionStorage.getItem('ORGID')!);
const config = tableConfig(editDrawerRef, editGroupRef, editFormulaRef); const defaultParams = ref({ orgId: result, energyType: '用电量', id: 19 });
const configCal = tableConfigCal(editDrawerRef, editGroupRef, editFormulaRef);
const config = tableConfig(editDrawerRef, editGroupRef, editFormulaRef, defaultParams);
const configCal = tableConfigCal(editDrawerRef, editGroupRef, editFormulaRef, defaultParams);
const tConfig = treeConfig(result); const tConfig = treeConfig(result);
const nsModalFormConfig = ref({ const nsModalFormConfig = ref({
api: group.creatOrUpdate, api: group.creatOrUpdate,
@ -150,8 +154,17 @@
{ title: '下移', key: 'moveDown', func: (data) => moveNode(data, 'down') }, { title: '下移', key: 'moveDown', func: (data) => moveNode(data, 'down') },
{ title: '删除', key: 'deleteNode', func: (data) => deleteNode(data) }, { title: '删除', key: 'deleteNode', func: (data) => deleteNode(data) },
]; ];
const handleSelect = () => { const handleSelect = (key, record) => {
defaultType.value = !defaultType.value; console.log(record);
const {
node: { pointType, id, energyType },
} = record;
defaultParams.value.energyType = energyType;
defaultParams.value.id = id;
defaultType.value = pointType === '分组节点';
defaultType.value
? tableRef.value?.nsTableRef.reload()
: tableCalRef.value?.nsTableRef.reload();
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

2
hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue

@ -194,7 +194,7 @@
const selectRoleRef = ref(); const selectRoleRef = ref();
const formSchema = formConfig(disabled as any); const formSchema = formConfig(disabled as any);
const formSchema2 = formConfig2(roleDisabled as any); const formSchema2 = formConfig2(roleDisabled as any);
const { orgName, projectId, orgId } = JSON.parse(sessionStorage.getItem('userInfo')); const { orgName, projectId, orgId } = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH));
// const orgId = JSON.parse(sessionStorage.getItem('ORGID')); // const orgId = JSON.parse(sessionStorage.getItem('ORGID'));
const roleTreeData = ref([]); const roleTreeData = ref([]);
const rolePermissionTreeData = ref([]); const rolePermissionTreeData = ref([]);

2
hx-ai-intelligent/src/view/organizationManage/usermanage/config.ts

@ -89,7 +89,7 @@ export const formConfig = (disabled) => {
label: '组织关系', label: '组织关系',
field: 'orgName', field: 'orgName',
component: 'NsInput', component: 'NsInput',
defaultValue: JSON.parse(sessionStorage.getItem('userInfo')).orgName, defaultValue: JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)).orgName,
componentProps: { componentProps: {
disabled: true, disabled: true,
maxLength: 30, maxLength: 30,

4
hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue

@ -104,7 +104,7 @@
const treeDataDept = ref([]); const treeDataDept = ref([]);
const treeData2 = ref([]); const treeData2 = ref([]);
const userAuthList = ref([]); const userAuthList = ref([]);
// const orgId = JSON.parse(sessionStorage.getItem('userInfo')).orgId; // const orgId = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)).orgId;
const orgId = JSON.parse(sessionStorage.getItem('ORGID')!); const orgId = JSON.parse(sessionStorage.getItem('ORGID')!);
const orgTreeConfig = ref({ const orgTreeConfig = ref({
selectedKeys: ['0-0'], selectedKeys: ['0-0'],
@ -291,7 +291,7 @@
setTimeout(() => { setTimeout(() => {
formData.value = { formData.value = {
sex: '男', sex: '男',
orgName: JSON.parse(sessionStorage.getItem('userInfo')).orgName, orgName: JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)).orgName,
}; };
userAuthList.value.splice(0); userAuthList.value.splice(0);
}); });

1
lib/component/drawer/drawer.vue

@ -32,6 +32,7 @@
getContainer: (triggerNode: any) => triggerNode.parentNode, getContainer: (triggerNode: any) => triggerNode.parentNode,
...attrs, ...attrs,
...props, ...props,
footerStyle: { textAlign: 'right' },
})); }));
return { getBindValue }; return { getBindValue };
}, },

2
lib/saas/config/router.config.ts

@ -4,7 +4,7 @@ export const routerConfig = {
router: router, router: router,
login: 'login', login: 'login',
logout: () => { logout: () => {
Cookies.remove('nervsid'); Cookies.remove(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
Cookies.remove('token'); Cookies.remove('token');
sessionStorage.clear(); sessionStorage.clear();
router.push('/login'); router.push('/login');

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

@ -4,6 +4,9 @@ import { authorizationService } from '/nerv-base/store/modules/authorization-ser
import { appConfigStore } from '/nerv-base/store/modules/app-config'; import { appConfigStore } from '/nerv-base/store/modules/app-config';
import { Cookies } from '/nerv-lib/util/cookie'; import { Cookies } from '/nerv-lib/util/cookie';
import { setRouteChange } from '/nerv-lib/util/routeChange'; import { setRouteChange } from '/nerv-lib/util/routeChange';
console.log(import.meta.env.VITE_PUBLIC_PATH);
export function createPermissionGuard(router: Router, whiteNameList: string[]) { export function createPermissionGuard(router: Router, whiteNameList: string[]) {
const authorizationStore = authorizationService(); const authorizationStore = authorizationService();
const appConfig = appConfigStore(); const appConfig = appConfigStore();
@ -11,23 +14,26 @@ export function createPermissionGuard(router: Router, whiteNameList: string[]) {
if (!appConfig.userCustomRouterGuard) { if (!appConfig.userCustomRouterGuard) {
setRouteChange(to); setRouteChange(to);
if (to?.query?.nervsid) { if (to?.query?.nervsid) {
if (to?.query?.nervsid !== Cookies.get('nervsid')) { if (to?.query?.nervsid !== Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`)) {
Cookies.set('nervsid', to?.query?.nervsid); Cookies.set(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`, to?.query?.nervsid);
try { try {
const info = await appConfig.userInfo(); const info = await appConfig.userInfo();
await authorizationStore.initUserResource(); await authorizationStore.initUserResource();
authorizationStore.initMenuResource(); authorizationStore.initMenuResource();
appConfig.setUserInfo(info.data); appConfig.setUserInfo(info.data);
info.success info.success
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data)) ? window.sessionStorage.setItem(
import.meta.env.VITE_PUBLIC_PATH,
JSON.stringify(info.data),
)
: ''; : '';
} catch (err) { } catch (err) {
Cookies.remove('nervsid'); Cookies.remove(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
} }
} }
} }
if ( if (
!Cookies.get('nervsid') && !Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`) &&
to.fullPath !== '/login' && to.fullPath !== '/login' &&
to.name && to.name &&
!whiteNameList.includes(to.name as string) !whiteNameList.includes(to.name as string)
@ -36,15 +42,19 @@ export function createPermissionGuard(router: Router, whiteNameList: string[]) {
next({ name: 'login' }); next({ name: 'login' });
} else { } else {
// 存储用户信息 // 存储用户信息
if (to.fullPath !== '/login') { if (to.fullPath !== '/login') {
const initUserInfo = window.sessionStorage['userInfo']; const initUserInfo = window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH];
if (!initUserInfo && Cookies.get('nervsid')) { if (!initUserInfo && Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`)) {
try { try {
const info = await appConfig.userInfo(); const info = await appConfig.userInfo();
info.data ? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data)) : ''; info.data
? window.sessionStorage.setItem(
import.meta.env.VITE_PUBLIC_PATH,
JSON.stringify(info.data),
)
: '';
} catch (err) { } catch (err) {
Cookies.remove('nervsid'); Cookies.remove(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
} }
} else { } else {
if (initUserInfo) { if (initUserInfo) {

2
lib/saas/view/service/updatePassWord.vue

@ -168,7 +168,7 @@
const res = await http.post(configStore.updatePassWordInfo?.api, data); const res = await http.post(configStore.updatePassWordInfo?.api, data);
if (res.success) { if (res.success) {
NsMessage.success('修改成功,需重新登陆', 1, () => { NsMessage.success('修改成功,需重新登陆', 1, () => {
Cookies.remove('nervsid'); Cookies.remove(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
sessionStorage.clear(); sessionStorage.clear();
router.push('/login'); router.push('/login');
authorizationStore.clearAuthorization(); authorizationStore.clearAuthorization();

15
lib/saas/view/system/layout/customHeader.vue

@ -197,7 +197,7 @@
}); });
const toCustomUrl = (val: string) => { const toCustomUrl = (val: string) => {
window.open(`${val}?nervsid=${Cookies.get('nervsid')}`); window.open(`${val}?nervsid=${Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`)}`);
}; };
const messageCount = computed(() => { const messageCount = computed(() => {
return messagecountStore.getCount; return messagecountStore.getCount;
@ -267,12 +267,15 @@
const { getProjectName: projectName } = storeToRefs(authorizationStore); const { getProjectName: projectName } = storeToRefs(authorizationStore);
const { getEnterpriseName: enterpriseName } = storeToRefs(authorizationStore); const { getEnterpriseName: enterpriseName } = storeToRefs(authorizationStore);
const initUserInfo = window.sessionStorage['userInfo']; const initUserInfo = window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH];
if (!authorizationStore.getProjectName && Cookies.get('projectName')) { if (!authorizationStore.getProjectName && Cookies.get('projectName')) {
authorizationStore.setProjectName(Cookies.get('projectName')); authorizationStore.setProjectName(Cookies.get('projectName'));
} }
if (!authorizationStore.getEnterpriseName && window.sessionStorage['userInfo']) { if (
const userInfo = JSON.parse(window.sessionStorage['userInfo']); !authorizationStore.getEnterpriseName &&
window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH]
) {
const userInfo = JSON.parse(window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH]);
authorizationStore.setEnterpriseName( authorizationStore.setEnterpriseName(
!userInfo.organizationalName ? '' : userInfo.organizationalName, !userInfo.organizationalName ? '' : userInfo.organizationalName,
); );
@ -351,7 +354,7 @@
if (configStore.dropOut) { if (configStore.dropOut) {
configStore.dropOut(Cookies, router, useTags, authorizationStore, http); configStore.dropOut(Cookies, router, useTags, authorizationStore, http);
} else { } else {
Cookies.remove('nervsid'); Cookies.remove(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
sessionStorage.clear(); sessionStorage.clear();
router.push('/login'); router.push('/login');
useTags().clearTags(); useTags().clearTags();
@ -392,7 +395,7 @@
]; ];
const backDoor = () => { const backDoor = () => {
let protocol = window.location.protocol; let protocol = window.location.protocol;
const nervsid = Cookies.get('nervsid'); const nervsid = Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
http.get('/portalurl.json').then((res) => { http.get('/portalurl.json').then((res) => {
if (nervsid) { if (nervsid) {
window.location.href = `${protocol}//${res.url}report?nervsid=${nervsid}`; window.location.href = `${protocol}//${res.url}report?nervsid=${nervsid}`;

17
lib/saas/view/system/layout/header.vue

@ -187,8 +187,8 @@
// const messageCount = ref(); // const messageCount = ref();
const time = ref(); const time = ref();
const toCustomUrl = (val: string) => { const toCustomUrl = (val: string) => {
window.open(`${val}?nervsid=${Cookies.get('nervsid')}`); window.open(`${val}?nervsid=${Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`)}`);
// window.location.href = `${val}?nervsid=${Cookies.get('nervsid')}`; // window.location.href = `${val}?nervsid=${Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`)}`;
}; };
const messageCount = computed(() => { const messageCount = computed(() => {
return messagecountStore.getCount; return messagecountStore.getCount;
@ -217,12 +217,15 @@
const userName = ref<string>('-'); const userName = ref<string>('-');
const authorizationStore = authorizationService(); const authorizationStore = authorizationService();
const initUserInfo = window.sessionStorage['userInfo']; const initUserInfo = window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH];
if (!authorizationStore.getProjectName && Cookies.get('projectName')) { if (!authorizationStore.getProjectName && Cookies.get('projectName')) {
authorizationStore.setProjectName(Cookies.get('projectName')); authorizationStore.setProjectName(Cookies.get('projectName'));
} }
if (!authorizationStore.getEnterpriseName && window.sessionStorage['userInfo']) { if (
const userInfo = JSON.parse(window.sessionStorage['userInfo']); !authorizationStore.getEnterpriseName &&
window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH]
) {
const userInfo = JSON.parse(window.sessionStorage[import.meta.env.VITE_PUBLIC_PATH]);
authorizationStore.setEnterpriseName( authorizationStore.setEnterpriseName(
!userInfo.organizationalName ? '' : userInfo.organizationalName, !userInfo.organizationalName ? '' : userInfo.organizationalName,
); );
@ -314,7 +317,7 @@
if (configStore.dropOut) { if (configStore.dropOut) {
configStore.dropOut(Cookies, router, useTags, authorizationStore, http); configStore.dropOut(Cookies, router, useTags, authorizationStore, http);
} else { } else {
Cookies.remove('nervsid'); Cookies.remove(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
sessionStorage.clear(); sessionStorage.clear();
router.push('/login'); router.push('/login');
useTags().clearTags(); useTags().clearTags();
@ -353,7 +356,7 @@
]; ];
const backDoor = () => { const backDoor = () => {
let protocol = window.location.protocol; let protocol = window.location.protocol;
const nervsid = Cookies.get('nervsid'); const nervsid = Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
http.get('/portalurl.json').then((res) => { http.get('/portalurl.json').then((res) => {
if (nervsid) { if (nervsid) {
window.location.href = `${protocol}//${res.url}report?nervsid=${nervsid}`; window.location.href = `${protocol}//${res.url}report?nervsid=${nervsid}`;

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

@ -140,11 +140,14 @@
verifyRef.value?.reload(); verifyRef.value?.reload();
if (res.data?.token) { if (res.data?.token) {
if (res.data?.token) { if (res.data?.token) {
Cookies.set('nervsid', res.data?.token); Cookies.set(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`, res.data?.token);
} }
const info = await configStore.userInfo(); const info = await configStore.userInfo();
info.data info.data
? window.sessionStorage.setItem('userInfo', JSON.stringify(info.data)) ? window.sessionStorage.setItem(
import.meta.env.VITE_PUBLIC_PATH,
JSON.stringify(info.data),
)
: ''; : '';
loading.value = false; loading.value = false;
if (configStore.enablePermissions) { if (configStore.enablePermissions) {
@ -264,7 +267,7 @@
}, },
mounted() { mounted() {
// if (Cookies.get('nervsid') !== undefined) { // if (Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`) !== undefined) {
// this.$router.push('/home'); // this.$router.push('/home');
// } // }
}, },

6
lib/util/http/axios.ts

@ -43,14 +43,14 @@ export class NSAxios {
private interceptors(): void { private interceptors(): void {
this.instance.interceptors.request.use((config: AxiosRequestConfig) => { this.instance.interceptors.request.use((config: AxiosRequestConfig) => {
// config.headers.token = Cookies.get('nervsid'); // config.headers.token = Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
// config.withCredentials = true; // config.withCredentials = true;
if (!config.headers) { if (!config.headers) {
config.headers = {}; config.headers = {};
} }
if (Cookies.get('nervsid')) { if (Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`)) {
config.headers['token'] = Cookies.get('nervsid'); config.headers['token'] = Cookies.get(`${import.meta.env.VITE_PUBLIC_PATH}-nervsid`);
} }
//暂时停用后端自己处理 //暂时停用后端自己处理

Loading…
Cancel
Save