ref: 优化不同架构下前缀自适应

This commit is contained in:
lbw 2023-04-07 13:54:15 +08:00
parent 9f23e64034
commit 9cc34aa71b
12 changed files with 104 additions and 26 deletions

View File

@ -145,7 +145,7 @@ export const getUserInfo = () => {
export const logout = () => {
return request({
url: '/admin/token/logout',
url: '/auth/token/logout',
method: 'delete',
});
};

View File

@ -13,14 +13,13 @@
</template>
<script setup lang="ts" name="wngEditor">
import { ComponentInternalInstance } from 'vue';
import '@wangeditor/editor/dist/css/style.css';
import { reactive, shallowRef, watch, onBeforeUnmount } from 'vue';
// @ts-ignore
import { IDomEditor } from '@wangeditor/editor';
import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
import { Session } from '/@/utils/storage';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { proxy } = getCurrentInstance();
//
const props = defineProps({

View File

@ -59,7 +59,7 @@
<script setup lang="ts" name="upload-file">
import { useMessage } from '/@/hooks/message';
import { Local, Session } from '/@/utils/storage';
import { Session } from '/@/utils/storage';
import other from '/@/utils/other';
const props = defineProps({
modelValue: [String, Array],
@ -110,10 +110,9 @@ const uploadList = ref([]) as any;
const fileUpload = ref();
const headers = computed(() => {
const tenantId = Local.get('tenantId') ? Local.get('tenantId') : 1;
return {
Authorization: 'Bearer ' + Session.get('token'),
'TENANT-ID': tenantId,
'TENANT-ID': Session.getTenant(),
};
});

View File

@ -1,5 +1,5 @@
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import { Session, Local } from '/@/utils/storage';
import { Session } from '/@/utils/storage';
import { useMessageBox } from '/@/hooks/message';
import qs from 'qs';
import other from './other';
@ -36,7 +36,7 @@ service.interceptors.request.use(
}
// 统一增加TENANT-ID请求头
const tenantId = Local.get('tenantId');
const tenantId = Session.getTenant()
if (tenantId && !config.headers?.skipTenant) {
config.headers!['TENANT-ID'] = tenantId;
}

View File

@ -62,6 +62,7 @@ export const Session = {
clear() {
Cookies.remove('token');
Cookies.remove('refresh_token');
Cookies.remove('tenantId');
window.sessionStorage.clear();
},
// 获取当前存储的 token

42
src/views/ext/jimu.vue Normal file
View File

@ -0,0 +1,42 @@
<template>
<div class="layout-padding">
<el-scrollbar class="main">
<iframe :src="src" class="iframe" v-if="isMicro === 'true'" />
<span v-else>单体架构暂不支持报表设计器</span>
</el-scrollbar>
</div>
</template>
<script lang="ts" name="modelView" setup>
import other from '/@/utils/other';
import { Session } from '/@/utils/storage';
const { proxy } = getCurrentInstance();
const route = useRoute();
const src = ref('');
const isMicro = import.meta.env.VITE_IS_MICRO;
watch([route], () => {
init();
});
onMounted(() => {
init();
});
const init = () => {
const token = Session.getToken();
const tenantId = Session.getTenant();
let url = proxy.baseURL + `/jimu/jmreport/list?token=${tenantId}_${token}`;
src.value = other.adaptationUrl(url);
};
</script>
<style lang="scss" scoped>
.iframe {
width: 100%;
height: 80vh;
border: 0;
overflow: hidden;
box-sizing: border-box;
}
</style>

40
src/views/ext/report.vue Normal file
View File

@ -0,0 +1,40 @@
<template>
<div class="layout-padding">
<iframe :src="src" class="iframe" v-if="isMicro === 'true'" />
<span v-else>单体架构暂不支持大屏设计器</span>
</div>
</template>
<script lang="ts" name="modelView" setup>
import other from '/@/utils/other';
import { Session } from '/@/utils/storage';
const { proxy } = getCurrentInstance();
const route = useRoute();
const src = ref('');
const isMicro = import.meta.env.VITE_IS_MICRO;
watch([route], () => {
init();
});
onMounted(() => {
init();
});
const init = () => {
const token = Session.getToken();
const tenantId = Session.getTenant();
let url = `/gv?token=${token}&TENANT-ID=${tenantId}`;
src.value = proxy.baseURL + other.adaptationUrl(url);
};
</script>
<style lang="scss" scoped>
.iframe {
width: 100%;
height: 80vh;
border: 0;
overflow: hidden;
box-sizing: border-box;
}
</style>

View File

@ -21,6 +21,7 @@ import Driver from 'driver.js';
import { fetchList } from '/@/api/admin/tenant';
import { Local, Session } from '/@/utils/storage';
import { useI18n } from 'vue-i18n';
import Cookies from 'js-cookie';
const { t } = useI18n();
@ -69,6 +70,7 @@ const handleAutoTenant = () => {
const handleCommand = (tenant: any) => {
Session.set('tenantId', tenant.id); // session
Local.set('tenantId', tenant.id); // local
Cookies.set('tenantId', tenant.id); // cookie 便使
};
/**
@ -105,7 +107,7 @@ const guide = () => {
*/
onMounted(async () => {
await getTenantList(); //
tenant.value = Local.get('tenantId'); //
tenant.value = Session.getTenant(); //
if (autoTenantEnable) {
handleAutoTenant(); //

View File

@ -121,7 +121,7 @@ import { useMessage, useMessageBox } from '/@/hooks/message';
import { useI18n } from 'vue-i18n';
import commonFunction from '/@/utils/commonFunction';
import other from '/@/utils/other';
const { proxy } = getCurrentInstance();
const { copyText } = commonFunction();
//
const ImageUpload = defineAsyncComponent(() => import('/@/components/Upload/Image.vue'));
@ -188,8 +188,8 @@ const dialogFormVisible = ref(false);
const wxurl = ref('');
const access = (row: any) => {
dialogFormVisible.value = true;
let url = baseUrl + row.url + '/mp/' + row.appid + '/portal';
wxurl.value = other.adaptationUrl(url);
let url = '/mp/' + row.appid + '/portal';
wxurl.value = row.url + proxy.baseURL + other.adaptationUrl(url);
};
const generate = (row: any) => {

View File

@ -7,10 +7,9 @@
</template>
<script lang="ts" name="modelView" setup>
import { ComponentInternalInstance } from 'vue';
import other from '/@/utils/other';
import { Session } from '/@/utils/storage';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { proxy } = getCurrentInstance();
const route = useRoute();
const src = ref('');

View File

@ -75,7 +75,6 @@
</template>
<script lang="ts" name="model" setup>
import { ComponentInternalInstance } from 'vue';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { delObj, fetchList, status } from '/@/api/oa/process';
import { useMessage, useMessageBox } from '/@/hooks/message';
@ -85,7 +84,7 @@ import other from '/@/utils/other';
//
const { t } = useI18n();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { proxy } = getCurrentInstance();
//
const showPicDialog = ref(false);
@ -139,12 +138,10 @@ const handleDelete = async (ids: string[]) => {
//
const handleView = (row: any) => {
let url =
proxy.baseURL +
`/act/process/resource/${row.deploymentId}/${
row.processonDefinitionId
}/image?access_token=${Session.getToken()}&TENANT-ID=${Session.getTenant()}`;
actPicUrl.value = other.adaptationUrl(url);
let url = `/act/process/resource/${row.deploymentId}/${
row.processonDefinitionId
}/image?access_token=${Session.getToken()}&TENANT-ID=${Session.getTenant()}`;
actPicUrl.value = proxy.baseURL + other.adaptationUrl(url);
showPicDialog.value = true;
};

View File

@ -77,7 +77,6 @@
</template>
<script setup lang="ts" name="systemTask">
import { ComponentInternalInstance } from 'vue';
import { BasicTableProps, useTable } from '/@/hooks/table';
import { fetchList, delObj } from '/@/api/oa/task';
import { useI18n } from 'vue-i18n';
@ -88,8 +87,8 @@ import other from '/@/utils/other';
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const CommentDialog = defineAsyncComponent(() => import('./comment.vue'));
const { proxy } = getCurrentInstance();
const { t } = useI18n();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
//
const formDialogRef = ref();
@ -152,8 +151,8 @@ const handleDelete = async (ids: string[]) => {
//
const handleView = (row: any) => {
let url = proxy.baseURL + `/act/task/view/${row.taskId}?access_token=${Session.getToken()}&TENANT-ID=${Session.getTenant()}`;
actPicUrl.value = other.adaptationUrl(url);
let url = `/act/task/view/${row.taskId}?access_token=${Session.getToken()}&TENANT-ID=${Session.getTenant()}`;
actPicUrl.value = proxy.baseURL + other.adaptationUrl(url);
showPicDialog.value = true;
};
</script>