feat: 新增预设库管理与一键创建英雄向导
1. 新增服务端模板持久化接口,支持触发/光环预设的读写 2. 前端新增预设库管理页面,支持增删改查触发/光环预设 3. 新增英雄创建向导,支持按职业快速生成英雄并套用预设 4. 调整本地开发端口与代理地址 5. 补充职业默认配置与攻速映射等常量定义
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
<header class="hero-header">
|
||||
<h1>英雄配置编辑器</h1>
|
||||
<div class="actions">
|
||||
<el-radio-group v-model="view" size="small">
|
||||
<el-radio-button value="heroes">英雄列表</el-radio-button>
|
||||
<el-radio-button value="templates">预设库</el-radio-button>
|
||||
</el-radio-group>
|
||||
<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="primary" @click="doApply" :disabled="!heroes.length">写入 heroSet.ts</el-button>
|
||||
@@ -10,6 +14,17 @@
|
||||
</div>
|
||||
</header>
|
||||
<div class="hero-main">
|
||||
<!-- 预设库视图 -->
|
||||
<TemplateManager
|
||||
v-if="view === 'templates'"
|
||||
:trigger-presets="triggerPresets"
|
||||
:field-presets="fieldPresets"
|
||||
:skill-options="allSkills"
|
||||
:skill-map="skillMap"
|
||||
:field-options="fieldOptions"
|
||||
:buff-options="buffOptions"
|
||||
/>
|
||||
<template v-else>
|
||||
<!-- 首页:英雄卡片列表 -->
|
||||
<div class="home-toolbar">
|
||||
<span class="muted">共 {{ heroes.length }} 个英雄</span>
|
||||
@@ -188,6 +203,17 @@
|
||||
<el-button size="small" @click="editVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 新建英雄向导 -->
|
||||
<HeroWizard
|
||||
v-model:visible="wizardVisible"
|
||||
:heroes="heroes"
|
||||
:skill-map="skillMap"
|
||||
:trigger-presets="triggerPresets"
|
||||
:field-presets="fieldPresets"
|
||||
@confirm="onWizardCreate"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -199,17 +225,26 @@ import { api } from './api'
|
||||
import {
|
||||
HERO_ROLES, GROW_TYPES, H_TYPES,
|
||||
ROLE_ATK_SKILL, ROLE_ULT_SKILL, SUPPORT_ULT,
|
||||
defaultHero, defaultSkill,
|
||||
defaultSkill,
|
||||
} from './constants'
|
||||
import SkillEditor from './components/SkillEditor.vue'
|
||||
import TriggerGroupEditor from './components/TriggerGroupEditor.vue'
|
||||
import FieldEditor from './components/FieldEditor.vue'
|
||||
import BonusEditor from './components/BonusEditor.vue'
|
||||
import HeroWizard from './components/HeroWizard.vue'
|
||||
import TemplateManager from './components/TemplateManager.vue'
|
||||
|
||||
const heroes = ref([])
|
||||
// 预设库(跨职业复用资产,与职业默认解耦)
|
||||
const triggerPresets = ref([])
|
||||
const fieldPresets = ref([])
|
||||
const activeIdx = ref(-1)
|
||||
const meta = ref(null)
|
||||
const loadingMeta = ref(false)
|
||||
// 视图切换:heroes 英雄列表 / templates 模板管理
|
||||
const view = ref('heroes')
|
||||
// 新建英雄向导可见性
|
||||
const wizardVisible = ref(false)
|
||||
// 编辑弹窗可见性:首页卡片点「修改/新建」打开,关闭仅收起不丢数据
|
||||
const editVisible = ref(false)
|
||||
|
||||
@@ -389,13 +424,13 @@ function openEdit(i) {
|
||||
activeIdx.value = i
|
||||
editVisible.value = true
|
||||
}
|
||||
// 「+ 新建英雄」改为打开向导:选职业/技能底座/勾选模板预设,一键生成完整英雄
|
||||
function addHero() {
|
||||
const nh = defaultHero()
|
||||
const used = new Set(heroes.value.map((h) => h.uuid))
|
||||
let uuid = 5001
|
||||
while (used.has(uuid)) uuid++
|
||||
nh.uuid = uuid
|
||||
heroes.value.push(nh)
|
||||
wizardVisible.value = true
|
||||
}
|
||||
// 向导创建完成:追加到列表并打开编辑弹窗微调
|
||||
function onWizardCreate(h) {
|
||||
heroes.value.push(h)
|
||||
openEdit(heroes.value.length - 1)
|
||||
}
|
||||
function removeHero(i) {
|
||||
@@ -448,6 +483,16 @@ async function loadHeroes() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTemplates() {
|
||||
try {
|
||||
const r = await api.fetchTemplates()
|
||||
triggerPresets.value = Array.isArray(r.triggerPresets) ? r.triggerPresets : []
|
||||
fieldPresets.value = Array.isArray(r.fieldPresets) ? r.fieldPresets : []
|
||||
} catch (e) {
|
||||
ElMessage.error('加载预设库失败: ' + (e?.response?.data?.error || e.message))
|
||||
}
|
||||
}
|
||||
|
||||
async function doSave() {
|
||||
try {
|
||||
const r = await api.saveHeroes(heroes.value)
|
||||
@@ -492,5 +537,6 @@ async function doExportCsv() {
|
||||
onMounted(() => {
|
||||
loadMeta()
|
||||
loadHeroes()
|
||||
loadTemplates()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user