feat: fix docs
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed, onUnmounted, nextTick } from 'vue'
|
import { ref, onMounted, computed, onUnmounted, nextTick, shallowRef } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
@@ -45,10 +45,23 @@ const showTerminalDialog = ref(false)
|
|||||||
const terminalRef = ref<InstanceType<typeof XTerminal> | null>(null)
|
const terminalRef = ref<InstanceType<typeof XTerminal> | null>(null)
|
||||||
const runCommand = ref('')
|
const runCommand = ref('')
|
||||||
|
|
||||||
|
// Monaco Editor 实例引用
|
||||||
|
const editorRef = shallowRef()
|
||||||
|
|
||||||
// 响应式字体大小
|
// 响应式字体大小
|
||||||
const isSmallScreen = ref(window.innerWidth < 1024)
|
const isSmallScreen = ref(window.innerWidth < 1024)
|
||||||
const editorFontSize = computed(() => isSmallScreen.value ? 12 : 13)
|
const editorFontSize = computed(() => isSmallScreen.value ? 12 : 13)
|
||||||
|
|
||||||
|
// 编辑器挂载时的回调
|
||||||
|
function handleEditorMount(editor: any) {
|
||||||
|
editorRef.value = editor
|
||||||
|
// 强制设置换行符为 LF
|
||||||
|
const model = editor.getModel()
|
||||||
|
if (model) {
|
||||||
|
model.setEOL(0) // 0 = LF, 1 = CRLF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleResize() {
|
function handleResize() {
|
||||||
isSmallScreen.value = window.innerWidth < 1024
|
isSmallScreen.value = window.innerWidth < 1024
|
||||||
}
|
}
|
||||||
@@ -411,11 +424,9 @@ onUnmounted(() => {
|
|||||||
tabSize: 4,
|
tabSize: 4,
|
||||||
insertSpaces: true,
|
insertSpaces: true,
|
||||||
readOnly: !isEditMode,
|
readOnly: !isEditMode,
|
||||||
domReadOnly: !isEditMode,
|
domReadOnly: !isEditMode
|
||||||
files: {
|
|
||||||
eol: '\n'
|
|
||||||
}
|
|
||||||
}"
|
}"
|
||||||
|
@mount="handleEditorMount"
|
||||||
/>
|
/>
|
||||||
<div v-else class="h-full flex items-center justify-center text-muted-foreground text-sm">
|
<div v-else class="h-full flex items-center justify-center text-muted-foreground text-sm">
|
||||||
<span class="lg:hidden">从上方选择文件开始编辑</span>
|
<span class="lg:hidden">从上方选择文件开始编辑</span>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed, shallowRef } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
@@ -31,6 +31,9 @@ const deletePath = ref<string | null>(null)
|
|||||||
const showUnsavedDialog = ref(false)
|
const showUnsavedDialog = ref(false)
|
||||||
const pendingNode = ref<FileNode | null>(null)
|
const pendingNode = ref<FileNode | null>(null)
|
||||||
|
|
||||||
|
// Monaco Editor 实例引用
|
||||||
|
const editorRef = shallowRef()
|
||||||
|
|
||||||
const hasChanges = computed(() => fileContent.value !== originalContent.value)
|
const hasChanges = computed(() => fileContent.value !== originalContent.value)
|
||||||
|
|
||||||
const editorLanguage = computed(() => {
|
const editorLanguage = computed(() => {
|
||||||
@@ -46,6 +49,16 @@ const editorLanguage = computed(() => {
|
|||||||
return 'plaintext'
|
return 'plaintext'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 编辑器挂载时的回调
|
||||||
|
function handleEditorMount(editor: any) {
|
||||||
|
editorRef.value = editor
|
||||||
|
// 强制设置换行符为 LF
|
||||||
|
const model = editor.getModel()
|
||||||
|
if (model) {
|
||||||
|
model.setEOL(0) // 0 = LF, 1 = CRLF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新 URL - 每次清空重建
|
// 更新 URL - 每次清空重建
|
||||||
function updateUrl() {
|
function updateUrl() {
|
||||||
const query: Record<string, string> = {}
|
const query: Record<string, string> = {}
|
||||||
@@ -308,12 +321,10 @@ onMounted(loadTree)
|
|||||||
scrollBeyondLastLine: false,
|
scrollBeyondLastLine: false,
|
||||||
automaticLayout: true,
|
automaticLayout: true,
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
wordWrap: 'on',
|
wordWrap: 'on'
|
||||||
files: {
|
|
||||||
eol: '\n'
|
|
||||||
}
|
|
||||||
}"
|
}"
|
||||||
style="height: 100%"
|
style="height: 100%"
|
||||||
|
@mount="handleEditorMount"
|
||||||
/>
|
/>
|
||||||
<div v-else class="h-full flex items-center justify-center text-muted-foreground text-sm">
|
<div v-else class="h-full flex items-center justify-center text-muted-foreground text-sm">
|
||||||
选择一个文件开始编辑
|
选择一个文件开始编辑
|
||||||
|
|||||||
Reference in New Issue
Block a user