游戏-游戏配置-优化样式

This commit is contained in:
2026-04-02 11:06:21 +08:00
parent 9786dab979
commit c602c0d67d
3 changed files with 101 additions and 0 deletions

View File

@@ -95,4 +95,8 @@ return [
'%d records and files have been deleted' => '%d records and files have been deleted',
'Please input correct username' => 'Please enter the correct username',
'Group Name Arr' => 'Group Name Arr',
'Game config weight keys cannot be modified' => 'Weight config keys cannot be modified',
'Game config weight value must be numeric' => 'Weight values must be numeric',
'Game config weight each value must not exceed 100' => 'Each weight value must not exceed 100',
'Game config weight sum must equal 100' => 'The sum of weights for default_tier_weight / default_kill_score_weight must equal 100',
];

View File

@@ -114,4 +114,8 @@ return [
'%d records and files have been deleted' => '已删除%d条记录和文件',
'Please input correct username' => '请输入正确的用户名',
'Group Name Arr' => '分组名称数组',
'Game config weight keys cannot be modified' => '权重配置的键不可修改',
'Game config weight value must be numeric' => '权重值必须为数字',
'Game config weight each value must not exceed 100' => '每项权重不能超过100',
'Game config weight sum must equal 100' => 'default_tier_weight / default_kill_score_weight 的权重之和必须等于100',
];

View File

@@ -0,0 +1,93 @@
<template>
<div v-if="isGameWeight && weightTagLabels.length" class="game-config-value-tags">
<el-tag
v-for="(label, idx) in weightTagLabels"
:key="idx"
class="m-4"
effect="light"
type="primary"
size="default"
>
{{ label }}
</el-tag>
</div>
<span v-else class="game-config-value-plain">{{ plainText }}</span>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps<{
renderRow: TableRow
renderField: TableColumn
renderValue: unknown
renderColumn: import('element-plus').TableColumnCtx<TableRow>
renderIndex: number
}>()
const isGameWeight = computed(() => props.renderRow?.group === 'game_weight')
/**
* value 形如 [{"T1":"5"},{"T2":"20"},...] 或同结构的 JSON 字符串
*/
function parseWeightTagLabels(raw: unknown): string[] {
if (raw === null || raw === undefined || raw === '') {
return []
}
let arr: unknown[] = []
if (typeof raw === 'string') {
const s = raw.trim()
if (!s) return []
try {
const parsed = JSON.parse(s)
arr = Array.isArray(parsed) ? parsed : []
} catch {
return []
}
} else if (Array.isArray(raw)) {
arr = raw
} else {
return []
}
const labels: string[] = []
for (const item of arr) {
if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
for (const [k, v] of Object.entries(item as Record<string, unknown>)) {
labels.push(`${k}:${String(v)}`)
}
}
}
return labels
}
const weightTagLabels = computed(() => parseWeightTagLabels(props.renderValue))
const plainText = computed(() => {
const v = props.renderValue
if (v === null || v === undefined) return ''
if (typeof v === 'object') {
try {
return JSON.stringify(v)
} catch {
return String(v)
}
}
return String(v)
})
</script>
<style scoped lang="scss">
.game-config-value-tags {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 4px 0;
}
.m-4 {
margin: 4px;
}
.game-config-value-plain {
word-break: break-all;
}
</style>