Skip to content

Commit aee6130

Browse files
committed
refactor(mock): remove third-party images
1 parent d677729 commit aee6130

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

mock/demo/table-demo.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { MockMethod } from 'vite-plugin-mock';
2+
import { Random } from 'mockjs';
23
import { resultPageSuccess } from '../_util';
34

5+
function getRandomPics(count = 10): string[] {
6+
const arr: string[] = [];
7+
for (let i = 0; i < count; i++) {
8+
arr.push(Random.image('800x600', Random.color(), Random.color(), Random.title()));
9+
}
10+
return arr;
11+
}
12+
413
const demoList = (() => {
514
const result: any[] = [];
615
for (let index = 0; index < 60; index++) {
@@ -18,6 +27,9 @@ const demoList = (() => {
1827
name6: '@cname()',
1928
name7: '@cname()',
2029
name8: '@cname()',
30+
avatar: Random.image('400x400', Random.color(), Random.color(), Random.first()),
31+
imgArr: getRandomPics(Math.ceil(Math.random() * 3) + 1),
32+
imgs: getRandomPics(Math.ceil(Math.random() * 3) + 1),
2133
date: `@date('yyyy-MM-dd')`,
2234
time: `@time('HH:mm')`,
2335
'no|100000-10000000': 100000,

src/views/demo/table/CustomerCell.vue

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,12 @@
88
</Tag>
99
</template>
1010
<template #avatar="{ record }">
11-
<Avatar
12-
:size="60"
13-
:src="'http://api.btstu.cn/sjtx/api.php?lx=c1&format=images&id=' + record.id"
14-
/>
11+
<Avatar :size="60" :src="record.avatar" />
1512
</template>
16-
<template #img>
17-
<TableImg
18-
:size="60"
19-
:simpleShow="true"
20-
:imgList="[
21-
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?1622962250222',
22-
'https://picsum.photos/id/66/346/216',
23-
'https://picsum.photos/id/67/346/216',
24-
]"
25-
/>
26-
</template>
27-
<template #imgs>
28-
<TableImg
29-
:size="60"
30-
:imgList="[
31-
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?1622962250222',
32-
'https://picsum.photos/id/66/346/216',
33-
'https://picsum.photos/id/67/346/216',
34-
]"
35-
/>
13+
<template #img="{ text }">
14+
<TableImg :size="60" :simpleShow="true" :imgList="text" />
3615
</template>
16+
<template #imgs="{ text }"> <TableImg :size="60" :imgList="text" /> </template>
3717

3818
<template #category="{ record }">
3919
<Tag color="green">
@@ -75,7 +55,7 @@
7555
},
7656
{
7757
title: '图片列表1',
78-
dataIndex: 'img',
58+
dataIndex: 'imgArr',
7959
helpMessage: ['这是简单模式的图片列表', '只会显示一张在表格中', '但点击可预览多张图片'],
8060
width: 140,
8161
slots: { customRender: 'img' },
@@ -109,6 +89,7 @@
10989
setup() {
11090
const [registerTable] = useTable({
11191
title: '自定义列内容',
92+
titleHelpMessage: '表格中所有头像、图片均为mock生成,仅用于演示图片占位',
11293
api: demoListApi,
11394
columns: columns,
11495
bordered: true,

0 commit comments

Comments
 (0)