fix(strategy): 编辑器加载文件误标未保存(code程序化赋值触发watch置dirty,运行回测被拦);select后nextTick复位 [nas]
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import { ref, computed, onMounted, watch, nextTick } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import MonacoEditor from '@/components/MonacoEditor.vue'
|
||||
@@ -61,8 +61,13 @@ async function select(f: StrategyFile): Promise<void> {
|
||||
try {
|
||||
const { data } = await apiClient.get<{ code: string }>(`/strategy/file/${f.name}`)
|
||||
code.value = data.code
|
||||
// 程序化赋值会触发 watch(code) 误标 dirty → 渲染后复位
|
||||
await nextTick()
|
||||
dirty.value = false
|
||||
} catch {
|
||||
code.value = ''
|
||||
await nextTick()
|
||||
dirty.value = false
|
||||
ElMessage.error(`读取 ${f.name} 失败`)
|
||||
} finally {
|
||||
loadingCode.value = false
|
||||
|
||||
Reference in New Issue
Block a user