提交
This commit is contained in:
52
src/components/FileUploader.vue
Normal file
52
src/components/FileUploader.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<label>
|
||||
上传 Weapon.xml:
|
||||
<input type="file" @change="onWeaponFileChange" />
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
上传单位 XML(如 AlliedAntiInfantryInfantry.xml):
|
||||
<input type="file" @change="onUnitFileChange" />
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const emit = defineEmits(['updateWeaponTemplates', 'updateUnitDoc'])
|
||||
|
||||
const onWeaponFileChange = (e) => {
|
||||
const file = e.target.files[0]
|
||||
if (!file) return
|
||||
|
||||
const reader = new FileReader()
|
||||
reader.onload = (event) => {
|
||||
const parser = new DOMParser()
|
||||
const xml = parser.parseFromString(event.target.result, 'text/xml')
|
||||
const templates = xml.querySelectorAll('WeaponTemplate')
|
||||
const ids = new Set()
|
||||
templates.forEach((t) => {
|
||||
const id = t.getAttribute('id')
|
||||
if (id) ids.add(id)
|
||||
})
|
||||
emit('updateWeaponTemplates', ids)
|
||||
}
|
||||
reader.readAsText(file)
|
||||
}
|
||||
|
||||
const onUnitFileChange = (e) => {
|
||||
const file = e.target.files[0]
|
||||
if (!file) return
|
||||
|
||||
const reader = new FileReader()
|
||||
reader.onload = (event) => {
|
||||
const parser = new DOMParser()
|
||||
const xml = parser.parseFromString(event.target.result, 'text/xml')
|
||||
emit('updateUnitDoc', xml)
|
||||
}
|
||||
reader.readAsText(file)
|
||||
}
|
||||
</script>
|
||||
|
||||
26
src/components/MatchResultTable.vue
Normal file
26
src/components/MatchResultTable.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>GameObject id</th>
|
||||
<th>匹配到的 WeaponTemplate</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(result, index) in matchResults" :key="index">
|
||||
<td>{{ result.goId }}</td>
|
||||
<td>{{ result.templates.length > 0 ? result.templates.join(', ') : 'None' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineProps({
|
||||
matchResults: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
11
src/components/index.vue
Normal file
11
src/components/index.vue
Normal file
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user