From 78c84cf61b2a7f558582673a3eecdf8b91eb24c3 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期五, 17 四月 2026 16:48:26 +0800
Subject: [PATCH] 测试完成
---
src/views/knowledge/education/compilequer/index.vue | 143 ++++++++++++++++++++++++++++++++---------------
1 files changed, 97 insertions(+), 46 deletions(-)
diff --git a/src/views/knowledge/education/compilequer/index.vue b/src/views/knowledge/education/compilequer/index.vue
index 7a7e4c9..ef4061c 100644
--- a/src/views/knowledge/education/compilequer/index.vue
+++ b/src/views/knowledge/education/compilequer/index.vue
@@ -357,59 +357,77 @@
// 缂栬緫鍣ㄦā寮�
mode: "default",
-fileList:[],
+ fileList: [],
// 宸ュ叿鏍忛厤缃�
toolbarConfig: {
- excludeKeys: [
- "group-video",
- "insertVideo",
- "uploadVideo",
- "emotion",
- "codeBlock",
- ],
+ excludeKeys: ["emotion", "codeBlock"],
},
- // 缂栬緫鍣ㄩ厤缃�
editorConfig: {
- placeholder: "璇疯緭鍏ュ鏁欏唴瀹�...",
+ placeholder: "璇疯緭鍏ュ唴瀹�...",
MENU_CONF: {
+ // 鍥剧墖涓婁紶閰嶇疆
uploadImage: {
server: process.env.VUE_APP_BASE_API + "/common/uploadSort",
fieldName: "file",
- maxFileSize: 2 * 1024 * 1024,
- maxNumberOfFiles: 1,
- allowedFileTypes: ["image/*"],
headers: {
Authorization: "Bearer " + getToken(),
},
- customUpload: async (file, insertFn) => {
- try {
- const formData = new FormData();
- formData.append("file", file);
-
- const response = await axios.post(
- process.env.VUE_APP_BASE_API + "/common/uploadSort",
- formData,
- {
- headers: {
- // "Content-Type": "multipart/form-data",
- Authorization: "Bearer " + getToken(),
- },
- }
+ // 鑷畾涔夋彃鍏ュ浘鐗�
+ customInsert: (res, insertFn) => {
+ const url = res.url || res.data || res.filePath;
+ if (url) {
+ // 澶勭悊鍐呯綉鍦板潃杞崲
+ const processedUrl = url.replace(
+ "http://192.168.191.181:8095/profile/upload",
+ "http://m.zjtongde.com:13871/prod-api/profile/upload"
);
-
- if (response.data && response.data.url) {
- let imgUrl = response.data.url;
- imgUrl = imgUrl.replace(
- "http://218.108.11.22:8093/profile-api/upload",
- "http://192.168.191.181:8095/profile/upload"
- );
- insertFn(imgUrl);
- }
- } catch (error) {
- console.error("鍥剧墖涓婁紶澶辫触", error);
- this.$message.error("鍥剧墖涓婁紶澶辫触");
+ insertFn(processedUrl);
}
+ },
+ // 涓婁紶鎴愬姛鍥炶皟
+ onSuccess: (file, res) => {
+ console.log("鍥剧墖涓婁紶鎴愬姛", res);
+ return res.url || res.data || res.filePath;
+ },
+ onFailed: (file, res) => {
+ this.$message.error("鍥剧墖涓婁紶澶辫触");
+ console.error("鍥剧墖涓婁紶澶辫触", res);
+ },
+ },
+
+ // 瑙嗛涓婁紶閰嶇疆
+ uploadVideo: {
+ server: process.env.VUE_APP_BASE_API + "/common/uploadSort",
+ fieldName: "file",
+ maxFileSize: 50 * 1024 * 1024, // 50MB
+ allowedFileTypes: ["video/*"],
+ headers: {
+ Authorization: "Bearer " + getToken(),
+ },
+ // 鑷畾涔夋彃鍏ヨ棰�
+ customInsert: (res, insertFn) => {
+ const url = res.url || res.data || res.filePath;
+ if (url) {
+ // 澶勭悊鍐呯綉鍦板潃杞崲
+ const processedUrl = url.replace(
+ "http://192.168.191.181:8095/profile/upload",
+ "http://m.zjtongde.com:13871/prod-api/profile/upload"
+ );
+ insertFn(processedUrl, "瑙嗛");
+ }
+ },
+ onSuccess: (file, res) => {
+ console.log("瑙嗛涓婁紶鎴愬姛", res);
+ return res.url || res.data || res.filePath;
+ },
+ onFailed: (file, res) => {
+ this.$message.error("瑙嗛涓婁紶澶辫触");
+ console.error("瑙嗛涓婁紶澶辫触", res);
+ },
+ onError: (file, err, res) => {
+ this.$message.error("瑙嗛涓婁紶鍑洪敊");
+ console.error("瑙嗛涓婁紶鍑洪敊", err);
},
},
},
@@ -480,11 +498,13 @@
options: [],
optionstag: [],
// 鍐呯綉鐨勯儴鍒嗭紙鏂囦欢锛�
- oldPattern: "http://192.168.191.181:8095/profile/upload",
+ // oldPattern: "http://192.168.191.181:8095/profile/upload",
+ oldPattern: "http://192.88.117.236:8090/prod-api/profile/upload",
// 鍐呯綉鐨勯儴鍒嗭紙鏂囦欢锛�
- oldPatternhtml: "/http:\/\/192\.168\.191\.181:8095\/profile\/upload\//g",
+ oldPatternhtml: "/http:\/\/192\.88\.117\.236:8095\/profile\/upload\//g",
// 澶栫綉閮ㄥ垎锛堟枃浠讹級
- newPattern: "http://218.108.11.22:8093/profile-api/upload",
+ // newPattern: "http://218.108.11.22:8093/profile-api/upload",銆併�佹柊鍗�
+ newPattern: "http://m.zjtongde.com:13871/prod-api/profile/upload",
xjxsoptions: [
{
@@ -630,7 +650,7 @@
// ------------------
// let html =
- // '<p>娴嬭瘯</p><video class="ql-video" controls="controls" controlslist="nofullscreen" type="video/mp4" style="object-fit:fill;width: 100%;" preload="auto" playsinline="true" x-webkit-airplay="allow" x5-video-orientation="portraint" x5-playsinline="true" x5-video-player-fullscreen="true" src="http://192.168.191.181:8095/profile/upload/vadio/钀ュ吇娉典粙缁�.mp4"></video><p>娴嬭瘯111</p><video class="ql-video" controls="controls" controlslist="nofullscreen" type="video/mp4" style="object-fit:fill;width: 100%;" preload="auto" playsinline="true" x-webkit-airplay="allow" x5-video-orientation="portraint" x5-playsinline="true" x5-video-player-fullscreen="true" src="http://192.168.191.181:8095/profile/upload/vadio/娉ㄥ皠鍣ㄦ帹娉�.mp4"></video><p><br></p>';
+ // '<p>娴嬭瘯</p><video class="ql-video" controls="controls" controlslist="nofullscreen" type="video/mp4" style="object-fit:fill;width: 100%;" preload="auto" playsinline="true" x-webkit-airplay="allow" x5-video-orientation="portraint" x5-playsinline="true" x5-video-player-fullscreen="true" src="http://192.88.117.236:8090/prod-api/profile/upload/vadio/钀ュ吇娉典粙缁�.mp4"></video><p>娴嬭瘯111</p><video class="ql-video" controls="controls" controlslist="nofullscreen" type="video/mp4" style="object-fit:fill;width: 100%;" preload="auto" playsinline="true" x-webkit-airplay="allow" x5-video-orientation="portraint" x5-playsinline="true" x5-video-player-fullscreen="true" src="http://192.88.117.236:8090/prod-api/profile/upload/vadio/娉ㄥ皠鍣ㄦ帹娉�.mp4"></video><p><br></p>';
// // html = html.parserdom(this.oldPattern, this.newPattern);
// html = this.parserdom(html);
// console.log(html, "html");
@@ -645,17 +665,42 @@
var doc = parser.parseFromString(html, "text/html");
// 瀹氫箟瑕佹浛鎹㈢殑鏂版棫URL
- var oldUrlBase = "http://192.168.191.181:8095/profile/upload";
- var newUrlBase = "http://218.108.11.22:8093/profile-api/upload";
+ var oldUrlBase = this.oldPattern;
+ // var newUrlBase = "http://218.108.11.22:8093/profile-api/upload";
+ var newUrlBase = this.newPattern;
// 鑾峰彇鎵�鏈夌殑video鍏冪礌
var videos = doc.querySelectorAll("video");
+ var images = doc.querySelectorAll("img");
+ console.log(videos, "videos");
+ console.log(images, "images");
// 閬嶅巻鎵�鏈夌殑video鍏冪礌骞舵浛鎹rc灞炴��
videos.forEach(function (video) {
+ // 鍏堟鏌ideo鍏冪礌鑷韩鐨剆rc灞炴��
var src = video.getAttribute("src");
- if (src.startsWith(oldUrlBase)) {
+ if (src && src.startsWith(oldUrlBase)) {
video.setAttribute("src", src.replace(oldUrlBase, newUrlBase));
+ }
+
+ // 鐒跺悗妫�鏌ideo鍏冪礌鍐呴儴鐨剆ource瀛愬厓绱�
+ var sources = video.querySelectorAll("source");
+ sources.forEach(function (source) {
+ var sourceSrc = source.getAttribute("src");
+ if (sourceSrc && sourceSrc.startsWith(oldUrlBase)) {
+ source.setAttribute(
+ "src",
+ sourceSrc.replace(oldUrlBase, newUrlBase)
+ );
+ }
+ });
+ });
+ console.log(images, "images");
+
+ images.forEach(function (img) {
+ var src = img.getAttribute("src");
+ if (src.startsWith(oldUrlBase)) {
+ img.setAttribute("src", src.replace(oldUrlBase, newUrlBase));
}
});
@@ -684,7 +729,13 @@
content: this.parserdom(this.content),
fileName: this.generateRandomHtmlFilename(),
}).then((res) => {
+ console.log(55);
+
this.ruleForm.richText = res.msg;
+ this.ruleForm.richText = res.msg.replace(
+ this.oldPattern,
+ this.newPattern
+ );
console.log(this.ruleForm.richText, "this.ruleForm.richText");
// 澶勭悊鍐呯綉html
addrichText({
--
Gitblit v1.9.3