Skip to content

Commit 5f85a52

Browse files
committed
feat(LogoMarquee): 支持自定义企业图标和名称显示
- 实现 customIcon 图片显示逻辑,支持图片和 SVG 图标两种格式 - 添加 company-name 文本标签展示企业简称 - 优化 logo-item 样式布局,使用 flex 布局并设置间距 - 新增企业案例数据文件,包含比亚迪、顺丰科技等6家企业信息 - 实现图标类型映射功能,支持传感器、农业、数据等多种行业图标 - 添加鼠标悬停效果,提升用户体验
1 parent 841dd09 commit 5f85a52

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

pages/public/user_byd.jpg

34.3 KB
Loading

pages/src/components/LogoMarquee.astro

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ import { userCompanies, getIconSvg } from '../data/users';
1212
<div class="marquee-content">
1313
{userCompanies.map((company) => (
1414
<div class="logo-item" title={company.fullName}>
15-
<svg viewBox="0 0 200 40" fill="currentColor" class="company-logo" set:html={getIconSvg(company.iconType) + `<text x="45" y="26" font-size="12" font-weight="600">${company.name}</text>`} />
15+
{company.customIcon&&<><img src={company.customIcon} alt={company.fullName} /><span class="company-name">{company.name}</span></>}
16+
{!company.customIcon&&<svg viewBox="0 0 200 40" fill="currentColor" class="company-logo" set:html={getIconSvg(company.iconType) + `<text x="45" y="26" font-size="12" font-weight="600">${company.name}</text>`} />}
1617
</div>
1718
))}
1819
</div>
19-
20+
2021
<!-- 复制一组实现无缝滚动 -->
2122
<div class="marquee-content" aria-hidden="true">
2223
{userCompanies.map((company) => (
2324
<div class="logo-item" title={company.fullName}>
24-
<svg viewBox="0 0 200 40" fill="currentColor" class="company-logo" set:html={getIconSvg(company.iconType) + `<text x="45" y="26" font-size="12" font-weight="600">${company.name}</text>`} />
25+
{company.customIcon&&<><img src={company.customIcon} alt={company.fullName} /><span class="company-name">{company.name}</span></>}
26+
27+
{!company.customIcon&&<svg viewBox="0 0 200 40" fill="currentColor" class="company-logo" set:html={getIconSvg(company.iconType) + `<text x="45" y="26" font-size="12" font-weight="600">${company.name}</text>`} />}
2528
</div>
2629
))}
2730
</div>
@@ -97,6 +100,9 @@ import { userCompanies, getIconSvg } from '../data/users';
97100
opacity: 0.6;
98101
transition: all 0.3s ease;
99102
cursor: default;
103+
display: flex;
104+
align-items: center;
105+
gap: 12px;
100106
}
101107

102108
.logo-item:hover {
@@ -122,6 +128,18 @@ import { userCompanies, getIconSvg } from '../data/users';
122128
object-fit: contain;
123129
}
124130

131+
.logo-item .company-name {
132+
font-size: 14px;
133+
font-weight: 500;
134+
color: var(--text-secondary);
135+
white-space: nowrap;
136+
transition: color 0.3s ease;
137+
}
138+
139+
.logo-item:hover .company-name {
140+
color: var(--text-primary);
141+
}
142+
125143
@keyframes marquee {
126144
0% {
127145
transform: translateX(0);

pages/src/data/users.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
export interface UserCompany {
99
name: string;
1010
fullName: string;
11-
iconType: 'sensor' | 'farm' | 'data' | 'tech' | 'logistics' | 'automotive' | 'custom';
11+
iconType?: 'sensor' | 'farm' | 'data' | 'tech' | 'logistics' | 'automotive' | 'custom';
1212
customIcon?: string;
1313
}
1414

1515
export const userCompanies: UserCompany[] = [
1616
{
17-
name: '比亚迪',
18-
fullName: '比亚迪股份有限公司',
19-
iconType: 'automotive'
17+
name: '深圳市比亚迪锂电池有限公司坑梓分公司',
18+
fullName: '深圳市比亚迪锂电池有限公司坑梓分公司',
19+
customIcon: '/smart-mqtt/user_byd.jpg'
2020
},
2121
{
2222
name: '上海极锐星瀚传感',

0 commit comments

Comments
 (0)