Przeglądaj źródła

调试代码预览

tanshanming 8 miesięcy temu
rodzic
commit
7561d29097

+ 279 - 18
package-lock.json

@@ -14,6 +14,12 @@
 				"@ant-design/icons-vue": "6.1.0",
 				"@antv/g2plot": "2.4.28",
 				"@chenfengyuan/vue-qrcode": "2.0.0",
+				"@codemirror/lang-css": "^6.3.1",
+				"@codemirror/lang-html": "^6.4.9",
+				"@codemirror/lang-javascript": "^6.2.4",
+				"@codemirror/lang-json": "^6.0.2",
+				"@codemirror/lang-xml": "^6.1.0",
+				"@codemirror/theme-one-dark": "^6.1.3",
 				"@highlightjs/vue-plugin": "2.1.0",
 				"@tinymce/tinymce-vue": "5.0.0",
 				"@vue-office/docx": "^1.2.0",
@@ -21,7 +27,6 @@
 				"@vue-office/pdf": "1.2.0",
 				"ant-design-vue": "3.2.14",
 				"axios": "1.1.3",
-				"codemirror-editor-vue3": "^2.8.0",
 				"cropperjs": "1.5.12",
 				"dayjs": "1.11.7",
 				"echarts": "5.4.0",
@@ -49,6 +54,7 @@
 				"tinymce": "^6.2.0",
 				"video.js": "^8.23.3",
 				"vue": "3.2.44",
+				"vue-codemirror": "^6.1.1",
 				"vue-cropper": "1.0.5",
 				"vue-demi": "0.13.11",
 				"vue-i18n": "9.2.2",
@@ -988,6 +994,156 @@
 				"vue": "^3.0.0"
 			}
 		},
+		"node_modules/@codemirror/autocomplete": {
+			"version": "6.18.6",
+			"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.18.6.tgz",
+			"integrity": "sha512-PHHBXFomUs5DF+9tCOM/UoW6XQ4R44lLNNhRaW9PKPTU0D7lIjRg3ElxaJnTwsl/oHiR93WSXDBrekhoUGCPtg==",
+			"dependencies": {
+				"@codemirror/language": "^6.0.0",
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.17.0",
+				"@lezer/common": "^1.0.0"
+			}
+		},
+		"node_modules/@codemirror/commands": {
+			"version": "6.8.1",
+			"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.8.1.tgz",
+			"integrity": "sha512-KlGVYufHMQzxbdQONiLyGQDUW0itrLZwq3CcY7xpv9ZLRHqzkBSoteocBHtMCoY7/Ci4xhzSrToIeLg7FxHuaw==",
+			"dependencies": {
+				"@codemirror/language": "^6.0.0",
+				"@codemirror/state": "^6.4.0",
+				"@codemirror/view": "^6.27.0",
+				"@lezer/common": "^1.1.0"
+			}
+		},
+		"node_modules/@codemirror/lang-css": {
+			"version": "6.3.1",
+			"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",
+			"integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",
+			"dependencies": {
+				"@codemirror/autocomplete": "^6.0.0",
+				"@codemirror/language": "^6.0.0",
+				"@codemirror/state": "^6.0.0",
+				"@lezer/common": "^1.0.2",
+				"@lezer/css": "^1.1.7"
+			}
+		},
+		"node_modules/@codemirror/lang-html": {
+			"version": "6.4.9",
+			"resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.9.tgz",
+			"integrity": "sha512-aQv37pIMSlueybId/2PVSP6NPnmurFDVmZwzc7jszd2KAF8qd4VBbvNYPXWQq90WIARjsdVkPbw29pszmHws3Q==",
+			"dependencies": {
+				"@codemirror/autocomplete": "^6.0.0",
+				"@codemirror/lang-css": "^6.0.0",
+				"@codemirror/lang-javascript": "^6.0.0",
+				"@codemirror/language": "^6.4.0",
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.17.0",
+				"@lezer/common": "^1.0.0",
+				"@lezer/css": "^1.1.0",
+				"@lezer/html": "^1.3.0"
+			}
+		},
+		"node_modules/@codemirror/lang-javascript": {
+			"version": "6.2.4",
+			"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.4.tgz",
+			"integrity": "sha512-0WVmhp1QOqZ4Rt6GlVGwKJN3KW7Xh4H2q8ZZNGZaP6lRdxXJzmjm4FqvmOojVj6khWJHIb9sp7U/72W7xQgqAA==",
+			"dependencies": {
+				"@codemirror/autocomplete": "^6.0.0",
+				"@codemirror/language": "^6.6.0",
+				"@codemirror/lint": "^6.0.0",
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.17.0",
+				"@lezer/common": "^1.0.0",
+				"@lezer/javascript": "^1.0.0"
+			}
+		},
+		"node_modules/@codemirror/lang-json": {
+			"version": "6.0.2",
+			"resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz",
+			"integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==",
+			"dependencies": {
+				"@codemirror/language": "^6.0.0",
+				"@lezer/json": "^1.0.0"
+			}
+		},
+		"node_modules/@codemirror/lang-xml": {
+			"version": "6.1.0",
+			"resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.1.0.tgz",
+			"integrity": "sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==",
+			"dependencies": {
+				"@codemirror/autocomplete": "^6.0.0",
+				"@codemirror/language": "^6.4.0",
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.0.0",
+				"@lezer/common": "^1.0.0",
+				"@lezer/xml": "^1.0.0"
+			}
+		},
+		"node_modules/@codemirror/language": {
+			"version": "6.11.1",
+			"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.11.1.tgz",
+			"integrity": "sha512-5kS1U7emOGV84vxC+ruBty5sUgcD0te6dyupyRVG2zaSjhTDM73LhVKUtVwiqSe6QwmEoA4SCiU8AKPFyumAWQ==",
+			"dependencies": {
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.23.0",
+				"@lezer/common": "^1.1.0",
+				"@lezer/highlight": "^1.0.0",
+				"@lezer/lr": "^1.0.0",
+				"style-mod": "^4.0.0"
+			}
+		},
+		"node_modules/@codemirror/lint": {
+			"version": "6.8.5",
+			"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.8.5.tgz",
+			"integrity": "sha512-s3n3KisH7dx3vsoeGMxsbRAgKe4O1vbrnKBClm99PU0fWxmxsx5rR2PfqQgIt+2MMJBHbiJ5rfIdLYfB9NNvsA==",
+			"dependencies": {
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.35.0",
+				"crelt": "^1.0.5"
+			}
+		},
+		"node_modules/@codemirror/search": {
+			"version": "6.5.11",
+			"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.11.tgz",
+			"integrity": "sha512-KmWepDE6jUdL6n8cAAqIpRmLPBZ5ZKnicE8oGU/s3QrAVID+0VhLFrzUucVKHG5035/BSykhExDL/Xm7dHthiA==",
+			"peer": true,
+			"dependencies": {
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.0.0",
+				"crelt": "^1.0.5"
+			}
+		},
+		"node_modules/@codemirror/state": {
+			"version": "6.5.2",
+			"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.2.tgz",
+			"integrity": "sha512-FVqsPqtPWKVVL3dPSxy8wEF/ymIEuVzF1PK3VbUgrxXpJUSHQWWZz4JMToquRxnkw+36LTamCZG2iua2Ptq0fA==",
+			"dependencies": {
+				"@marijn/find-cluster-break": "^1.0.0"
+			}
+		},
+		"node_modules/@codemirror/theme-one-dark": {
+			"version": "6.1.3",
+			"resolved": "https://registry.npmjs.org/@codemirror/theme-one-dark/-/theme-one-dark-6.1.3.tgz",
+			"integrity": "sha512-NzBdIvEJmx6fjeremiGp3t/okrLPYT0d9orIc7AFun8oZcRk58aejkqhv6spnz4MLAevrKNPMQYXEWMg4s+sKA==",
+			"dependencies": {
+				"@codemirror/language": "^6.0.0",
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.0.0",
+				"@lezer/highlight": "^1.0.0"
+			}
+		},
+		"node_modules/@codemirror/view": {
+			"version": "6.37.2",
+			"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.37.2.tgz",
+			"integrity": "sha512-XD3LdgQpxQs5jhOOZ2HRVT+Rj59O4Suc7g2ULvZ+Yi8eCkickrkZ5JFuoDhs2ST1mNI5zSsNYgR3NGa4OUrbnw==",
+			"dependencies": {
+				"@codemirror/state": "^6.5.0",
+				"crelt": "^1.0.6",
+				"style-mod": "^4.1.0",
+				"w3c-keyname": "^2.2.4"
+			}
+		},
 		"node_modules/@ctrl/tinycolor": {
 			"version": "3.6.1",
 			"resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz",
@@ -1641,6 +1797,77 @@
 				"@jridgewell/sourcemap-codec": "^1.4.14"
 			}
 		},
