feat: 重构报告模块中文件预览地址的获取逻辑,改用file字段信息拼接完整路径

master
2 days ago
parent 9fde6a92d5
commit 5f360a66dc

@ -26,3 +26,9 @@ VITE_API_TIMEOUT = 120000
# 代理前缀
VITE_APP_BASE_API = /api/v1
# Dify 知识库代理前缀
VITE_DIFY_API_BASE = /p30
# 文件服务代理前缀
VITE_STORAGE_API_BASE = /storage

@ -10,8 +10,8 @@ VITE_APP_TITLE = FastapiAdmin
VITE_API_URL = /
# 代理目标:本机后端(若出现 ENOTFOUND说明上面域名在当前网络/DNS 下不可解析,改用本地或可用地址)
# VITE_API_BASE_URL = http://127.0.0.1:8001
VITE_API_BASE_URL = http://192.168.5.5:8011
VITE_API_BASE_URL = http://192.168.5.37:8011
# VITE_API_BASE_URL = http://192.168.5.5:8011
# VITE_API_BASE_URL = https://service.fastapiadmin.com
# 是否删除控制台输出
@ -23,3 +23,6 @@ VITE_APP_WS_ENDPOINT = ws://127.0.0.1:8001
# Dify 知识库后端代理目标地址
VITE_DIFY_API_BASE_URL = https://p30-dify.ngsk.tech:7001/
# 文件服务后端代理目标地址
VITE_STORAGE_API_BASE_URL = http://192.168.5.119:9000/

@ -143,6 +143,8 @@ export interface ReviewTaskItem {
template_id?: number;
template_name?: string;
file_id: number;
/** 文件记录对象 */
file?: import("@/api/common/file").FileInfo;
/** 文档访问地址,可直接用于预览/下载 */
file_url?: string;
original_name?: string;

@ -0,0 +1,6 @@
export function getFileUrl(filePath: string) {
if (!filePath) {
return '';
}
return window.location.origin + "/storage/" + filePath;
}

@ -68,7 +68,7 @@
<DocPreviewDialog
v-model:visible="docPreviewVisible"
:title="task?.original_name || '审核文档'"
:file-url="task?.file_url"
:file-url="getFileUrl(task?.file?.bucket_name! + '/' + task?.file?.file_path! || '')"
/>
</ElDialog>
</template>
@ -78,6 +78,7 @@ import { ref } from "vue";
import { View } from "@element-plus/icons-vue";
import type { ReviewTaskItem } from "@/api/module_report/review";
import DocPreviewDialog from "./DocPreviewDialog.vue";
import { getFileUrl } from "@/utils/file";
defineOptions({ name: "TaskDetailDialog" });

@ -261,6 +261,7 @@ import ReviewFormDialog from "./components/ReviewFormDialog.vue";
import TaskDetailDialog from "./components/TaskDetailDialog.vue";
import DocPreviewDialog from "./components/DocPreviewDialog.vue";
import LogDrawer from "./components/LogDrawer.vue";
import { getFileUrl } from "@/utils/file";
defineOptions({ name: "EnergyReportReviewList" });
@ -430,7 +431,7 @@ function handleDetail(row: ReviewTaskItem) {
function handlePreviewDoc(row: ReviewTaskItem) {
if (!row.file_url) return;
currentPreviewFile.value = {
url: row.file_url,
url: getFileUrl(row?.file?.bucket_name! + '/' + row?.file?.file_path! || ''),
name: row.original_name || "审核文档",
};
docPreviewVisible.value = true;

@ -28,7 +28,7 @@
<div class="docx-panel" :class="{ 'docx-panel--full': mdPanelCollapsed }">
<FaDocxPreview
v-if="task?.file_url"
:src="task.file_url"
:src="getFileUrl(task?.file?.bucket_name! + '/' + task?.file?.file_path! || '')"
:readonly="true"
class="docx-preview"
/>
@ -149,6 +149,7 @@ import FaDocxPreview from "@/components/business/fa-docx-preview/index.vue";
import { ReviewTaskAPI } from "@/api/module_report/review";
import type { ReviewTaskItem } from "@/api/module_report/review";
import type { ReportType } from "@/api/module_report/report";
import { getFileUrl } from "@/utils/file";
defineOptions({ name: "ReviewResultPage" });

@ -192,6 +192,7 @@ import type {
import { RuleAPI } from "@/api/module_rule/rule";
import type { RuleItem } from "@/api/module_rule/rule";
import { extractPromptVariables } from "../promptVars";
import { getFileUrl } from "@/utils/file";
const route = useRoute();
const router = useRouter();
@ -249,7 +250,7 @@ async function loadTemplate() {
const data = resp?.data?.data;
if (data) {
template.value = data;
docxSrc.value = data.file_url || "";
docxSrc.value = getFileUrl(data.file?.bucket_name! + '/' + data.file?.file_path! || "");
}
} catch (e) {
template.value = null;

@ -276,6 +276,7 @@ import type {
import { RuleAPI } from "@/api/module_rule/rule";
import type { RuleItem } from "@/api/module_rule/rule";
import { extractPromptVariables } from "../promptVars";
import { getFileUrl } from "@/utils/file";
const route = useRoute();
const router = useRouter();
@ -379,7 +380,7 @@ async function loadTemplate() {
const data = resp?.data?.data;
if (data) {
template.value = data;
docxSrc.value = data.file_url || "";
docxSrc.value = getFileUrl(data.file?.bucket_name! + '/' + data.file?.file_path! || "");
}
} catch (e) {
template.value = null;

Loading…
Cancel
Save