优化:1,file列表页工具栏新建的整个逻辑链的英文文本,缺少翻译的增加对应的翻译

2,txt文档要支持编辑
This commit is contained in:
jingrow 2026-05-28 23:40:25 +08:00
parent a857b7f0a6
commit 5043b96d90
2 changed files with 35 additions and 1 deletions

View File

@ -50,7 +50,15 @@
<div v-if="textLoading" class="visual-fallback">
<Icon icon="tabler:loader-2" :size="32" class="spin-icon" />
</div>
<pre v-else-if="textContent !== null" class="text-content">{{ textContent }}</pre>
<textarea
v-else-if="textContent !== null"
ref="textEditorRef"
v-model="editableText"
class="text-content"
:class="{ 'text-editable': canSave }"
:readonly="!canSave"
:spellcheck="false"
></textarea>
<div v-else class="visual-fallback">
<Icon icon="tabler:file-text" :size="48" style="color: #6b7280" />
<p>{{ t('Preview unavailable') }}</p>
@ -190,6 +198,8 @@ const documentPreviewRef = ref<any>(null)
const spreadsheetPreviewRef = ref<any>(null)
const textContent = ref<string | null>(null)
const textLoading = ref(false)
const editableText = ref('')
const textEditorRef = ref<HTMLTextAreaElement | null>(null)
const canSave = computed(() => EDITABLE_EXTENSIONS.includes((props.row?.file_type || '').toLowerCase()))
const saving = ref(false)
@ -217,6 +227,7 @@ watch(() => props.row, async (row) => {
const fullUrl = /^https?:\/\//.test(url) ? url : window.location.origin + url
const res = await axios.get(fullUrl, { responseType: 'text' })
textContent.value = res.data
editableText.value = res.data
} catch {
textContent.value = null
} finally {
@ -324,6 +335,9 @@ async function handleSave() {
blob = (await documentPreviewRef.value?.saveFile()) ?? null
} else if (['xls', 'xlsx', 'csv'].includes(ext)) {
blob = (await spreadsheetPreviewRef.value?.saveFile()) ?? null
} else if (ext === 'txt') {
const content = editableText.value
blob = new Blob([content], { type: 'text/plain;charset=utf-8' })
}
if (!blob) {
@ -518,6 +532,14 @@ async function handleSave() {
user-select: text;
cursor: text;
flex: 1;
border: none;
outline: none;
resize: none;
}
.text-content.text-editable {
background: #fff;
color: #1f2937;
}
/* ===== 信息面板(可折叠) ===== */

View File

@ -8994,6 +8994,9 @@ msgstr "新建邮箱账户"
msgid "New Event"
msgstr "新建事件"
msgid "New File"
msgstr "新建文件"
msgid "New Folder"
msgstr "新建文件夹"
@ -10845,6 +10848,9 @@ msgstr "生成名称预览"
msgid "Preview type"
msgstr "预览类型"
msgid "Preview unavailable"
msgstr "预览不可用"
msgid "Preview:"
msgstr "预览:"
@ -13455,6 +13461,9 @@ msgstr "垃圾邮件"
msgid "SparkPost"
msgstr "SparkPost服务"
msgid "Spreadsheet"
msgstr "电子表格"
msgid "Special Characters are not allowed"
msgstr "不允许使用特殊字符"
@ -16009,6 +16018,9 @@ msgstr "非活跃站点每天仅运行一次计划任务。设为0可避免自
msgid "With Letter head"
msgstr "带信头"
msgid "Word"
msgstr "文档"
msgid "Worflow States Don't Exist"
msgstr "工作流状态不存在"