+		"node_modules/@lezer/common": {
+			"version": "1.2.3",
+			"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.2.3.tgz",
+			"integrity": "sha512-w7ojc8ejBqr2REPsWxJjrMFsA/ysDCFICn8zEOR9mrqzOu2amhITYuLD8ag6XZf0CFXDrhKqw7+tW8cX66NaDA=="
+		},
+		"node_modules/@lezer/css": {
+			"version": "1.2.1",
+			"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.2.1.tgz",
+			"integrity": "sha512-2F5tOqzKEKbCUNraIXc0f6HKeyKlmMWJnBB0i4XW6dJgssrZO/YlZ2pY5xgyqDleqqhiNJ3dQhbrV2aClZQMvg==",
+			"dependencies": {
+				"@lezer/common": "^1.2.0",
+				"@lezer/highlight": "^1.0.0",
+				"@lezer/lr": "^1.3.0"
+			}
+		},
+		"node_modules/@lezer/highlight": {
+			"version": "1.2.1",
+			"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.1.tgz",
+			"integrity": "sha512-Z5duk4RN/3zuVO7Jq0pGLJ3qynpxUVsh7IbUbGj88+uV2ApSAn6kWg2au3iJb+0Zi7kKtqffIESgNcRXWZWmSA==",
+			"dependencies": {
+				"@lezer/common": "^1.0.0"
+			}
+		},
+		"node_modules/@lezer/html": {
+			"version": "1.3.10",
+			"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.10.tgz",
+			"integrity": "sha512-dqpT8nISx/p9Do3AchvYGV3qYc4/rKr3IBZxlHmpIKam56P47RSHkSF5f13Vu9hebS1jM0HmtJIwLbWz1VIY6w==",
+			"dependencies": {
+				"@lezer/common": "^1.2.0",
+				"@lezer/highlight": "^1.0.0",
+				"@lezer/lr": "^1.0.0"
+			}
+		},
+		"node_modules/@lezer/javascript": {
+			"version": "1.5.1",
+			"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.1.tgz",
+			"integrity": "sha512-ATOImjeVJuvgm3JQ/bpo2Tmv55HSScE2MTPnKRMRIPx2cLhHGyX2VnqpHhtIV1tVzIjZDbcWQm+NCTF40ggZVw==",
+			"dependencies": {
+				"@lezer/common": "^1.2.0",
+				"@lezer/highlight": "^1.1.3",
+				"@lezer/lr": "^1.3.0"
+			}
+		},
+		"node_modules/@lezer/json": {
+			"version": "1.0.3",
+			"resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz",
+			"integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==",
+			"dependencies": {
+				"@lezer/common": "^1.2.0",
+				"@lezer/highlight": "^1.0.0",
+				"@lezer/lr": "^1.0.0"
+			}
+		},
+		"node_modules/@lezer/lr": {
+			"version": "1.4.2",
+			"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.2.tgz",
+			"integrity": "sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA==",
+			"dependencies": {
+				"@lezer/common": "^1.0.0"
+			}
+		},
+		"node_modules/@lezer/xml": {
+			"version": "1.0.6",
+			"resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.6.tgz",
+			"integrity": "sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==",
+			"dependencies": {
+				"@lezer/common": "^1.2.0",
+				"@lezer/highlight": "^1.0.0",
+				"@lezer/lr": "^1.0.0"
+			}
+		},
 		"node_modules/@ljharb/resumer": {
 			"version": "0.0.1",
 			"resolved": "https://registry.npmjs.org/@ljharb/resumer/-/resumer-0.0.1.tgz",
@@ -1665,6 +1892,11 @@
 				"node": ">= 0.4"
 			}
 		},
+		"node_modules/@marijn/find-cluster-break": {
+			"version": "1.0.2",
+			"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
+			"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g=="
+		},
 		"node_modules/@nicolo-ribaudo/eslint-scope-5-internals": {
 			"version": "5.1.1-v1",
 			"resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz",
@@ -3524,24 +3756,18 @@
 			}
 		},
 		"node_modules/codemirror": {
-			"version": "5.65.19",
-			"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.19.tgz",
-			"integrity": "sha512-+aFkvqhaAVr1gferNMuN8vkTSrWIFvzlMV9I2KBLCWS2WpZ2+UAkZjlMZmEuT+gcXTi6RrGQCkWq1/bDtGqhIA==",
-			"license": "MIT"
-		},
-		"node_modules/codemirror-editor-vue3": {
-			"version": "2.8.0",
-			"resolved": "https://registry.npmjs.org/codemirror-editor-vue3/-/codemirror-editor-vue3-2.8.0.tgz",
-			"integrity": "sha512-ebYGNhBpLmQNLguXzNyMMkn6K8v3lcS5/Ncvdn6YS4bLGEHE67MfsJIS/WV0L7I6WavUuFlY/Rs/AJKChIwSwg==",
-			"license": "MIT",
+			"version": "6.0.2",
+			"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz",
+			"integrity": "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==",
+			"peer": true,
 			"dependencies": {
-				"codemirror": "^5",
-				"diff-match-patch": "^1.0.5"
-			},
-			"peerDependencies": {
-				"codemirror": "^5",
-				"diff-match-patch": "^1.0.5",
-				"vue": "^3.x"
+				"@codemirror/autocomplete": "^6.0.0",
+				"@codemirror/commands": "^6.0.0",
+				"@codemirror/language": "^6.0.0",
+				"@codemirror/lint": "^6.0.0",
+				"@codemirror/search": "^6.0.0",
+				"@codemirror/state": "^6.0.0",
+				"@codemirror/view": "^6.0.0"
 			}
 		},
 		"node_modules/color-convert": {
@@ -3636,6 +3862,11 @@
 				"url": "https://opencollective.com/core-js"
 			}
 		},
+		"node_modules/crelt": {
+			"version": "1.0.6",
+			"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
+			"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
+		},
 		"node_modules/cropperjs": {
 			"version": "1.5.12",
 			"resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.5.12.tgz",
@@ -9014,6 +9245,11 @@
 				"vue": "3.2.44"
 			}
 		},
