diff --git a/app/Models/FileContent.php b/app/Models/FileContent.php
index 63b6ae35a..21ce768cf 100644
--- a/app/Models/FileContent.php
+++ b/app/Models/FileContent.php
@@ -72,23 +72,18 @@ class FileContent extends AbstractModel
$content['preview'] = false;
if ($file->ext) {
$filePath = public_path($content['url']);
- switch ($file->type) {
- // 支持编辑
- case 'txt':
- case 'code':
- $content['content'] = file_get_contents($filePath);
- break;
-
+ if (in_array($file->type, ['txt', 'code']) && $file->size < 2 * 1024 * 1024) {
+ // 支持编辑,限制2M内的文件
+ $content['content'] = file_get_contents($filePath);
+ } else {
// 支持预览
- default:
- if (in_array($file->type, ['picture', 'image', 'tif', 'media'])) {
- $url = Base::fillUrl($content['url']);
- } else {
- $url = 'http://' . env('APP_IPPR') . '.3/' . $content['url'];
- }
- $content['url'] = base64_encode($url);
- $content['preview'] = true;
- break;
+ if (in_array($file->type, ['picture', 'image', 'tif', 'media'])) {
+ $url = Base::fillUrl($content['url']);
+ } else {
+ $url = 'http://' . env('APP_IPPR') . '.3/' . $content['url'];
+ }
+ $content['url'] = base64_encode($url);
+ $content['preview'] = true;
}
}
if ($download) {
diff --git a/resources/assets/js/components/AceEditor.vue b/resources/assets/js/components/AceEditor.vue
index ec34d4c22..2e627f061 100644
--- a/resources/assets/js/components/AceEditor.vue
+++ b/resources/assets/js/components/AceEditor.vue
@@ -27,13 +27,19 @@ export default {
type: Number || null,
default: null
},
+ wrap: {
+ type: Boolean,
+ default: false
+ },
readOnly: {
type: Boolean,
default: false
},
},
render(createElement) {
- return createElement('div')
+ return createElement('div', {
+ class: "no-dark-mode"
+ })
},
data: () => ({
code: '',
@@ -187,7 +193,7 @@ export default {
// init ace editor
this.editor = window.ace.edit(this.$el, {
- wrap: true,
+ wrap: this.wrap,
showPrintMargin: false,
readOnly: this.readOnly,
keyboardHandler: 'vscode',
diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue
index de1dc5c9c..04c944843 100644
--- a/resources/assets/js/pages/manage/components/FileContent.vue
+++ b/resources/assets/js/pages/manage/components/FileContent.vue
@@ -53,7 +53,7 @@