feat(web): 添加写入heroSet.ts的功能按钮和逻辑
新增了写入heroSet.ts的操作按钮,添加了二次确认弹窗和后端写入接口调用逻辑,支持将当前英雄数据覆盖写入到指定配置文件的对应区域。
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<el-button size="small" @click="refreshMeta" :loading="loadingMeta">刷新配置数据</el-button>
|
||||
<el-button size="small" type="success" @click="doSave" :disabled="!heroes.length">保存到服务器</el-button>
|
||||
<el-button size="small" type="warning" @click="doExport" :disabled="!heroes.length">导出 hexport.ts</el-button>
|
||||
<el-button size="small" type="primary" @click="doApply" :disabled="!heroes.length">写入 heroSet.ts</el-button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="hero-main">
|
||||
@@ -288,6 +289,22 @@ async function doExport() {
|
||||
}
|
||||
}
|
||||
|
||||
async function doApply() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`将用 ${heroes.value.length} 个英雄直接覆盖 heroSet.ts 的英雄配置区域(@hero-setup:heroes-begin/end 标记之间),怪物配置不受影响。`,
|
||||
'写入确认',
|
||||
{ confirmButtonText: '覆盖写入', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
} catch { return }
|
||||
try {
|
||||
const r = await api.applyHeroes(heroes.value)
|
||||
ElMessage.success(`已写入 ${r.count} 个英雄 → ${r.path}`)
|
||||
} catch (e) {
|
||||
ElMessage.error('写入失败: ' + (e?.response?.data?.error || e.message))
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadMeta()
|
||||
loadHeroes()
|
||||
|
||||
Reference in New Issue
Block a user