diff --git a/src/views/model/list/ModelCard.vue b/src/views/model/list/ModelCard.vue index e828e6d..93d0b3d 100644 --- a/src/views/model/list/ModelCard.vue +++ b/src/views/model/list/ModelCard.vue @@ -37,14 +37,26 @@ const modelCardList = ref>([]) const lastQuery = ref(null) const colors = ['#8dc63f', '#dbb09e'] const statusStr = ['未下装', '已下装'] -const icons = ['material-symbols:lock-open-right-outline', 'material-symbols:lock-outline'] +const statusIcons = ['material-symbols:lock-open', 'material-symbols:lock'] -const buildQuery = (value: any): ModelQueryParams => ({ - unitId: value?.unit, - typeId: value?.type, - systemId: value?.system, - name: value?.name, -}) +function colorToBg(hex: string, alpha = 0.5) { + const raw = (hex || '').replace('#', '') + if (raw.length !== 6) + return 'rgba(0,0,0,0.5)' + const r = Number.parseInt(raw.slice(0, 2), 16) + const g = Number.parseInt(raw.slice(2, 4), 16) + const b = Number.parseInt(raw.slice(4, 6), 16) + return `rgba(${r}, ${g}, ${b}, ${alpha})` +} + +function buildQuery(value: any): ModelQueryParams { + return { + unitId: value?.unit, + typeId: value?.type, + systemId: value?.system, + name: value?.name, + } +} async function loadModelList(value: any) { const queryParams = buildQuery(value) @@ -61,7 +73,7 @@ async function loadModelList(value: any) { id: modelCard.id, title: modelCard.name, version: modelCard.version, - icon: icons[statusIndex], + icon: statusIcons[statusIndex], value: 1, total: 1, color: colors[statusIndex], @@ -69,14 +81,10 @@ async function loadModelList(value: any) { creator: modelCard.creator, createTime: modelCard.createTime, description: modelCard.name, - headStyle: { - backgroundColor: colors[statusIndex], - fontSize: '20px', - }, - bodyStyle: { - borderColor: colors[statusIndex], - borderWidth: '1px', - }, + headStyle: {}, + bodyStyle: {}, + statusColor: colors[statusIndex], + cardBg: colorToBg(colors[statusIndex]), } cardList.push(card) } @@ -100,23 +108,40 @@ async function confirmDelete(id: number | string) {