From a2534bce96644bae89c67cb0e7ac94a56c0fa6b0 Mon Sep 17 00:00:00 2001 From: sd <1504629600@qq.com> Date: Mon, 2 Feb 2026 10:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E7=9F=A5bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/public/stepEditor.html | 612 +++++++++++++++++++++ ruoyi-ui/src/views/childRoom/BottomLeftPanel.vue | 20 +- ruoyi-ui/src/views/childRoom/StepEditor.vue | 75 ++- ruoyi-ui/src/views/childRoom/TopHeader.vue | 8 +- ruoyi-ui/src/views/childRoom/index.vue | 1 + ruoyi-ui/src/views/dialogs/OnlineMembersDialog.vue | 1 + 6 files changed, 701 insertions(+), 16 deletions(-) create mode 100644 ruoyi-ui/public/stepEditor.html diff --git a/ruoyi-ui/public/stepEditor.html b/ruoyi-ui/public/stepEditor.html new file mode 100644 index 0000000..8c2e600 --- /dev/null +++ b/ruoyi-ui/public/stepEditor.html @@ -0,0 +1,612 @@ + + + + + + 六步法编辑器 + + + + +
+
+
+
+ + 关闭 + + {{ stepTitle }} +
+
+ + + 保存 + +
+
+ +
+
+ + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ + + B + + + + + I + + + + + U + + + + + S + + +
+ +
+ +
+ + + + + + + + x₂ + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + +
+ {{ wordCount }} 字 +
+
+
+ +
+
+
+
+ + +
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-ui/src/views/childRoom/BottomLeftPanel.vue b/ruoyi-ui/src/views/childRoom/BottomLeftPanel.vue index 8d1ee82..5e4db4e 100644 --- a/ruoyi-ui/src/views/childRoom/BottomLeftPanel.vue +++ b/ruoyi-ui/src/views/childRoom/BottomLeftPanel.vue @@ -90,19 +90,25 @@ export default { this.showPanel = true }, selectStep(index) { + const clickedStep = this.sixStepsData[index] + + if (clickedStep.completed && !clickedStep.active) { + this.sixStepsData.forEach((step, i) => { + if (i >= index) { + step.completed = false + } + }) + } + this.sixStepsData.forEach((step, i) => { step.active = i === index if (i < index) { step.completed = true } }) - this.$router.push({ - path: '/stepEditor', - query: { - title: this.sixStepsData[index].title, - index: index - } - }) + + const url = `/stepEditor.html?title=${encodeURIComponent(this.sixStepsData[index].title)}&index=${index}` + window.open(url, '_blank') } } } diff --git a/ruoyi-ui/src/views/childRoom/StepEditor.vue b/ruoyi-ui/src/views/childRoom/StepEditor.vue index fd549c6..14783af 100644 --- a/ruoyi-ui/src/views/childRoom/StepEditor.vue +++ b/ruoyi-ui/src/views/childRoom/StepEditor.vue @@ -198,7 +198,7 @@ export default { }, methods: { goBack() { - this.$router.go(-1) + this.$router.push('/childRoom') }, formatText(command) { document.execCommand(command, false, null) @@ -206,7 +206,7 @@ export default { }, importDocument() { this.uploadType = 'document' - this.$refs.fileInput.accept = '.txt,.doc,.docx,.md' + this.$refs.fileInput.accept = '.txt,.md,.docx' this.$refs.fileInput.click() }, importImage() { @@ -227,13 +227,78 @@ export default { event.target.value = '' }, handleDocumentUpload(file) { + const fileName = file.name.toLowerCase() + const fileExt = fileName.substring(fileName.lastIndexOf('.')) + + if (fileExt === '.docx') { + this.handleDocxUpload(file) + } else if (fileExt === '.txt' || fileExt === '.md') { + this.handleTextFileUpload(file) + } else { + this.$message.warning('不支持的文件格式,请使用 .txt、.md 或 .docx 文件') + } + }, + handleDocxUpload(file) { + this.$message.warning('正在解析 Word 文档...') const reader = new FileReader() reader.onload = (e) => { - const text = e.target.result + try { + const arrayBuffer = e.target.result + this.parseDocx(arrayBuffer) + } catch (error) { + console.error('解析 Word 文档失败:', error) + this.$message.error('解析 Word 文档失败,请将文档另存为 .txt 或 .md 格式后重试') + } + } + reader.readAsArrayBuffer(file) + }, + async parseDocx(arrayBuffer) { + try { + const mammoth = await import('mammoth') + const result = await mammoth.extractRawText({ arrayBuffer: arrayBuffer }) + const text = result.value this.insertText(text) - this.$message.success('文档导入成功') + this.$message.success('Word 文档导入成功') + } catch (error) { + console.error('mammoth.js 加载失败:', error) + this.$message.error('需要安装 mammoth.js 库才能解析 Word 文档,请运行: npm install mammoth') + } + }, + handleTextFileUpload(file) { + const reader = new FileReader() + reader.onload = (e) => { + let text = e.target.result + + if (!text || text.trim() === '') { + this.$message.warning('文档内容为空') + return + } + + if (this.isGarbled(text)) { + this.tryGBKEncoding(file) + } else { + this.insertText(text) + this.$message.success('文档导入成功') + } + } + reader.readAsText(file, 'UTF-8') + }, + isGarbled(text) { + const garbageChars = text.match(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g) + return garbageChars && garbageChars.length > text.length * 0.3 + }, + tryGBKEncoding(file) { + const reader = new FileReader() + reader.onload = (e) => { + const text = e.target.result + if (this.isGarbled(text)) { + this.$message.error('文档编码无法识别,请确保文档使用 UTF-8 或 GBK 编码') + } else { + this.insertText(text) + this.$message.success('文档导入成功') + } } - reader.readAsText(file) + reader.readAsText(file, 'GBK') }, handleImageUpload(file) { const reader = new FileReader() diff --git a/ruoyi-ui/src/views/childRoom/TopHeader.vue b/ruoyi-ui/src/views/childRoom/TopHeader.vue index fb9837e..2443238 100644 --- a/ruoyi-ui/src/views/childRoom/TopHeader.vue +++ b/ruoyi-ui/src/views/childRoom/TopHeader.vue @@ -315,6 +315,10 @@ export default { userAvatar: { type: String, default: 'https://cube.elemecdn.com/0/88dd03f9bf287d08f58fbcf58fddbf4a8c6/avatar.png' + }, + isIconEditMode: { + type: Boolean, + default: false } }, data() { @@ -326,7 +330,6 @@ export default { currentScale: {}, externalParamsDialogVisible: false, currentExternalParams: {}, - isIconEditMode: false, is2DMode: true, isRulerVisible: true, isAirportVisible: true, @@ -364,7 +367,6 @@ export default { // 文件下拉菜单方法 savePlan() { if (this.isIconEditMode) { - this.isIconEditMode = false this.$emit('toggle-icon-edit', false) } else { this.$emit('save-plan') @@ -406,10 +408,8 @@ export default { iconEdit() { if (this.isIconEditMode) { - this.isIconEditMode = false this.$emit('toggle-icon-edit', false) } else { - this.isIconEditMode = true this.$emit('toggle-icon-edit', true) } }, diff --git a/ruoyi-ui/src/views/childRoom/index.vue b/ruoyi-ui/src/views/childRoom/index.vue index 8b04a9f..3b0f38b 100644 --- a/ruoyi-ui/src/views/childRoom/index.vue +++ b/ruoyi-ui/src/views/childRoom/index.vue @@ -30,6 +30,7 @@ :combat-time="combatTime" :astro-time="astroTime" :user-avatar="userAvatar" + :is-icon-edit-mode="isIconEditMode" @select-nav="selectTopNav" @save-plan="savePlan" @import-plan-file="importPlanFile" diff --git a/ruoyi-ui/src/views/dialogs/OnlineMembersDialog.vue b/ruoyi-ui/src/views/dialogs/OnlineMembersDialog.vue index ee5b1be..b5216c6 100644 --- a/ruoyi-ui/src/views/dialogs/OnlineMembersDialog.vue +++ b/ruoyi-ui/src/views/dialogs/OnlineMembersDialog.vue @@ -102,6 +102,7 @@ :visible.sync="showRollbackDialog" width="400px" center + append-to-body >

{{ $t('onlineMembersDialog.rollbackConfirmText') }}