修复文件地址
This commit is contained in:
@@ -15,16 +15,16 @@ VITE_DROP_CONSOLE = true
|
|||||||
|
|
||||||
# 跨域代理,可以配置多个,请注意不要换行
|
# 跨域代理,可以配置多个,请注意不要换行
|
||||||
#VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]]
|
#VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]]
|
||||||
VITE_PROXY=[["/fg-api","https://fin-loan.mmlizi.com"]]
|
VITE_PROXY=[["/fg-api","https://fin-loan.mmlizi.com/fg-api"]]
|
||||||
|
|
||||||
# API 接口地址
|
# API 接口地址
|
||||||
VITE_GLOB_API_URL = /
|
VITE_GLOB_API_URL =
|
||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
#VITE_GLOB_API_URL_PREFIX = /fg-api
|
VITE_GLOB_API_URL_PREFIX = /fg-api
|
||||||
|
|
||||||
# 文件上传地址
|
# 文件上传地址
|
||||||
VITE_GLOB_UPLOAD_URL=
|
VITE_GLOB_UPLOAD_URL= https://fin-loan.mmlizi.com/fg-api
|
||||||
|
|
||||||
# 文件前缀地址
|
# 文件前缀地址
|
||||||
VITE_GLOB_FILE_URL=
|
VITE_GLOB_FILE_URL= https://fin-loan.mmlizi.com/fg-api
|
||||||
|
|||||||
@@ -14,11 +14,14 @@ VITE_GLOB_API_URL = /fg-api
|
|||||||
VITE_GLOB_API_URL_PREFIX =
|
VITE_GLOB_API_URL_PREFIX =
|
||||||
|
|
||||||
# 图片上传地址
|
# 图片上传地址
|
||||||
VITE_GLOB_UPLOAD_URL=
|
VITE_GLOB_UPLOAD_URL= https://fin-loan.mmlizi.com/fg-api
|
||||||
|
|
||||||
# 图片前缀地址
|
# 图片前缀地址
|
||||||
VITE_GLOB_IMG_URL=
|
VITE_GLOB_IMG_URL=
|
||||||
|
|
||||||
|
# 文件前缀地址
|
||||||
|
VITE_GLOB_FILE_URL = https://fin-loan.mmlizi.com/fg-api
|
||||||
|
|
||||||
# 是否启用gzip压缩或brotli压缩
|
# 是否启用gzip压缩或brotli压缩
|
||||||
# 可选: gzip | brotli | none
|
# 可选: gzip | brotli | none
|
||||||
# 如果你需要多种形式,你可以用','来分隔
|
# 如果你需要多种形式,你可以用','来分隔
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Alova } from '@/utils/http/alova/index';
|
import { Alova } from '@/utils/http/alova/index';
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum';
|
||||||
import { PageEnum } from '@/enums/pageEnum';
|
|
||||||
import { ACCESS_TOKEN } from '@/store/mutation-types';
|
import { ACCESS_TOKEN } from '@/store/mutation-types';
|
||||||
import { storage } from '@/utils/Storage';
|
import { storage } from '@/utils/Storage';
|
||||||
|
import { useGlobSetting } from '@/hooks/setting';
|
||||||
|
import { replaceToLogin } from '@/utils/loginRedirect';
|
||||||
|
|
||||||
const LOAN_FILE_HOST = 'http://192.168.1.26:7060';
|
const { fileUrl = '', apiUrl = '', urlPrefix = '' } = useGlobSetting();
|
||||||
|
|
||||||
export interface LoanApplicationQueryListReq {
|
export interface LoanApplicationQueryListReq {
|
||||||
pageNum: number;
|
pageNum: number;
|
||||||
@@ -59,7 +60,23 @@ export interface LoanApplicationPageRes {
|
|||||||
export function getLoanFileUrl(file?: LoanFileObj) {
|
export function getLoanFileUrl(file?: LoanFileObj) {
|
||||||
if (!file?.url) return '';
|
if (!file?.url) return '';
|
||||||
if (/^https?:\/\//i.test(file.url)) return file.url;
|
if (/^https?:\/\//i.test(file.url)) return file.url;
|
||||||
return `${LOAN_FILE_HOST}${file.url.startsWith('/') ? file.url : `/${file.url}`}`;
|
const fileHost = fileUrl.replace(/\/+$/, '');
|
||||||
|
return `${fileHost}${file.url.startsWith('/') ? file.url : `/${file.url}`}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function joinUrl(...parts: string[]) {
|
||||||
|
return parts
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((part, index) =>
|
||||||
|
index === 0 ? part.replace(/\/+$/, '') : part.replace(/^\/+|\/+$/g, '')
|
||||||
|
)
|
||||||
|
.join('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getApiUrl(path: string) {
|
||||||
|
const apiBase = joinUrl(apiUrl, urlPrefix);
|
||||||
|
if (!apiBase) return path;
|
||||||
|
return `${apiBase}${path.startsWith('/') ? path : `/${path}`}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FinResult<T> {
|
interface FinResult<T> {
|
||||||
@@ -120,15 +137,8 @@ export async function handleLoanApplication(params: LoanApplicationHandleReq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function redirectToLogin() {
|
function redirectToLogin() {
|
||||||
const { pathname, search, hash } = window.location;
|
|
||||||
const currentPath = `${pathname}${search}${hash}`;
|
|
||||||
const redirectPath =
|
|
||||||
pathname === PageEnum.BASE_LOGIN
|
|
||||||
? PageEnum.BASE_LOGIN
|
|
||||||
: `${PageEnum.BASE_LOGIN}?redirect=${encodeURIComponent(currentPath)}`;
|
|
||||||
|
|
||||||
storage.clear();
|
storage.clear();
|
||||||
window.location.replace(redirectPath);
|
replaceToLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExportFileName(disposition: string | null) {
|
function getExportFileName(disposition: string | null) {
|
||||||
@@ -149,7 +159,7 @@ function getExportFileName(disposition: string | null) {
|
|||||||
|
|
||||||
export async function exportLoanApplicationList(params: LoanApplicationQueryListReq) {
|
export async function exportLoanApplicationList(params: LoanApplicationQueryListReq) {
|
||||||
const token = storage.get(ACCESS_TOKEN, '');
|
const token = storage.get(ACCESS_TOKEN, '');
|
||||||
const response = await fetch('/loan/application/export', {
|
const response = await fetch(getApiUrl('/loan/application/export'), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export function getUserInfo() {
|
|||||||
*/
|
*/
|
||||||
export function login(params: LoginParams) {
|
export function login(params: LoginParams) {
|
||||||
return Alova.Post<LoginRes>(
|
return Alova.Post<LoginRes>(
|
||||||
'/fg-api/user/login',
|
'/user/login',
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
@@ -1,28 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<RouterView>
|
<RouterView>
|
||||||
<template #default="{ Component, route }">
|
<template #default="{ Component, route }">
|
||||||
<template v-if="mode === 'production'">
|
<keep-alive v-if="keepAliveComponents.length" :include="keepAliveComponents">
|
||||||
<transition :name="getTransitionName" mode="out-in" appear>
|
<component :is="Component" :key="route.fullPath" />
|
||||||
<keep-alive v-if="keepAliveComponents.length" :include="keepAliveComponents">
|
</keep-alive>
|
||||||
<component :is="Component" :key="route.fullPath" />
|
<component v-else :is="Component" :key="route.fullPath" />
|
||||||
</keep-alive>
|
|
||||||
<component v-else :is="Component" :key="route.fullPath" />
|
|
||||||
</transition>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<keep-alive v-if="keepAliveComponents.length" :include="keepAliveComponents">
|
|
||||||
<component :is="Component" :key="route.fullPath" />
|
|
||||||
</keep-alive>
|
|
||||||
<component v-else :is="Component" :key="route.fullPath" />
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</RouterView>
|
</RouterView>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { defineComponent, computed, unref } from 'vue';
|
import { defineComponent, computed } from 'vue';
|
||||||
import { useAsyncRouteStore } from '@/store/modules/asyncRoute';
|
import { useAsyncRouteStore } from '@/store/modules/asyncRoute';
|
||||||
import { useProjectSetting } from '@/hooks/setting/useProjectSetting';
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'MainView',
|
name: 'MainView',
|
||||||
@@ -38,20 +27,12 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const { isPageAnimate, pageAnimateType } = useProjectSetting();
|
|
||||||
const asyncRouteStore = useAsyncRouteStore();
|
const asyncRouteStore = useAsyncRouteStore();
|
||||||
// 需要缓存的路由组件
|
// 需要缓存的路由组件
|
||||||
const keepAliveComponents = computed(() => asyncRouteStore.keepAliveComponents);
|
const keepAliveComponents = computed(() => asyncRouteStore.keepAliveComponents);
|
||||||
|
|
||||||
const getTransitionName = computed(() => {
|
|
||||||
return unref(isPageAnimate) ? unref(pageAnimateType) : '';
|
|
||||||
});
|
|
||||||
|
|
||||||
const mode = import.meta.env.MODE;
|
|
||||||
return {
|
return {
|
||||||
keepAliveComponents,
|
keepAliveComponents,
|
||||||
getTransitionName,
|
|
||||||
mode,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import mocks from './mocks';
|
|||||||
import { useUser } from '@/store/modules/user';
|
import { useUser } from '@/store/modules/user';
|
||||||
import { storage } from '@/utils/Storage';
|
import { storage } from '@/utils/Storage';
|
||||||
import { useGlobSetting } from '@/hooks/setting';
|
import { useGlobSetting } from '@/hooks/setting';
|
||||||
import { PageEnum } from '@/enums/pageEnum';
|
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum';
|
||||||
import { isUrl } from '@/utils';
|
import { isUrl } from '@/utils';
|
||||||
|
import { replaceToLogin } from '@/utils/loginRedirect';
|
||||||
|
|
||||||
const { useMock, apiUrl, urlPrefix, loggerMock } = useGlobSetting();
|
const { useMock, apiUrl, urlPrefix, loggerMock } = useGlobSetting();
|
||||||
|
|
||||||
@@ -34,14 +34,8 @@ const mockAdapter = createAlovaMockAdapter([...mocks], {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function redirectToLogin() {
|
function redirectToLogin() {
|
||||||
const loginPath = PageEnum.BASE_LOGIN;
|
|
||||||
const { pathname, search, hash } = window.location;
|
|
||||||
const currentPath = `${pathname}${search}${hash}`;
|
|
||||||
const redirectPath =
|
|
||||||
pathname === loginPath ? loginPath : `${loginPath}?redirect=${encodeURIComponent(currentPath)}`;
|
|
||||||
|
|
||||||
storage.clear();
|
storage.clear();
|
||||||
window.location.replace(redirectPath);
|
replaceToLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Alova = createAlova({
|
export const Alova = createAlova({
|
||||||
@@ -122,7 +116,6 @@ export const Alova = createAlova({
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const Modal = window.$dialog;
|
const Modal = window.$dialog;
|
||||||
|
|
||||||
const LoginPath = PageEnum.BASE_LOGIN;
|
|
||||||
if (ResultEnum.SUCCESS === code) {
|
if (ResultEnum.SUCCESS === code) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -136,7 +129,7 @@ export const Alova = createAlova({
|
|||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
storage.clear();
|
storage.clear();
|
||||||
window.location.href = LoginPath;
|
replaceToLogin();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, nextTick, onMounted, ref } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { getLoanFileUrl } from '@/api/loan/application';
|
import { getLoanFileUrl } from '@/api/loan/application';
|
||||||
import type { LoanApplicationQueryListRes, LoanFileObj } from '@/api/loan/application';
|
import type { LoanApplicationQueryListRes, LoanFileObj } from '@/api/loan/application';
|
||||||
@@ -186,12 +186,27 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToTop() {
|
||||||
|
nextTick(() => {
|
||||||
|
window.scrollTo({ top: 0, left: 0 });
|
||||||
|
document.documentElement.scrollTop = 0;
|
||||||
|
document.body.scrollTop = 0;
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelectorAll<HTMLElement>('.layout-content, .main-view, .n-layout-scroll-container')
|
||||||
|
.forEach((element) => {
|
||||||
|
element.scrollTop = 0;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
router.push({ name: 'LoanApplication' });
|
router.push({ name: 'LoanApplication' });
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadDetail();
|
loadDetail();
|
||||||
|
scrollToTop();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -452,12 +452,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openDetail(row: LoanApplicationQueryListRes) {
|
function openDetail(row: LoanApplicationQueryListRes) {
|
||||||
sessionStorage.setItem(`${DETAIL_STORAGE_PREFIX}:${row.id}`, JSON.stringify(row));
|
if (!row.id) {
|
||||||
|
message.error('申请记录缺少ID,无法打开详情');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const id = String(row.id);
|
||||||
|
sessionStorage.setItem(`${DETAIL_STORAGE_PREFIX}:${id}`, JSON.stringify(row));
|
||||||
router.push({
|
router.push({
|
||||||
name: 'LoanApplicationDetail',
|
path: `/loan/application/${id}`,
|
||||||
params: {
|
|
||||||
id: row.id,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useUserStore } from '@/store/modules/user';
|
import { useUserStore } from '@/store/modules/user';
|
||||||
import { useMessage } from 'naive-ui';
|
import { useMessage } from 'naive-ui';
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum';
|
||||||
@@ -89,6 +89,21 @@
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
function getRedirectPath() {
|
||||||
|
const redirect = route.query.redirect;
|
||||||
|
const value = Array.isArray(redirect) ? redirect[0] : redirect;
|
||||||
|
if (!value || value.startsWith('http') || value.startsWith('//')) return PageEnum.BASE_HOME;
|
||||||
|
|
||||||
|
const hashIndex = value.indexOf('#');
|
||||||
|
if (hashIndex >= 0) {
|
||||||
|
const hashPath = value.slice(hashIndex + 1);
|
||||||
|
return hashPath.startsWith('/') ? hashPath : `/${hashPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.startsWith('/') ? value : PageEnum.BASE_HOME;
|
||||||
|
}
|
||||||
|
|
||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -108,7 +123,7 @@
|
|||||||
message.destroyAll();
|
message.destroyAll();
|
||||||
if (code == ResultEnum.SUCCESS) {
|
if (code == ResultEnum.SUCCESS) {
|
||||||
message.success('登录成功,即将进入系统');
|
message.success('登录成功,即将进入系统');
|
||||||
router.replace(PageEnum.BASE_HOME);
|
router.replace(getRedirectPath());
|
||||||
} else {
|
} else {
|
||||||
message.info(msg || '登录失败');
|
message.info(msg || '登录失败');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user