+		"node_modules/snowy-form-design/node_modules/codemirror": {
+			"version": "5.65.19",
+			"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.65.19.tgz",
+			"integrity": "sha512-+aFkvqhaAVr1gferNMuN8vkTSrWIFvzlMV9I2KBLCWS2WpZ2+UAkZjlMZmEuT+gcXTi6RrGQCkWq1/bDtGqhIA=="
+		},
 		"node_modules/snowy-form-design/node_modules/codemirror-editor-vue3": {
 			"version": "2.3.0",
 			"resolved": "https://registry.npmjs.org/codemirror-editor-vue3/-/codemirror-editor-vue3-2.3.0.tgz",
@@ -9265,6 +9501,11 @@
 			"dev": true,
 			"license": "MIT"
 		},
+		"node_modules/style-mod": {
+			"version": "4.1.2",
+			"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
+			"integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw=="
+		},
 		"node_modules/supports-color": {
 			"version": "7.2.0",
 			"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -10226,6 +10467,21 @@
 				"@vue/shared": "3.2.44"
 			}
 		},
+		"node_modules/vue-codemirror": {
+			"version": "6.1.1",
+			"resolved": "https://registry.npmjs.org/vue-codemirror/-/vue-codemirror-6.1.1.tgz",
+			"integrity": "sha512-rTAYo44owd282yVxKtJtnOi7ERAcXTeviwoPXjIc6K/IQYUsoDkzPvw/JDFtSP6T7Cz/2g3EHaEyeyaQCKoDMg==",
+			"dependencies": {
+				"@codemirror/commands": "6.x",
+				"@codemirror/language": "6.x",
+				"@codemirror/state": "6.x",
+				"@codemirror/view": "6.x"
+			},
+			"peerDependencies": {
+				"codemirror": "6.x",
+				"vue": "3.x"
+			}
+		},
 		"node_modules/vue-cropper": {
 			"version": "1.0.5",
 			"resolved": "https://registry.npmjs.org/vue-cropper/-/vue-cropper-1.0.5.tgz",
@@ -10665,6 +10921,11 @@
 			"integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==",
 			"license": "MIT"
 		},
