Skip to content

Commit e9e5af3

Browse files
committed
fix: 修复在飞牛上选择文件加载的 bug
1 parent e5c9b1f commit e9e5af3

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

frontend/src/App.vue

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<template>
2-
<MonacoEditor v-if="defInfo.path" :path="defInfo.path" :like="like" @like="open = !open" />
2+
<MonacoEditor
3+
v-if="defInfo.path"
4+
:key="defInfo.path"
5+
:path="defInfo.path"
6+
:like="like"
7+
@like="open = !open"
8+
@reset="inputPath"
9+
/>
310

411
<el-dialog v-model="open" title="偏好设置" width="300">
512
<div class="like-dialog">
@@ -68,13 +75,20 @@ const getPath = async (): Promise<string> => {
6875
return query
6976
}
7077
71-
return await ElMessageBox.prompt('部分文件可在文件管理中双击文件进行编辑,详见应用介绍', '请输入文件路径', {
72-
confirmButtonText: '确认',
73-
cancelButtonText: '取消',
74-
}).then(({ value }) => {
78+
return inputPath()
79+
}
80+
81+
const inputPath = async () => {
82+
return await ElMessageBox.prompt(
83+
'部分文件可在文件管理中双击文件进行编辑,详见应用介绍',
84+
'请输入文件路径',
85+
{
86+
confirmButtonText: '确认',
87+
cancelButtonText: '取消',
88+
},
89+
).then(({ value }) => {
7590
if (value) {
76-
window.location.assign(`/?path=${value}`)
77-
return ''
91+
return defInfo.path = value
7892
} else {
7993
return value
8094
}

frontend/src/components/MonacoEditor.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="header">
33
<div class="title">{{ $props.path }}</div>
44

5-
<el-button size="small" @click="resetPath()">修改路径</el-button>
5+
<el-button size="small" @click="$emit('reset')">切换文件</el-button>
66

77
<div style="flex: 1"></div>
88

@@ -72,10 +72,9 @@ import { LANG_OPTIONS, ENCODING_OPTIONS } from '@/utils/option'
7272
import { type LikeModel } from '../hooks/useLike'
7373
import useCode from '../hooks/useCode'
7474
import useEditor from '../hooks/useEditor'
75-
import useReset from '../hooks/useReset'
7675
7776
const $props = defineProps<{ path: string; like: LikeModel }>()
78-
const $emit = defineEmits<{ like: [] }>()
77+
const $emit = defineEmits<{ like: []; reset: [] }>()
7978
8079
watch(
8180
() => $props.like.confirm,
@@ -104,8 +103,6 @@ const { code, save } = useCode({ path: $props.path, confirm: () => editorLike.co
104103
105104
const { editorDidMount, changeLang, changeTheme, changeSize } = useEditor({ onSave: save })
106105
107-
const { resetPath } = useReset({ isDiff: () => code.value !== code.org })
108-
109106
const changeEncode = async (v: string) => {
110107
const buffer = await code.blob.arrayBuffer()
111108
code.org = code.value = iconv.decode(new Uint8Array(buffer), v)

0 commit comments

Comments
 (0)