Skip to content

Commit 91e2b99

Browse files
committed
feat: demo
1 parent 46d5641 commit 91e2b99

6 files changed

Lines changed: 38 additions & 77 deletions

File tree

src/assets/svg/line-border.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/svg/line.svg

Lines changed: 1 addition & 0 deletions
Loading

src/pages/business/index.jsx

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,63 +43,24 @@ const fixColumns = [
4343

4444
const initialFetchData = [
4545
{
46-
grid: '1634270012',
47-
name: '中化学土木工程有限公司',
46+
grid: '2316258212',
47+
name: '上海徐汇规划建筑设计有限公司',
48+
list: [],
49+
},
50+
{
51+
grid: '551517222',
52+
name: '中交第一公路勘察设计研究院有限公司',
4853
list: [],
4954
},
50-
// {
51-
// grid: '304300699',
52-
// name: '上海市建筑装饰工程集团有限公司',
53-
// list: [],
54-
// },
55-
// {
56-
// grid: '325253024',
57-
// name: '上海市工程建设咨询监理有限公司',
58-
// list: [],
59-
// },
60-
// {
61-
// grid: '307886242',
62-
// name: '上海市住安建设发展股份有限公司',
63-
// list: [],
64-
// },
65-
// {
66-
// grid: '828163972',
67-
// name: '中石化上海工程有限公司',
68-
// list: [],
69-
// },
70-
// {
71-
// grid: '2350706740',
72-
// name: '上海璞奥电子科技有限公司',
73-
// list: [],
74-
// },
75-
// {
76-
// grid: '804448386',
77-
// name: '上海江崎格力高南奉食品有限公司',
78-
// list: [],
79-
// },
80-
// {
81-
// grid: '787672126',
82-
// name: '清水建设(中国)有限公司',
83-
// list: [],
84-
// },
85-
// {
86-
// grid: '137331760',
87-
// name: '信息产业电子第十一设计研究院科技工程股份有限公司',
88-
// list: [],
89-
// },
90-
// {
91-
// grid: '2416780932',
92-
// name: '上海子绵置业有限公司',
93-
// list: [],
94-
// },
9555
]
9656

9757
const Business = () => {
9858
const [fetchData, setFetchData] = useState(initialFetchData)
99-
59+
const [loading, setLoading] = useState(false)
10060
useEffect(() => {
10161
const fetchAllData = async () => {
10262
const newFetchData = [...fetchData]
63+
setLoading(true)
10364
for (let i = 0; i < newFetchData.length; i++) {
10465
const item = newFetchData[i]
10566
try {
@@ -118,11 +79,13 @@ const Business = () => {
11879
},
11980
}
12081
)
82+
setLoading(false)
12183
newFetchData[i] = {
12284
...item,
12385
list: res.data?.list || [],
12486
}
12587
} catch (error) {
88+
setLoading(false)
12689
console.error('数据请求失败:', error)
12790
}
12891
}
@@ -139,7 +102,7 @@ const Business = () => {
139102
{index + 1}
140103
<span>.</span> {item.name} : {item.list.length}
141104
</section>
142-
<Table columns={fixColumns} dataSource={item.list} pagination={false} />
105+
<Table loading={loading} columns={fixColumns} dataSource={item.list} pagination={false} />
143106
</section>
144107
))}
145108
</FixTabPanel>

src/pages/demo/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const ProDemo = () => {
119119
return (
120120
<FixTabPanel>
121121
{/* <OrbitingCirclesDemo /> */}
122-
{/* <ScriptView showMultiplePackageOptions={true} codeLanguage="shell" commandMap={customCommandMap} /> */}
122+
<ScriptView showMultiplePackageOptions={true} codeLanguage="shell" commandMap={customCommandMap} />
123123
{/* <section style={{ height: 240, overflow: 'hidden', margin: 20 }}>
124124
<AnimatedList>
125125
{Array.from({ length: 10 }, () => ({

src/pages/home/index.jsx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,30 @@ const Home = () => {
312312

313313
const images = slugs.map((slug) => `https://cdn.simpleicons.org/${slug}/${slug}`)
314314

315+
// 使用 useRef 来引用 SVG 元素
316+
const svgRef = useRef(null)
317+
const saveSvgAsFile = () => {
318+
if (svgRef.current) {
319+
// 获取 SVG 元素的 outerHTML
320+
const svgContent = svgRef.current.outerHTML
321+
// 创建 Blob 对象
322+
const blob = new Blob([svgContent], { type: 'image/svg+xml' })
323+
// 创建下载链接
324+
const url = URL.createObjectURL(blob)
325+
// 创建 <a> 元素
326+
const a = document.createElement('a')
327+
a.href = url
328+
a.download = 'mySvg.svg'
329+
// 模拟点击下载链接
330+
a.click()
331+
// 释放临时 URL
332+
URL.revokeObjectURL(url)
333+
}
334+
}
335+
315336
return (
316337
<FixTabPanel ref={scrollRef}>
338+
<button onClick={saveSvgAsFile}>保存 SVG</button>
317339
<section className={styles.avatar} style={{ margin: '10px 0', fontSize: 24 }}>
318340
<ColorfulText text={`React version: ${version}`} />
319341
</section>
@@ -505,7 +527,7 @@ const Home = () => {
505527
>
506528
<section className="relative p-4">
507529
<div className={styles.itemCircle} />
508-
<svg style={{ height: '10px', width: '100%' }}>
530+
<svg ref={svgRef} style={{ height: '10px', width: '100%' }}>
509531
<path
510532
d="M 0 0 L 5000 0"
511533
stroke-miterlimit="10"
@@ -526,31 +548,6 @@ const Home = () => {
526548
</svg>
527549
<div className={styles.itemCircleTail} />
528550
</section>
529-
530-
<svg width="100%" height="100%" viewBox="0 0 620 445" fill="none" xmlns="http://www.w3.org/2000/svg">
531-
<linearGradient id="paint0_linear" x1="277" y1="0" x2="277" y2="202" gradientUnits="userSpaceOnUse">
532-
<stop stop-color="#FF7383"></stop>
533-
<stop offset="1" stop-color="#2F48EA"></stop>
534-
</linearGradient>
535-
<rect
536-
x="3"
537-
y="3"
538-
width="610"
539-
height="400"
540-
stroke="url(#paint0_linear)"
541-
stroke-width="5"
542-
stroke-linecap="round"
543-
stroke-dasharray="31 31"
544-
rx="25"
545-
></rect>
546-
<animate
547-
attributeName="stroke-dashoffset"
548-
values="370;0"
549-
dur="3s"
550-
calcMode="linear"
551-
repeatCount="indefinite"
552-
></animate>
553-
</svg>
554551
</section>
555552
<section className={styles.line} />
556553
<section className={styles.linear} />

src/service/fetch.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ export const reqFetch = (
200200
const signedPayload = suffix(suffixPayload)
201201

202202
const queryParams = parseToQuery(signedPayload)
203-
console.log('queryParams', queryParams)
204203

205204
const fetchUrl = `${baseUrl}${url}?${queryParams}`
206205

0 commit comments

Comments
 (0)