+		"node_modules/w3c-keyname": {
+			"version": "2.2.8",
+			"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
+			"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
+		},
 		"node_modules/warning": {
 			"version": "4.0.3",
 			"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",

+ 7 - 1
package.json

@@ -23,6 +23,12 @@
 		"@ant-design/icons-vue": "6.1.0",
 		"@antv/g2plot": "2.4.28",
 		"@chenfengyuan/vue-qrcode": "2.0.0",
+		"@codemirror/lang-css": "^6.3.1",
+		"@codemirror/lang-html": "^6.4.9",
+		"@codemirror/lang-javascript": "^6.2.4",
+		"@codemirror/lang-json": "^6.0.2",
+		"@codemirror/lang-xml": "^6.1.0",
+		"@codemirror/theme-one-dark": "^6.1.3",
 		"@highlightjs/vue-plugin": "2.1.0",
 		"@tinymce/tinymce-vue": "5.0.0",
 		"@vue-office/docx": "^1.2.0",
@@ -30,7 +36,6 @@
 		"@vue-office/pdf": "1.2.0",
 		"ant-design-vue": "3.2.14",
 		"axios": "1.1.3",
-		"codemirror-editor-vue3": "^2.8.0",
 		"cropperjs": "1.5.12",
 		"dayjs": "1.11.7",
 		"echarts": "5.4.0",
@@ -58,6 +63,7 @@
 		"tinymce": "^6.2.0",
 		"video.js": "^8.23.3",
 		"vue": "3.2.44",
+		"vue-codemirror": "^6.1.1",
 		"vue-cropper": "1.0.5",
 		"vue-demi": "0.13.11",
 		"vue-i18n": "9.2.2",

+ 1 - 1
src/api/myResource/file.js

@@ -76,7 +76,7 @@ export const batchDeleteRecoveryFile = (p) => request('recoveryfile/batchdelete'
  * 文件公共接口
  */
 // 文件预览
-export const getFilePreview = (p) => request('filetransfer/preview', p, 'get')
+export const getFilePreview = (p) => request('filetransfer/preview', p, 'get', { skipCodeCheck: true })
 // 文件修改
 export const modifyFileContent = (p) => request('file/update', p, 'post')
 

+ 0 - 9
src/libs/globalFunction/file.js

@@ -74,12 +74,6 @@ const fileFunction = {
 	 * @returns {string}  文件下载路径
 	 */
 	getDownloadFilePath(row) {
-		console.log(
-			'获取下载地址',
-			`${config.baseContext}/filetransfer/downloadfile?userFileId=${row.userFileId}&shareBatchNum=${
-				row.shareBatchNum == null ? '' : row.shareBatchNum
-			}&extractionCode=${row.extractionCode == null ? '' : row.extractionCode}`
-		)
 		return `${config.baseContext}/filetransfer/downloadfile?userFileId=${row.userFileId}&shareBatchNum=${
 			row.shareBatchNum == null ? '' : row.shareBatchNum
 		}&extractionCode=${row.extractionCode == null ? '' : row.extractionCode}`
@@ -243,7 +237,6 @@ const fileFunction = {
 	 */
 	handleVideoPreview(currentIndex, videoInfo = {}, videoInfoList = []) {
 		// 视频分类下 - 传递整个页面的视频列表;非视频分类下 - 由单个视频构建视频列表
-		console.log('查看视频', router.currentRoute.value)
 		const videoList =
 			router.currentRoute.value.query.fileType && Number(router.currentRoute.value.query.fileType) === 3
 				? videoInfoList.map((item) => {
@@ -305,7 +298,6 @@ const fileFunction = {
 	 */
 	handleFileNameClick(row, currentIndex, fileList = []) {
 		const myResourceStore = useMyResourceStore()
-		console.log('查看')
 		// 如果当前文件在回收站中,则不允许预览
 		if (row.deleteFlag !== undefined && row.deleteFlag !== 0) {
 			return false
@@ -337,7 +329,6 @@ const fileFunction = {
 				// 	}
 				// })
 			} else if (Number(router.currentRoute.value.query.fileType) !== 6) {
-				console.log('打开网盘文件夹', row)
 				// 回收站页面不允许打开文件夹
 				// 网盘页面
 				myResourceStore.changeQuery({

+ 0 - 2
src/store/myResource.js

@@ -67,7 +67,6 @@ export const useMyResourceStore = defineStore('myResource', {
 		 * @param {string} data 文件展示模式
 		 */
 		changeFileModel(data) {
-			console.log('改变文件展示模式', data)
 			localStorage.setItem('qiwen_file_model', data)
 			this.fileModel = data
 		},
@@ -85,7 +84,6 @@ export const useMyResourceStore = defineStore('myResource', {
 		 * @param {array} data 批量操作模式下,被选中的文件列表
 		 */
 		changeSelectedFiles(data) {
-			console.log('批量操作模式下,被选中的文件列表', data)
 			this.selectedFiles = data
 		},
 		/**

+ 6 - 0
src/utils/reSourceRequest.js

@@ -87,6 +87,12 @@ service.interceptors.response.use(
 				return
 			}
 		}
+
+		// 如果设置了skipCodeCheck参数,则直接返回响应数据
+		if (response.config.skipCodeCheck) {
+			return Promise.resolve(response.data)
+		}
+
 		const data = response.data
 		const code = data.code
 		if (reloadCodes.includes(code)) {

+ 443 - 0
src/views/myResource/file/box/codePreview/BoxMask copy.vue

@@ -0,0 +1,443 @@
+<template>
+	<transition
+		name="fade"
+		enter-active-class="ant-fade-enter ant-fade-enter-active"
+		leave-active-class="ant-fade-leave ant-fade-leave-active"
+	>
+		<div class="code-preview-wrapper" v-show="visible" @keydown.ctrl.s.prevent="handleModifyFileContent">
+			<!-- 顶部信息栏 -->
+			<div class="tip-wrapper" v-if="visible">
+				<div class="name" :title="$getFileNameComplete(fileInfo)">
+					{{ $getFileNameComplete(fileInfo) }}
+					<span class="un-save" v-show="isModify && !codeMirrorOptions.readOnly">(未保存)</span>
+				</div>
+				<div class="editor-preview">在线预览{{ codeMirrorOptions.readOnly ? '' : ' & 编辑' }}</div>
+				<div class="tool-wrapper">
+					<a
+						class="item download-link"
+						target="_blank"
+						:href="$getDownloadFilePath(fileInfo)"
+						:download="$getFileNameComplete(fileInfo)"
+					>
+						<download-outlined title="下载" />
+					</a>
+					<a-tooltip placement="bottom">
+						<template #title>
+							<div>
+								操作提示:<br />
+								1. 按 Esc 键可退出查看;<br />
+								2. 支持在线编辑、保存、下载
+							</div>
+						</template>
+						<div class="item text-wrapper">
+							<span class="text">操作提示</span>
+							<bulb-outlined />
+						</div>
+					</a-tooltip>
+					<close-outlined class="item" title="关闭预览" @click="closeCodePreview" />
+				</div>
+			</div>
+
+			<!-- 代码编辑区域 -->
+			<div class="code-editor-wrapper">
+				<div class="operate-wrapper">
+					<save-outlined
+						v-show="isModify && !codeMirrorOptions.readOnly"
+						class="save-icon"
+						title="保存(ctrl+s)"
+						@click="handleModifyFileContent"
+					/>
+					<a-form class="editor-set-form" :model="codeMirrorOptions" layout="inline" size="small">
+						<a-form-item>
+							<a-checkbox v-model:checked="codeMirrorOptions.lineWrapping" @change="handleChangeCodeMirrorOption">
+								自动换行
+							</a-checkbox>
+						</a-form-item>
+
+						<a-form-item>
+							<a-select v-model:value="codeMirrorCustomOptions.fontSize" style="width: 96px" show-search>
+								<a-select-option v-for="size in fontSizeList" :key="size" :value="size">
+									{{ size }} px
+								</a-select-option>
+							</a-select>
+						</a-form-item>
+
+						<a-form-item label="代码语言">
+							<a-select
+								v-model:value="codeMirrorOptions.mode"
+								style="width: 120px"
+								show-search
+								@change="handleChangeCodeMirrorOption"
+							>
+								<a-select-option
+									v-for="[key, value] in Object.entries(fileSuffixCodeModeMap)"
+									:key="key"
+									:value="value[1].mime"
+								>
+									{{ value[1].language }}
+								</a-select-option>
+							</a-select>
+						</a-form-item>
+
+						<a-form-item label="主题">
+							<a-select
+								v-model:value="codeMirrorOptions.theme"
+								style="width: 190px"
+								show-search
+								@change="handleChangeCodeMirrorOption"
+							>
+								<a-select-option value="default">default</a-select-option>
+								<a-select-option v-for="theme in codeMirrorThemeList" :key="theme" :value="theme">
+									{{ theme }}
+								</a-select-option>
+							</a-select>
+						</a-form-item>
+					</a-form>
+				</div>
+
+				<a-spin :spinning="codeMirrorLoading">
+					<!-- <Codemirror
+						v-if="isShow"
+						ref="codemirrorRef"
+						v-model:value="codeMirrorText"
+						:options="codeMirrorOptions"
+						class="code-editor"
+						:style="{ fontSize: `${codeMirrorCustomOptions.fontSize}px` }"
+					/> -->
+				</a-spin>
+			</div>
+		</div>
+	</transition>
+</template>
+
+<script setup>
+	import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
+	import { message } from 'ant-design-vue'
+	// import { Codemirror } from 'codemirror-editor-vue3'
+	// 启用基础样式
+	// import 'codemirror-editor-vue3/dist/style.css'
+	// // 启用编程语言
+	// import 'codemirror/mode/javascript/javascript.js'
+	// import 'codemirror/mode/xml/xml.js'
+	// import 'codemirror/mode/css/css.js'
+	// // 启用主题
+	// import 'codemirror/lib/codemirror.css'
+	// import 'codemirror/theme/monokai.css'
+	// import 'codemirror/theme/material.css'
+	import { DownloadOutlined, BulbOutlined, CloseOutlined, SaveOutlined } from '@ant-design/icons-vue'
+	import { useMyResourceStore } from '@/store/myResource'
+	import { getFilePreview, modifyFileContent } from '@/api/myResource/file'
+	import { fontSizeList, fileSuffixCodeModeMap, codeMirrorThemeList } from '@/libs/map'
+
+	// import 'codemirror/lib/codemirror.css'
+	// import './theme.js'
+	// import './mode.js'
+	// import './fold.js'
+
+	// 状态管理
+	const store = useMyResourceStore()
+
+	const visible = ref(false)
+	const originalCodeText = ref('')
+	const codeMirrorText = ref('')
+	const codeMirrorLoading = ref(false)
+	const codeMirrorOptions = ref({
+		tabSize: 4,
+		mode: 'text/html',
+		theme: 'default',
+		readOnly: true,
+		lineNumbers: true,
+		line: true,
+		autoCloseBrackets: true,
+		foldGutter: true,
+		lineWrapping: true,
+		gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers']
+	})
+	const codeMirrorCustomOptions = ref({
+		fontSize: 14
+	})
+	const isShow = ref(true)
+
+	// 计算属性
+	const screenWidth = computed(() => store.screenWidth)
+	const isModify = computed(() => originalCodeText.value !== codeMirrorText.value)
+
+	// 方法
+	function getCodeText() {
+		codeMirrorLoading.value = true
+		getFilePreview({
+			userFileId: fileInfo.userFileId,
+			isMin: false,
+			shareBatchNum: fileInfo.shareBatchNum,
+			extractionCode: fileInfo.extractionCode,
+			token: $common.getCookies($config.tokenKeyName)
+		}).then((res) => {
+			codeMirrorLoading.value = false
+			originalCodeText.value = typeof res === 'object' ? JSON.stringify(res) : res
+			codeMirrorText.value = originalCodeText.value + ''
+		})
+	}
+
+	function handleModifyFileContent() {
+		if (!isModify.value || codeMirrorOptions.value.readOnly) {
+			return false
+		}
+		codeMirrorLoading.value = true
+		modifyFileContent({
+			userFileId: fileInfo.userFileId,
+			fileContent: codeMirrorText.value
+		})
+			.then((res) => {
+				codeMirrorLoading.value = false
+				if (res.success) {
+					message.success('已保存')
+					getCodeText()
+				} else {
+					message.error(res.message)
+				}
+			})
+			.catch((err) => {
+				codeMirrorLoading.value = false
+				message.error(err.message)
+			})
+	}
+
+	function handleChangeCodeMirrorOption() {
+		isShow.value = false
+		isShow.value = true
+	}
+
+	function closeCodePreview() {
+		visible.value = false
+		callback('cancel')
+	}
+
+	// 监听
+	watch(visible, (val) => {
+		if (val) {
+			let fileSuffix = fileInfo.extendName.toLowerCase()
+			if (fileSuffix === 'yaml') {
+				fileSuffix = 'yml'
+			}
+			if (fileSuffixCodeModeMap.has(fileSuffix)) {
+				codeMirrorOptions.value.mode = fileSuffixCodeModeMap.get(fileSuffix).mime
+			}
+			codeMirrorOptions.value.readOnly = !isEdit //  设置编辑器是否只读
+			codeMirrorOptions.value.theme = localStorage.getItem('qiwen_file_codemirror_theme') || 'default'
+			getCodeText()
+			// 添加键盘 Esc 事件
+			nextTick(() => {
+				document.addEventListener('keyup', (e) => {
+					if (e.keyCode === 27) {
+						closeCodePreview()
+					}
+				})
+			})
+		} else {
+			document.removeEventListener('keyup', (e) => {
+				if (e.keyCode === 27) {
+					closeCodePreview()
+				}
+			})
+		}
+	})
+
+	watch(
+		() => codeMirrorOptions.value.theme,
+		(val) => {
+			localStorage.setItem('qiwen_file_codemirror_theme', val)
+		}
+	)
+
+	// 生命周期钩子
+	onMounted(() => {})
+
+	onUnmounted(() => {})
+
+	defineExpose({
+		visible
+	})
+</script>
+
+<style lang="less" scoped>
+	@import '@/style/myResource/varibles.less';
+
+	.code-preview-wrapper {
+		position: fixed;
+		top: 0;
+		right: 0;
+		bottom: 0;
+		left: 0;
+		overflow: auto;
+		width: 100%;
+		height: 100vh;
+		z-index: 2;
+		display: flex;
+		align-items: center;
+		animation: imgPreviewAnimation 0.3s;
+		-webkit-animation: imgPreviewAnimation 0.3s; /* Safari and Chrome */
+		animation-iteration-count: 0.3;
+		-webkit-animation-iteration-count: 0.3;
+		animation-fill-mode: forwards;
+		-webkit-animation-fill-mode: forwards; /* Safari 和 Chrome */
+		@keyframes imgPreviewAnimation {
+			0% {
+				background: transparent;
+			}
+			100% {
+				background: rgba(0, 0, 0, 0.8);
+			}
+		}
+		@keyframes imgPreviewAnimation {
+			0% {
+				background: transparent;
+			}
+			100% {
+				background: rgba(0, 0, 0, 0.8);
+			}
+		}
+		.tip-wrapper {
+			position: fixed;
+			top: 0;
+			left: 0;
+			z-index: 2;
+			background: rgba(0, 0, 0, 0.5);
+			padding: 0 48px;
+			width: 100%;
+			height: 48px;
+			line-height: 48px;
+			color: #fff;
+			font-size: 16px;
+			display: flex;
+			justify-content: space-between;
+			.name {
+				flex: 1;
+				padding-right: 16px;
+				text-align: left;
+				overflow: hidden;
+				text-overflow: ellipsis;
+				white-space: nowrap;
+				.un-save {
+					color: @Warning;
+					font-size: 14px;
+				}
+			}
+			.tool-wrapper {
+				flex: 1;
+				display: flex;
+				justify-content: flex-end;
+				.item {
+					margin-left: 16px;
+					height: 48px;
+					line-height: 48px;
+					cursor: pointer;
+					&:hover {
+						opacity: 0.7;
+					}
+				}
+				.download-link {
+					color: inherit;
+					font-size: 18px;
+				}
+				.text-wrapper {
+					.text {
+						margin-right: 8px;
+					}
+				}
+			}
+		}
+		.code-editor-wrapper {
+			margin: 56px auto 0 auto;
+			width: 90vw;
+			height: calc(100vh - 80px);
+			.operate-wrapper {
+				display: flex;
+				justify-content: space-between;
+				align-items: center;
+				border-radius: 8px 8px 0 0;
+				border-bottom: 1px solid @BorderBase;
+				padding: 8px 16px;
+				background: #fff;
+				.save-icon {
+					font-size: 20px;
+					cursor: pointer;
+					color: @Info;
+					font-weight: 550;
+					&:hover {
+						opacity: 0.5;
+					}
+				}
+				.editor-set-form {
+					flex: 1;
+					text-align: right;
+					// >>> .el-form-item {
+					//   margin-bottom: 0;
+					//   &.font-size {
+					//     .el-form-item__content {
+					//       .el-select {
+					//         width: 96px;
+					//       }
+					//     }
+					//   }
+					//   &.lanaguage {
+					//     .el-form-item__content {
+					//       .el-select {
+					//         width: 120px;
+					//       }
+					//     }
+					//   }
+					//   &.theme {
+					//     .el-form-item__content {
+					//       .el-select {
+					//         width: 190px;
+					//       }
+					//     }
+					//   }
+					// }
+				}
+			}
+			.code-editor {
+				height: calc(100vh - 129px);
+				//   >>> .CodeMirror {
+				//     border-radius: 0 0 8px 8px;
+				//     height: inherit;
+				//     font-size: inherit;
+				//     * {
+				//       font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace !important;
+				//     }
+				//     .CodeMirror-vscrollbar, .CodeMirror-hscrollbar {
+				//       display: none !important;
+				//     }
+				//     .CodeMirror-scroll {
+				//       width: 100%;
+				//       padding: 8px 0 0 0;
+				//       line-height: 1.5;
+				//       font-size: inherit;
+				//       setScrollbar(12px, transparent, #C0C4CC);
+				//     }
+				//   }
+			}
+		}
+	}
+	.editor-preveiw {
+		margin-left: -102px;
+	}
+	.editor-preveiw[data-v-8897ab08] {
+		margin-left: -102px;
+	}
+	/deep/ .el-checkbox__input.is-checked + .el-checkbox__label {
+		color: #29175b;
+	}
+	/deep/ .el-checkbox__input.is-checked .el-checkbox__inner,
+	.el-checkbox__input.is-indeterminate .el-checkbox__inner {
+		background-color: #29175b;
+		border-color: #29175b;
+	}
+	/deep/ .el-select .el-input.is-focus .el-input__inner {
+		border-color: #29175b;
+	}
+	/deep/ .el-select-dropdown__item.selected {
+		color: #29175b !important;
+		font-weight: 700;
+	}
+</style>

+ 279 - 224
src/views/myResource/file/box/codePreview/BoxMask.vue

@@ -1,109 +1,88 @@
 <template>
-	<transition
-		name="fade"
-		enter-active-class="ant-fade-enter ant-fade-enter-active"
-		leave-active-class="ant-fade-leave ant-fade-leave-active"
-	>
-		<div class="code-preview-wrapper" v-show="visible" @keydown.ctrl.s.prevent="handleModifyFileContent">
-			<!-- 顶部信息栏 -->
+	<transition name="fade-in">
+		<div class="code-preview-wrapper" v-show="visible" @keydown.s.ctrl.prevent="handleModifyFileContent">
+			<!-- 顶部信息栏 & 工具栏 -->
 			<div class="tip-wrapper" v-if="visible">
-				<div class="name" :title="$getFileNameComplete(fileInfo)">
-					{{ $getFileNameComplete(fileInfo) }}
+				<div class="name" :title="$file.getFileNameComplete(fileInfo)">
+					{{ $file.getFileNameComplete(fileInfo) }}
 					<span class="un-save" v-show="isModify && !codeMirrorOptions.readOnly">(未保存)</span>
 				</div>
-				<div class="editor-preview">在线预览{{ codeMirrorOptions.readOnly ? '' : ' & 编辑' }}</div>
+				<div class="editor-preveiw">在线预览{{ codeMirrorOptions.readOnly ? '' : ' & 编辑' }}</div>
 				<div class="tool-wrapper">
 					<a
 						class="item download-link"
 						target="_blank"
-						:href="$getDownloadFilePath(fileInfo)"
-						:download="$getFileNameComplete(fileInfo)"
+						:href="$file.getDownloadFilePath(fileInfo)"
+						:download="$file.getFileNameComplete(fileInfo)"
 					>
-						<download-outlined title="下载" />
+						<DownloadOutlined title="下载" />
 					</a>
 					<a-tooltip placement="bottom">
 						<template #title>
-							<div>
-								操作提示:<br />
-								1. 按 Esc 键可退出查看;<br />
-								2. 支持在线编辑、保存、下载
-							</div>
+							操作提示: <br />
+							1. 按 Esc 键可退出查看;<br />
+							2. 支持在线编辑、保存、下载
 						</template>
 						<div class="item text-wrapper">
 							<span class="text">操作提示</span>
-							<bulb-outlined />
+							<BulbOutlined />
 						</div>
 					</a-tooltip>
-					<close-outlined class="item" title="关闭预览" @click="closeCodePreview" />
+					<CloseOutlined class="item" title="关闭预览" @click="closeCodePreview" />
 				</div>
 			</div>
-
 			<!-- 代码编辑区域 -->
 			<div class="code-editor-wrapper">
 				<div class="operate-wrapper">
-					<save-outlined
-						v-show="isModify && !codeMirrorOptions.readOnly"
+					<SaveOutlined
 						class="save-icon"
 						title="保存(ctrl+s)"
+						v-show="isModify && !codeMirrorOptions.readOnly"
 						@click="handleModifyFileContent"
 					/>
-					<a-form class="editor-set-form" :model="codeMirrorOptions" layout="inline" size="small">
-						<a-form-item>
-							<a-checkbox v-model:checked="codeMirrorOptions.lineWrapping" @change="handleChangeCodeMirrorOption">
-								自动换行
-							</a-checkbox>
+					<a-form class="editor-set-form" :model="codeMirrorOptions" layout="inline" size="small" label-align="right">
+						<a-form-item class="line-wrapper">
+							<a-checkbox v-model:checked="codeMirrorOptions.lineWrapping" @change="handleChangeCodeMirrorOption"
+								>自动换行</a-checkbox
+							>
 						</a-form-item>
-
-						<a-form-item>
-							<a-select v-model:value="codeMirrorCustomOptions.fontSize" style="width: 96px" show-search>
-								<a-select-option v-for="size in fontSizeList" :key="size" :value="size">
-									{{ size }} px
-								</a-select-option>
+						<a-form-item class="font-size">
+							<a-select v-model:value="codeMirrorCustomOptions.fontSize" filterable>
+								<a-select-option v-for="(item, index) in fontSizeList" :key="index" :value="item"
+									>{{ item }} px</a-select-option
+								>
 							</a-select>
 						</a-form-item>
-
-						<a-form-item label="代码语言">
-							<a-select
-								v-model:value="codeMirrorOptions.mode"
-								style="width: 120px"
-								show-search
-								@change="handleChangeCodeMirrorOption"
-							>
-								<a-select-option
-									v-for="[key, value] in Object.entries(fileSuffixCodeModeMap)"
-									:key="key"
-									:value="value[1].mime"
-								>
-									{{ value[1].language }}
-								</a-select-option>
+						<a-form-item label="代码语言" class="lanaguage">
+							<a-select v-model:value="codeMirrorLanguage" filterable @change="handleChangeCodeMirrorOption">
+								<a-select-option v-for="[key, value] in fileSuffixCodeModeMap.entries()" :key="key" :value="key">{{
+									value.language
+								}}</a-select-option>
 							</a-select>
 						</a-form-item>
-
-						<a-form-item label="主题">
-							<a-select
-								v-model:value="codeMirrorOptions.theme"
-								style="width: 190px"
-								show-search
-								@change="handleChangeCodeMirrorOption"
-							>
+						<a-form-item label="主题" class="theme">
+							<a-select v-model:value="codeMirrorTheme" filterable @change="handleChangeCodeMirrorOption">
 								<a-select-option value="default">default</a-select-option>
-								<a-select-option v-for="theme in codeMirrorThemeList" :key="theme" :value="theme">
-									{{ theme }}
-								</a-select-option>
+								<a-select-option v-for="(item, index) in codeMirrorThemeList" :key="index" :value="item">{{
+									item
+								}}</a-select-option>
 							</a-select>
 						</a-form-item>
 					</a-form>
 				</div>
-
 				<a-spin :spinning="codeMirrorLoading">
-					<!-- <Codemirror
-						v-if="isShow"
-						ref="codemirrorRef"
-						v-model:value="codeMirrorText"
-						:options="codeMirrorOptions"
+					<Codemirror
 						class="code-editor"
+						ref="codemirrorRef"
+						v-model="codeMirrorText"
 						:style="{ fontSize: `${codeMirrorCustomOptions.fontSize}px` }"
-					/> -->
+						:extensions="extensions"
+						:disabled="codeMirrorOptions.readOnly"
+						:indent-with-tab="true"
+						:tab-size="codeMirrorOptions.tabSize"
+						:placeholder="'请输入代码...'"
+						v-if="isShow"
+					/>
 				</a-spin>
 			</div>
 		</div>
@@ -111,37 +90,45 @@
 </template>
 
 <script setup>
-	import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
+	import { ref, reactive, computed, watch, onMounted, onUnmounted, getCurrentInstance } from 'vue'
 	import { message } from 'ant-design-vue'
-	// import { Codemirror } from 'codemirror-editor-vue3'
-	// 启用基础样式
-	// import 'codemirror-editor-vue3/dist/style.css'
-	// // 启用编程语言
-	// import 'codemirror/mode/javascript/javascript.js'
-	// import 'codemirror/mode/xml/xml.js'
-	// import 'codemirror/mode/css/css.js'
-	// // 启用主题
-	// import 'codemirror/lib/codemirror.css'
-	// import 'codemirror/theme/monokai.css'
-	// import 'codemirror/theme/material.css'
 	import { DownloadOutlined, BulbOutlined, CloseOutlined, SaveOutlined } from '@ant-design/icons-vue'
-	import { useMyResourceStore } from '@/store/myResource'
-	import { getFilePreview, modifyFileContent } from '@/api/myResource/file'
-	import { fontSizeList, fileSuffixCodeModeMap, codeMirrorThemeList } from '@/libs/map'
+	import { Codemirror } from 'vue-codemirror'
+	import { basicSetup } from 'codemirror'
+	import { oneDark } from '@codemirror/theme-one-dark'
+	import { javascript } from '@codemirror/lang-javascript'
+	import { html } from '@codemirror/lang-html'
+	import { css } from '@codemirror/lang-css'
+	import { json } from '@codemirror/lang-json'
+	import { xml } from '@codemirror/lang-xml'
+	import { EditorView } from '@codemirror/view'
+	import { fontSizeList, fileSuffixCodeModeMap, codeMirrorThemeList } from '@/libs/map.js'
+	import { useMyResourceStore } from '@/store/myResource.js'
+	import { getFilePreview, modifyFileContent } from '@/api/myResource/file.js'
+	import tool from '@/utils/tool'
 
-	// import 'codemirror/lib/codemirror.css'
-	// import './theme.js'
-	// import './mode.js'
-	// import './fold.js'
+	const props = defineProps({
+		fileInfo: Object,
+		isEdit: Boolean,
+		callback: Function
+	})
 
-	// 状态管理
-	const store = useMyResourceStore()
+	const { proxy } = getCurrentInstance()
+	const myResource = useMyResourceStore()
 
 	const visible = ref(false)
+	defineExpose({ visible })
+
 	const originalCodeText = ref('')
 	const codeMirrorText = ref('')
 	const codeMirrorLoading = ref(false)
-	const codeMirrorOptions = ref({
+	const isShow = ref(true)
+	const codemirrorRef = ref(null)
+	const codeMirrorLanguage = ref('html')
+	const codeMirrorTheme = ref('default')
+
+	// CodeMirror 配置
+	const codeMirrorOptions = reactive({
 		tabSize: 4,
 		mode: 'text/html',
 		theme: 'default',
@@ -153,38 +140,137 @@
 		lineWrapping: true,
 		gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers']
 	})
-	const codeMirrorCustomOptions = ref({
+
+	const codeMirrorCustomOptions = reactive({
 		fontSize: 14
 	})
-	const isShow = ref(true)
 
-	// 计算属性
-	const screenWidth = computed(() => store.screenWidth)
+	// 根据语言和主题生成扩展
+	const extensions = computed(() => {
+		const exts = [basicSetup]
+
+		// 添加语言支持
+		switch (codeMirrorLanguage.value) {
+			case 'js':
+			case 'javascript':
+				exts.push(javascript())
+				break
+			case 'html':
+				exts.push(html())
+				break
+			case 'css':
+				exts.push(css())
+				break
+			case 'json':
+				exts.push(json())
+				break
+			case 'xml':
+				exts.push(xml())
+				break
+			default:
+				exts.push(html())
+		}
+
+		// 添加主题
+		if (codeMirrorTheme.value === 'one-dark') {
+			exts.push(oneDark)
+		} else {
+			// 默认亮色主题
+			exts.push(
+				EditorView.theme({
+					'&': {
+						height: '100%',
+						fontSize: `${codeMirrorCustomOptions.fontSize}px`,
+						color: '#e0e0e0' // 添加默认文本颜色为浅灰色
+					},
+					'.cm-scroller': {
+						overflow: 'auto'
+					},
+					'.cm-content': {
+						color: '#e0e0e0' // 确保内容区域文本为浅灰色
+					},
+					'.cm-line': {
+						color: '#e0e0e0' // 确保每行文本为浅灰色
+					},
+					// 语法高亮颜色
+					'.cm-comment': { color: '#6a9955' }, // 注释
+					'.cm-keyword': { color: '#569cd6' }, // 关键字
+					'.cm-string': { color: '#ce9178' }, // 字符串
+					'.cm-number': { color: '#b5cea8' }, // 数字
+					'.cm-property': { color: '#9cdcfe' }, // 属性
+					'.cm-operator': { color: '#d4d4d4' }, // 操作符
+					'.cm-meta': { color: '#dcdcaa' }, // 元数据
+					'.cm-atom': { color: '#4ec9b0' }, // 原子
+					'.cm-variable': { color: '#9cdcfe' }, // 变量
+					'.cm-tag': { color: '#569cd6' }, // 标签
+					'.cm-attribute': { color: '#9cdcfe' } // 属性
+				})
+			)
+		}
+
+		// 添加行号
+		if (codeMirrorOptions.lineNumbers) {
+			exts.push(EditorView.lineWrapping)
+		}
+
+		return exts
+	})
+
+	const screenWidth = computed(() => myResource.screenWidth)
 	const isModify = computed(() => originalCodeText.value !== codeMirrorText.value)
 
-	// 方法
-	function getCodeText() {
+	watch(visible, (val) => {
+		if (val) {
+			let fileSuffix = props.fileInfo.extendName.toLowerCase()
+			if (fileSuffix === 'yaml') {
+				fileSuffix = 'yml'
+			}
+			if (fileSuffixCodeModeMap.has(fileSuffix)) {
+				codeMirrorLanguage.value = fileSuffix
+				codeMirrorOptions.mode = fileSuffixCodeModeMap.get(fileSuffix).mime
+			}
+			codeMirrorOptions.readOnly = !props.isEdit
+			codeMirrorTheme.value = localStorage.getItem('qiwen_file_codemirror_theme') || 'default'
+			getCodeText()
+			document.addEventListener('keyup', handleEscKey)
+		} else {
+			document.removeEventListener('keyup', handleEscKey)
+		}
+	})
+
+	watch(
+		() => codeMirrorTheme.value,
+		(val) => {
+			localStorage.setItem('qiwen_file_codemirror_theme', val)
+		}
+	)
+
+	const getCodeText = () => {
 		codeMirrorLoading.value = true
 		getFilePreview({
-			userFileId: fileInfo.userFileId,
+			userFileId: props.fileInfo.userFileId,
 			isMin: false,
-			shareBatchNum: fileInfo.shareBatchNum,
-			extractionCode: fileInfo.extractionCode,
-			token: $common.getCookies($config.tokenKeyName)
-		}).then((res) => {
-			codeMirrorLoading.value = false
-			originalCodeText.value = typeof res === 'object' ? JSON.stringify(res) : res
-			codeMirrorText.value = originalCodeText.value + ''
+			shareBatchNum: props.fileInfo.shareBatchNum,
+			extractionCode: props.fileInfo.extractionCode,
+			token: tool.data.get('TOKEN')
 		})
+			.then((res) => {
+				codeMirrorLoading.value = false
+				originalCodeText.value = typeof res === 'object' ? JSON.stringify(res) : res
+				codeMirrorText.value = originalCodeText.value + ''
+			})
+			.catch(() => {
+				codeMirrorLoading.value = false
+			})
 	}
 
-	function handleModifyFileContent() {
-		if (!isModify.value || codeMirrorOptions.value.readOnly) {
+	const handleModifyFileContent = () => {
+		if (!isModify.value || codeMirrorOptions.readOnly) {
 			return false
 		}
 		codeMirrorLoading.value = true
 		modifyFileContent({
-			userFileId: fileInfo.userFileId,
+			userFileId: props.fileInfo.userFileId,
 			fileContent: codeMirrorText.value
 		})
 			.then((res) => {
@@ -202,65 +288,38 @@
 			})
 	}
 
-	function handleChangeCodeMirrorOption() {
+	const handleChangeCodeMirrorOption = () => {
 		isShow.value = false
-		isShow.value = true
+		setTimeout(() => {
+			isShow.value = true
+		}, 0)
 	}
 
-	function closeCodePreview() {
+	const closeCodePreview = () => {
 		visible.value = false
-		callback('cancel')
+		props.callback('cancel')
 	}
 
-	// 监听
-	watch(visible, (val) => {
-		if (val) {
-			let fileSuffix = fileInfo.extendName.toLowerCase()
-			if (fileSuffix === 'yaml') {
-				fileSuffix = 'yml'
-			}
-			if (fileSuffixCodeModeMap.has(fileSuffix)) {
-				codeMirrorOptions.value.mode = fileSuffixCodeModeMap.get(fileSuffix).mime
-			}
-			codeMirrorOptions.value.readOnly = !isEdit //  设置编辑器是否只读
-			codeMirrorOptions.value.theme = localStorage.getItem('qiwen_file_codemirror_theme') || 'default'
-			getCodeText()
-			// 添加键盘 Esc 事件
-			nextTick(() => {
-				document.addEventListener('keyup', (e) => {
-					if (e.keyCode === 27) {
-						closeCodePreview()
-					}
-				})
-			})
-		} else {
-			document.removeEventListener('keyup', (e) => {
-				if (e.keyCode === 27) {
-					closeCodePreview()
-				}
-			})
+	const handleEscKey = (e) => {
+		if (e.keyCode === 27) {
+			closeCodePreview()
 		}
-	})
+	}
 
-	watch(
-		() => codeMirrorOptions.value.theme,
-		(val) => {
-			localStorage.setItem('qiwen_file_codemirror_theme', val)
+	onMounted(() => {
+		if (visible.value) {
+			document.addEventListener('keyup', handleEscKey)
 		}
-	)
-
-	// 生命周期钩子
-	onMounted(() => {})
-
-	onUnmounted(() => {})
+	})
 
-	defineExpose({
-		visible
+	onUnmounted(() => {
+		document.removeEventListener('keyup', handleEscKey)
 	})
 </script>
 
 <style lang="less" scoped>
 	@import '@/style/myResource/varibles.less';
+	@import '@/style/myResource/mixins.less';
 
 	.code-preview-wrapper {
 		position: fixed;
@@ -288,14 +347,6 @@
 				background: rgba(0, 0, 0, 0.8);
 			}
 		}
-		@keyframes imgPreviewAnimation {
-			0% {
-				background: transparent;
-			}
-			100% {
-				background: rgba(0, 0, 0, 0.8);
-			}
-		}
 		.tip-wrapper {
 			position: fixed;
 			top: 0;
@@ -318,7 +369,7 @@
 				text-overflow: ellipsis;
 				white-space: nowrap;
 				.un-save {
-					color: @Warning;
+					color: @warning-color;
 					font-size: 14px;
 				}
 			}
@@ -346,6 +397,7 @@
 				}
 			}
 		}
+
 		.code-editor-wrapper {
 			margin: 56px auto 0 auto;
 			width: 90vw;
@@ -355,9 +407,10 @@
 				justify-content: space-between;
 				align-items: center;
 				border-radius: 8px 8px 0 0;
-				border-bottom: 1px solid @BorderBase;
+				border-bottom: 1px solid @border-color-base;
 				padding: 8px 16px;
-				background: #fff;
+				background: #1e1e1e; /* 修改为暗色背景 */
+				color: #e0e0e0; /* 添加文字颜色为浅色 */
 				.save-icon {
 					font-size: 20px;
 					cursor: pointer;
@@ -370,74 +423,76 @@
 				.editor-set-form {
 					flex: 1;
 					text-align: right;
-					// >>> .el-form-item {
-					//   margin-bottom: 0;
-					//   &.font-size {
-					//     .el-form-item__content {
-					//       .el-select {
-					//         width: 96px;
-					//       }
-					//     }
-					//   }
-					//   &.lanaguage {
-					//     .el-form-item__content {
-					//       .el-select {
-					//         width: 120px;
-					//       }
-					//     }
-					//   }
-					//   &.theme {
-					//     .el-form-item__content {
-					//       .el-select {
-					//         width: 190px;
-					//       }
-					//     }
-					//   }
-					// }
+					:deep(.ant-form-item) {
+						margin-bottom: 0;
+						/* 修改表单项文字颜色 */
+						color: #e0e0e0;
+						.ant-form-item-label > label {
+							color: #e0e0e0;
+						}
+						.ant-checkbox-wrapper {
+							color: #e0e0e0;
+						}
+						&.font-size {
+							.ant-form-item-control-input-content {
+								.ant-select {
+									width: 96px;
+								}
+							}
+						}
+						&.lanaguage {
+							.ant-form-item-control-input-content {
+								.ant-select {
+									width: 120px;
+								}
+							}
+						}
+						&.theme {
+							.ant-form-item-control-input-content {
+								.ant-select {
+									width: 190px;
+								}
+							}
+						}
+					}
 				}
 			}
 			.code-editor {
 				height: calc(100vh - 129px);
-				//   >>> .CodeMirror {
-				//     border-radius: 0 0 8px 8px;
-				//     height: inherit;
-				//     font-size: inherit;
-				//     * {
-				//       font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace !important;
-				//     }
-				//     .CodeMirror-vscrollbar, .CodeMirror-hscrollbar {
-				//       display: none !important;
-				//     }
-				//     .CodeMirror-scroll {
-				//       width: 100%;
-				//       padding: 8px 0 0 0;
-				//       line-height: 1.5;
-				//       font-size: inherit;
-				//       setScrollbar(12px, transparent, #C0C4CC);
-				//     }
-				//   }
+				background: #1e1e1e; /* 添加暗色背景 */
+				:deep(.cm-editor) {
+					border-radius: 0 0 8px 8px;
+					height: inherit;
+					font-size: inherit;
+					background: #1e1e1e; /* 添加暗色背景 */
+					color: #e0e0e0; /* 确保编辑器文本为浅灰色 */
+					* {
+						font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace !important;
+					}
+					.cm-scroller {
+						width: 100%;
+						padding: 8px 0 0 0;
+						line-height: 1.5;
+						font-size: inherit;
+						overflow: auto;
+						background: #1e1e1e; /* 添加暗色背景 */
+					}
+					.cm-content {
+						color: #e0e0e0; /* 确保内容区域文本为浅灰色 */
+					}
+					.cm-line {
+						color: #e0e0e0; /* 确保每行文本为浅灰色 */
+					}
+					.cm-gutters {
+						background: #1e1e1e; /* 行号区域背景 */
+						border-right: 1px solid #333; /* 行号右侧边框 */
+						color: #858585; /* 行号颜色 */
+					}
+					.cm-activeLineGutter {
+						background-color: #2c2c2c; /* 当前行的行号背景 */
+					}
+				}
 			}
 		}
 	}
-	.editor-preveiw {
-		margin-left: -102px;
-	}
-	.editor-preveiw[data-v-8897ab08] {
-		margin-left: -102px;
-	}
-	/deep/ .el-checkbox__input.is-checked + .el-checkbox__label {
-		color: #29175b;
-	}
-	/deep/ .el-checkbox__input.is-checked .el-checkbox__inner,
-	.el-checkbox__input.is-indeterminate .el-checkbox__inner {
-		background-color: #29175b;
-		border-color: #29175b;
-	}
-	/deep/ .el-select .el-input.is-focus .el-input__inner {
-		border-color: #29175b;
-	}
-	/deep/ .el-select-dropdown__item.selected {
-		color: #29175b !important;
-		font-weight: 700;
-	}
 </style>

+ 2 - 1
src/views/myResource/file/box/codePreview/index.js

@@ -2,7 +2,7 @@ import { createApp } from 'vue'
 import Antd from 'ant-design-vue'
 // 导入组件
 import CodePreview from './BoxMask.vue'
-
+import snowy from '@/snowy'
 let codePreviewInstance = null
 let codePreviewApp = null
 
@@ -21,6 +21,7 @@ const initInstanceCodePreview = (fileInfo, isEdit, callback) => {
 	})
 	// 注册 Ant Design Vue 组件
 	codePreviewApp.use(Antd)
+	codePreviewApp.use(snowy)
 	codePreviewInstance = codePreviewApp.mount(mountNode)
 	return mountNode
 }