fix(测试跟踪): 图片预览失效

--bug=1017976 --user=陈建星 【测试跟踪】测试用例-添加附件-上传本地文件-预览提示加载失败 https://www.tapd.cn/55049933/s/1261722
--bug=1017976 --user=陈建星 【测试跟踪】测试用例-添加附件-上传本地文件-预览提示加载失败 https://www.tapd.cn/55049933/s/1261970
This commit is contained in:
chenjianxing 2022-10-14 17:46:25 +08:00 committed by jianxing
parent 8cc8729699
commit e3b264e5f1
5 changed files with 15 additions and 5 deletions

View File

@ -18,7 +18,7 @@ import java.util.Optional;
public class SessionFilter implements WebFilter { public class SessionFilter implements WebFilter {
// 所有模块的前缀 // 所有模块的前缀
private static final String[] PREFIX = new String[]{"/setting", "/project", "/api", "/performance", "/track", "/workstation", "/ui", "/report"}; private static final String[] PREFIX = new String[]{"/setting", "/project", "/api", "/performance", "/track", "/workstation", "/ui", "/report"};
private static final String[] TO_SUB_SERVICE = new String[]{"/license", "/system"}; private static final String[] TO_SUB_SERVICE = new String[]{"/license", "/system", "/resource"};
private static final String PERFORMANCE_DOWNLOAD_PREFIX = "/jmeter/"; private static final String PERFORMANCE_DOWNLOAD_PREFIX = "/jmeter/";
private static final String API_DOWNLOAD_PREFIX = "/api/jmeter/"; private static final String API_DOWNLOAD_PREFIX = "/api/jmeter/";

View File

@ -268,6 +268,14 @@ export const generateShareUrl = (name, shareUrl) => {
} }
} }
export const generateModuleUrl = (url) => {
if (window.__POWERED_BY_QIANKUN__) {
return window.location.origin + '/' + packageJSON.name + url;
} else {
return window.location.origin + url;
}
}
export default { export default {
install(Vue) { install(Vue) {
Vue.prototype.$get = get; Vue.prototype.$get = get;

View File

@ -17,6 +17,7 @@ public class ShiroUtils {
filterChainDefinitionMap.put("/resource/md/get/**", "anon"); filterChainDefinitionMap.put("/resource/md/get/**", "anon");
filterChainDefinitionMap.put("/resource/ui/get/**", "anon"); filterChainDefinitionMap.put("/resource/ui/get/**", "anon");
filterChainDefinitionMap.put("/attachment/preview/**", "anon");
filterChainDefinitionMap.put("/*.worker.js", "anon"); filterChainDefinitionMap.put("/*.worker.js", "anon");
filterChainDefinitionMap.put("/signin", "anon"); filterChainDefinitionMap.put("/signin", "anon");
filterChainDefinitionMap.put("/ldap/signin", "anon"); filterChainDefinitionMap.put("/ldap/signin", "anon");
@ -90,8 +91,6 @@ public class ShiroUtils {
public static void ignoreCsrfFilter(Map<String, String> filterChainDefinitionMap) { public static void ignoreCsrfFilter(Map<String, String> filterChainDefinitionMap) {
filterChainDefinitionMap.put("/", "apikey, authc"); // 跳转到 / 不用校验 csrf filterChainDefinitionMap.put("/", "apikey, authc"); // 跳转到 / 不用校验 csrf
filterChainDefinitionMap.put("/language", "apikey, authc");// 跳转到 /language 不用校验 csrf filterChainDefinitionMap.put("/language", "apikey, authc");// 跳转到 /language 不用校验 csrf
filterChainDefinitionMap.put("/test/case/file/preview/**", "apikey, authc"); // 预览测试用例附件 不用校验 csrf
filterChainDefinitionMap.put("/attachment/preview/**", "apikey, authc"); // 预览缺陷及测试用例附件 不用校验 csrf
filterChainDefinitionMap.put("/mock", "apikey, authc"); // 跳转到 /mock接口 不用校验 csrf filterChainDefinitionMap.put("/mock", "apikey, authc"); // 跳转到 /mock接口 不用校验 csrf
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<el-dialog :visible.sync="dialogVisible" width="80%" :destroy-on-close="true" :before-close="close" :append-to-body="true"> <el-dialog :visible.sync="dialogVisible" width="80%" :destroy-on-close="true" :before-close="close" :append-to-body="true">
<div> <div>
<img :src="'/attachment/preview/' + file.id + '/' + file.isLocal" :alt="$t('test_track.case.img_loading_fail')" style="width: 100%;height: 100%;" <img :src="url" :alt="$t('test_track.case.img_loading_fail')" style="width: 100%;height: 100%;"
v-if="file.type === 'JPG' || file.type === 'JPEG' || file.type === 'PNG'"> v-if="file.type === 'JPG' || file.type === 'JPEG' || file.type === 'PNG'">
<div v-if="file.type === 'PDF'"> <div v-if="file.type === 'PDF'">
<test-case-pdf :file-id="file.id"/> <test-case-pdf :file-id="file.id"/>
@ -13,6 +13,7 @@
<script> <script>
import TestCasePdf from "@/business/case/components/TestCasePdf"; import TestCasePdf from "@/business/case/components/TestCasePdf";
import {generateModuleUrl} from "@/business/utils/sdk-utils";
export default { export default {
name: "TestCaseFiles", name: "TestCaseFiles",
@ -25,12 +26,14 @@ export default {
type: '' type: ''
}, },
dialogVisible: false, dialogVisible: false,
url: ''
} }
}, },
methods: { methods: {
open(file) { open(file) {
this.file = file; this.file = file;
this.dialogVisible = true; this.dialogVisible = true;
this.url = generateModuleUrl('/attachment/preview/' + this.file.id + '/' + this.file.isLocal);
}, },
close() { close() {
this.file = { this.file = {

View File

@ -2,7 +2,7 @@ export {operationConfirm, removeGoBackListener, handleCtrlSEvent, byteToSize, ge
export {parseCustomFilesForList, getCustomFieldFilter, buildBatchParam} from "metersphere-frontend/src/utils/tableUtils"; export {parseCustomFilesForList, getCustomFieldFilter, buildBatchParam} from "metersphere-frontend/src/utils/tableUtils";
export {getCurrentProjectID, getCurrentWorkspaceId, getCurrentUser} from "metersphere-frontend/src/utils/token"; export {getCurrentProjectID, getCurrentWorkspaceId, getCurrentUser} from "metersphere-frontend/src/utils/token";
export {hasLicense, hasPermissions, hasPermission} from "metersphere-frontend/src/utils/permission"; export {hasLicense, hasPermissions, hasPermission} from "metersphere-frontend/src/utils/permission";
export {get, post, downloadFile, fileDownloadGet, fileDownloadPost, fileUpload} from "metersphere-frontend/src/plugins/request"; export {get, post, downloadFile, fileDownloadGet, fileDownloadPost, fileUpload, generateShareUrl, generateModuleUrl} from "metersphere-frontend/src/plugins/request";
export {CURRENT_LANGUAGE} from "metersphere-frontend/src/utils/constants"; export {CURRENT_LANGUAGE} from "metersphere-frontend/src/utils/constants";