From adf124ee70fe26420073963703b61123930c8e6f Mon Sep 17 00:00:00 2001 From: zzhuan <1260310633@qq.com> Date: Thu, 23 Apr 2026 11:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 10 ++++---- .env.production | 5 +++- src/api/loan/application.ts | 34 +++++++++++++++++---------- src/api/system/user.ts | 2 +- src/layout/components/Main/index.vue | 29 ++++------------------- src/utils/http/alova/index.ts | 13 +++------- src/views/loan/application/detail.vue | 17 +++++++++++++- src/views/loan/application/index.vue | 13 ++++++---- src/views/login/index.vue | 19 +++++++++++++-- 9 files changed, 81 insertions(+), 61 deletions(-) diff --git a/.env.development b/.env.development index 5ed83fa..5bde322 100644 --- a/.env.development +++ b/.env.development @@ -15,16 +15,16 @@ VITE_DROP_CONSOLE = true # 跨域代理,可以配置多个,请注意不要换行 #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 接口地址 -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 diff --git a/.env.production b/.env.production index f66d74d..12508c8 100644 --- a/.env.production +++ b/.env.production @@ -14,11 +14,14 @@ VITE_GLOB_API_URL = /fg-api 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_FILE_URL = https://fin-loan.mmlizi.com/fg-api + # 是否启用gzip压缩或brotli压缩 # 可选: gzip | brotli | none # 如果你需要多种形式,你可以用','来分隔 diff --git a/src/api/loan/application.ts b/src/api/loan/application.ts index a73b915..063820f 100644 --- a/src/api/loan/application.ts +++ b/src/api/loan/application.ts @@ -1,10 +1,11 @@ import { Alova } from '@/utils/http/alova/index'; import { ResultEnum } from '@/enums/httpEnum'; -import { PageEnum } from '@/enums/pageEnum'; import { ACCESS_TOKEN } from '@/store/mutation-types'; 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 { pageNum: number; @@ -59,7 +60,23 @@ export interface LoanApplicationPageRes { export function getLoanFileUrl(file?: LoanFileObj) { if (!file?.url) return ''; 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 { @@ -120,15 +137,8 @@ export async function handleLoanApplication(params: LoanApplicationHandleReq) { } 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(); - window.location.replace(redirectPath); + replaceToLogin(); } function getExportFileName(disposition: string | null) { @@ -149,7 +159,7 @@ function getExportFileName(disposition: string | null) { export async function exportLoanApplicationList(params: LoanApplicationQueryListReq) { const token = storage.get(ACCESS_TOKEN, ''); - const response = await fetch('/loan/application/export', { + const response = await fetch(getApiUrl('/loan/application/export'), { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/api/system/user.ts b/src/api/system/user.ts index 9720132..a9175c8 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -61,7 +61,7 @@ export function getUserInfo() { */ export function login(params: LoginParams) { return Alova.Post( - '/fg-api/user/login', + '/user/login', params, { meta: { diff --git a/src/layout/components/Main/index.vue b/src/layout/components/Main/index.vue index b378b3e..c6582c2 100644 --- a/src/layout/components/Main/index.vue +++ b/src/layout/components/Main/index.vue @@ -1,28 +1,17 @@ diff --git a/src/views/loan/application/index.vue b/src/views/loan/application/index.vue index c4067d0..b121d73 100644 --- a/src/views/loan/application/index.vue +++ b/src/views/loan/application/index.vue @@ -452,12 +452,15 @@ } 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({ - name: 'LoanApplicationDetail', - params: { - id: row.id, - }, + path: `/loan/application/${id}`, }); } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index c3ce8fe..a0ce8b0 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -59,7 +59,7 @@