feat(web+server): 新增枚举覆写支持与CSV导出功能
1. 新增buff_target枚举覆写配置,支持选择施法目标类型 2. 后端添加CSV导出接口,生成标准化英雄设计表 3. 前端新增CSV导出按钮,支持一键导出配置 4. 优化覆写字段渲染逻辑,支持枚举值转可读枚举名 5. 清理英雄数据中冗余的summon_count默认配置
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
<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>
|
||||
<el-button size="small" type="danger" @click="doExportCsv" :disabled="!heroes.length">导出英雄设计表.csv</el-button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="hero-main">
|
||||
@@ -406,6 +407,22 @@ async function doApply() {
|
||||
}
|
||||
}
|
||||
|
||||
async function doExportCsv() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`将用 ${heroes.value.length} 个英雄覆盖写入 assets/script/game/common/config/英雄设计表.csv`,
|
||||
'导出确认',
|
||||
{ confirmButtonText: '覆盖写入', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
} catch { return }
|
||||
try {
|
||||
const r = await api.exportCsv(heroes.value)
|
||||
ElMessage.success(`已写入 ${r.count} 个英雄 → ${r.path}`)
|
||||
} catch (e) {
|
||||
ElMessage.error('导出失败: ' + (e?.response?.data?.error || e.message))
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadMeta()
|
||||
loadHeroes()
|
||||
|
||||
@@ -7,5 +7,6 @@ export const api = {
|
||||
saveHeroes: (heroes) => axios.post('/api/heroes', { heroes }).then((r) => r.data),
|
||||
exportHeroes: (heroes) => axios.post('/api/export', { heroes }).then((r) => r.data),
|
||||
applyHeroes: (heroes) => axios.post('/api/apply', { heroes }).then((r) => r.data),
|
||||
exportCsv: (heroes) => axios.post('/api/export-csv', { heroes }).then((r) => r.data),
|
||||
fetchExport: () => axios.get('/api/export', { responseType: 'text' }).then((r) => r.data),
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@ function isStringKey(key) {
|
||||
return OVERRIDE_KEYS.find((k) => k.key === key)?.type === 'string'
|
||||
}
|
||||
|
||||
// 该覆写字段为枚举型时返回候选列表(如 buff_target),否则返回 null 走数值输入
|
||||
function enumOptions(key) {
|
||||
const def = OVERRIDE_KEYS.find((k) => k.key === key)
|
||||
return def?.type === 'enum' ? def.options : null
|
||||
}
|
||||
|
||||
function add() {
|
||||
rows.value.push({ key: '', value: 0 })
|
||||
}
|
||||
|
||||
@@ -112,6 +112,13 @@ export const OVERRIDE_KEYS = [
|
||||
{ key: 'buff_value', label: 'buff_value 修饰数值' },
|
||||
{ key: 'buff_duration', label: 'buff_duration 持续时间' },
|
||||
{ key: 'buff_chance', label: 'buff_chance 附加概率' },
|
||||
// 枚举型覆写:计时 buff 施加目标(缺省跟随技能主效果目标,见 SkillSet.BuffTarget)
|
||||
{ key: 'buff_target', label: 'buff_target buff施加目标', type: 'enum', options: [
|
||||
{ value: 0, label: '0 被命中者(Hit/默认)' },
|
||||
{ value: 1, label: '1 施法者自身(Self)' },
|
||||
{ value: 2, label: '2 全体友方(Ally)' },
|
||||
{ value: 3, label: '3 全体敌方(Enemy)' },
|
||||
]},
|
||||
{ key: 'summon_count', label: 'summon_count 召唤数' },
|
||||
{ key: 'num', label: 'num 额外释放次数' },
|
||||
{ key: 'call_hero', label: 'call_hero 召唤英雄id' },
|
||||
|
||||
Reference in New Issue
Block a user