gpt-4.1-mini-2025-04-14· OpenAI
LMArena Human Preference 140K
template> <v-card variant="outlined" class="mb-4"> <v-card-title>{{…
- User
template> {{ projectConfig?.projectName }} {{ projectSlug }} {{ projectConfig?.description }} 实验组: {{ group.name }} No logical groups defined.
<!-- Display Physical Sources --> <template v-if="projectConfig?.physicalSources && projectConfig.physicalSources.length > 0"> <strong>数据采集设备:</strong> <v-list density="compact"> <v-list-item v-for="source in projectConfig.physicalSources" :key="source.id"> <template v-slot:prepend> <v-icon :color="getSourceColor(source.type)">{{ getSourceIcon(source.type) }}</v-icon> </template> <v-list-item-title>{{ source.name }} ({{ source.description }})</v-list-item-title> <v-list-item-subtitle>类型: {{ source.type }}</v-list-item-subtitle> <v-list-item-subtitle style="margin-top: 5px;"> 采集: <template v-if="source.associatedLogicalGroups && source.associatedLogicalGroups.length > 0"> <v-chip size="x-small" label class="ml-1" v-for="groupSlug in source.associatedLogicalGroups" :key="groupSlug"> {{ getGroupName(groupSlug) }} </v-chip> </template> <span v-else class="text-medium-emphasis text-caption ml-1">None</span> </v-list-item-subtitle> </v-list-item> </v-list> </template> <p v-else-if="projectConfig" class="text-medium-emphasis text-caption">No physical sources defined.</p>重构我的代码,让标题居中放大,描述现代段落样式。实验组卡片,标题和描述(手机竖排,电脑横排)。采集设备折叠并放在后面
- Assistant
你想要对现有的 Vuetify 代码进行重构,主要需求是:
- 标题居中且放大
- 描述使用现代段落样式
- 实验组卡片在手机竖排、电脑横排显示(响应式布局)
- 采集设备折叠起来,默认收起,放在后面
下面是基于你原代码的重构示例,满足以上需求:
<template> <v-card variant="outlined" class="mb-4 pa-4"> <!-- 标题居中放大 --> <v-card-title class="title-center"> {{ projectConfig?.projectName }} </v-card-title> <!-- 副标题居中 --> <v-card-subtitle class="subtitle-center"> {{ projectSlug }} </v-card-subtitle> <!-- 描述,现代段落样式 --> <v-card-text> <p class="modern-paragraph">{{ projectConfig?.description }}</p> </v-card-text> <v-divider class="my-4"></v-divider> <!-- 实验组卡片,响应式布局 --> <template v-if="projectConfig?.logicalGroups && projectConfig.logicalGroups.length > 0"> <strong class="mb-2 d-block">实验组:</strong> <v-row class="logical-groups-row" :class="$vuetify.breakpoint.smAndDown ? 'flex-column' : 'flex-row'" align="center" justify="start" dense > <v-col v-for="group in projectConfig.logicalGroups" :key="group.slug" cols="auto" class="d-flex flex-column align-center pa-2" style="min-width: 120px;" > <v-chip label size="small" class="mb-1" color="primary" text-color="white"> {{ group.name }} </v-chip> <small class="text-caption text-center">{{ group.description || '无描述' }}</small> </v-col> </v-row> </template> <p v-else-if="projectConfig" class="text-medium-emphasis text-caption">No logical groups defined.</p> <v-divider class="my-4"></v-divider> <!-- 采集设备折叠面板 --> <v-expansion-panels> <v-expansion-panel> <v-expansion-panel-title> <strong>数据采集设备</strong> </v-expansion-panel-title> <v-expansion-panel-text> <template v-if="projectConfig?.physicalSources && projectConfig.physicalSources.length > 0"> <v-list density="compact"> <v-list-item v-for="source in projectConfig.physicalSources" :key="source.id"> <template v-slot:prepend> <v-icon :color="getSourceColor(source.type)">{{ getSourceIcon(source.type) }}</v-icon> </template> <v-list-item-content> <v-list-item-title>{{ source.name }} ({{ source.description }})</v-list-item-title> <v-list-item-subtitle>类型: {{ source.type }}</v-list-item-subtitle> <v-list-item-subtitle class="mt-1"> 采集: <template v-if="source.associatedLogicalGroups && source.associatedLogicalGroups.length > 0"> <v-chip size="x-small" label class="ml-1" v-for="groupSlug in source.associatedLogicalGroups" :key="groupSlug" > {{ getGroupName(groupSlug) }} </v-chip> </template> <span v-else class="text-medium-emphasis text-caption ml-1">None</span> </v-list-item-subtitle> </v-list-item-content> </v-list-item> </v-list> </template> <p v-else class="text-medium-emphasis text-caption">No physical sources defined.</p> </v-expansion-panel-text> </v-expansion-panel> </v-expansion-panels> </v-card> </template> <script setup> import { defineProps } from 'vue'; const props = defineProps({ projectConfig: { type: Object, required: true, default: () => ({}), }, projectSlug: { type: String, required: true, }, }); // Helper functions const getGroupName = (slug) => { if (!props.projectConfig || !props.projectConfig.logicalGroups) return slug; return props.projectConfig.logicalGroups.find((g) => g.slug === slug)?.name || slug; }; const getSourceIcon = (type) => { return { camera: 'mdi-camera', hotimage: 'mdi-thermometer-lines', intensity: 'mdi-lightbulb-on-outline', tempRH: 'mdi-water-percent', }[type] || 'mdi-help-circle-outline'; }; const getSourceColor = (type) => { return { camera: 'blue', hotimage: 'red', intensity: 'orange', tempRH: 'teal', }[type] || 'grey'; }; </script> <style scoped> .title-center { text-align: center; font-size: 2rem; font-weight: 700; line-height: 1.2; margin-bottom: 0.25rem; } .subtitle-center { text-align: center; font-size: 1.25rem; color: var(--v-theme-on-surface-variant); margin-bottom: 1rem; } .modern-paragraph { font-size: 1rem; line-height: 1.6; color: var(--v-theme-on-surface); margin-bottom: 1.5rem; white-space: pre-line; /* 保持换行 */ } /* 响应式逻辑组布局 */ .logical-groups-row.flex-column { flex-direction: column !important; } .logical-groups-row.flex-row { flex-direction: row !important; } /* 文字强调样式 */ .text-medium-emphasis { color: rgba(var(--v-theme-on-surface), 0.6); } .text-caption { font-size: 0.75rem !important; font-weight: 400; line-height: 1.25rem; letter-spacing: 0.033em !important; text-transform: none !important; } </style>
说明
- 标题居中放大:用
.title-center类设置字体大小、加粗和居中。 - 副标题居中:
.subtitle-center类,颜色使用 Vuetify 主题变量。 - 描述段落:
.modern-paragraph,字体大小适中,行高舒适,支持换行。 - 实验组卡片响应式布局:
- 使用
<v-row>+<v-col>,根据屏幕宽度切换flex-direction,手机竖排,电脑横排。 - 每个实验组显示一个
v-chip和下面的描述(如果有)。
- 使用
- 采集设备折叠:
- 使用
<v-expansion-panels>包裹采集设备列表,默认折叠。 - 点击标题展开详细设备列表。
- 使用
- 样式:使用 scoped CSS,利用 Vuetify 主题变量保证风格统一。
你可以根据需要调整颜色、间距等细节。这样重构后,界面更现代且响应式,用户体验更好。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.