Skip to content

Commit 2023fec

Browse files
committed
fix: 紧急处理因为 gitee 防盗链导致图片访问不了
1 parent b172910 commit 2023fec

File tree

10 files changed

+48
-37
lines changed

10 files changed

+48
-37
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "",
3-
"description": "",
4-
"img": "https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg"
5-
}
2+
"title": "",
3+
"description": "",
4+
"img": "https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg"
5+
}

src/utils/materials.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const getLocalMaterials = (
2626
const fullPath = path.join(materialsFullPath, s);
2727
let model = {} as any;
2828
let schema = {} as any;
29-
let preview = {};
29+
let preview = { img: '' };
3030
let template = '';
3131
try {
3232
model = JSON.parse(
@@ -43,6 +43,10 @@ export const getLocalMaterials = (
4343
getFileContent(path.join(fullPath, 'config', 'preview.json'), true),
4444
);
4545
} catch {}
46+
if (preview.img && preview.img.indexOf('gitee.') > -1) {
47+
preview.img =
48+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg';
49+
}
4650
if (type === 'snippets') {
4751
try {
4852
template = getFileContent(
@@ -110,7 +114,7 @@ export function getSnippets() {
110114
model: {},
111115
schema: {},
112116
preview: {
113-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
117+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
114118
},
115119
template: s.template,
116120
}));

src/webview/controllers/scaffold.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IMessage } from '../type';
66

77
export const getScaffolds = async (message: IMessage<{ url: string }>) => {
88
const res = await fetchScaffolds(message.data.url);
9-
return res.data;
9+
return res.data || [];
1010
};
1111

1212
export const downloadScaffold = (
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "",
3-
"description": "",
4-
"img": "https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg"
5-
}
2+
"title": "",
3+
"description": "",
4+
"img": "https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg"
5+
}

webview-react/src/pages/scaffold/List/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ const View = () => {
7373
}}
7474
>
7575
<div className="screenshot">
76-
<img src={s.screenshot} />
76+
<img
77+
src={
78+
s.screenshot?.includes('gitee.')
79+
? 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg'
80+
: s.screenshot
81+
}
82+
/>
7783
</div>
7884
<div className="title">{s.title}</div>
7985
<div className="description">{s.description}</div>

webview-react/src/pages/snippets/AddSnippet/useModel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const useModel = () => {
1414
{
1515
title: '',
1616
description: '',
17-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
17+
img:
18+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
1819
},
1920
null,
2021
2,

webview-react/src/webview/mock/getLocalMaterials.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export default [
112112
preview: {
113113
title: '哈哈哈',
114114
description: 'ksjfdfhdfhdkfjd',
115-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
115+
img:
116+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
116117
},
117118
template: '1212121',
118119
},
@@ -233,7 +234,8 @@ export default [
233234
preview: {
234235
title: '哈哈哈',
235236
description: 'ksjfdfhdfhdkfjd',
236-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
237+
img:
238+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
237239
},
238240
template: '',
239241
},
@@ -270,7 +272,8 @@ export default [
270272
preview: {
271273
title: '哈哈哈',
272274
description: 'ksjfdfhdfhdkfjd',
273-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
275+
img:
276+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
274277
},
275278
template: '',
276279
},
@@ -307,7 +310,8 @@ export default [
307310
preview: {
308311
title: '哈哈哈',
309312
description: 'ksjfdfhdfhdkfjd',
310-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
313+
img:
314+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
311315
},
312316
template: '',
313317
},
@@ -344,7 +348,8 @@ export default [
344348
preview: {
345349
title: '哈哈哈',
346350
description: 'ksjfdfhdfhdkfjd',
347-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
351+
img:
352+
'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
348353
},
349354
template: '',
350355
},
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "",
3-
"description": "",
4-
"img": "https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg"
5-
}
2+
"title": "",
3+
"description": "",
4+
"img": "https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg"
5+
}

webview-vue-webpack/src/vscode/mock/getLocalMaterials.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export default [
3232
preview: {
3333
title: '哈哈哈',
3434
description: 'ksjfdfhdfhdkfjd',
35-
img:
36-
'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
35+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
3736
},
3837
template: '1212121',
3938
},
@@ -70,8 +69,7 @@ export default [
7069
preview: {
7170
title: '哈哈哈',
7271
description: 'ksjfdfhdfhdkfjd',
73-
img:
74-
'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
72+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
7573
},
7674
template: '',
7775
},
@@ -108,8 +106,7 @@ export default [
108106
preview: {
109107
title: '哈哈哈',
110108
description: 'ksjfdfhdfhdkfjd',
111-
img:
112-
'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
109+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
113110
},
114111
template: '',
115112
},
@@ -146,8 +143,7 @@ export default [
146143
preview: {
147144
title: '哈哈哈',
148145
description: 'ksjfdfhdfhdkfjd',
149-
img:
150-
'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
146+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
151147
},
152148
template: '',
153149
},
@@ -184,8 +180,7 @@ export default [
184180
preview: {
185181
title: '哈哈哈12121',
186182
description: 'kjksss',
187-
img:
188-
'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
183+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
189184
},
190185
template: '',
191186
},

webview-vue/src/vscode/mock/getLocalMaterials.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default [
3232
preview: {
3333
title: '哈哈哈',
3434
description: 'ksjfdfhdfhdkfjd',
35-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
35+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
3636
},
3737
template: '1212121',
3838
},
@@ -69,7 +69,7 @@ export default [
6969
preview: {
7070
title: '哈哈哈',
7171
description: 'ksjfdfhdfhdkfjd',
72-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
72+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
7373
},
7474
template: '',
7575
},
@@ -106,7 +106,7 @@ export default [
106106
preview: {
107107
title: '哈哈哈',
108108
description: 'ksjfdfhdfhdkfjd',
109-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
109+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
110110
},
111111
template: '',
112112
},
@@ -143,7 +143,7 @@ export default [
143143
preview: {
144144
title: '哈哈哈',
145145
description: 'ksjfdfhdfhdkfjd',
146-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
146+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
147147
},
148148
template: '',
149149
},
@@ -180,7 +180,7 @@ export default [
180180
preview: {
181181
title: '哈哈哈',
182182
description: 'ksjfdfhdfhdkfjd',
183-
img: 'https://gitee.com/img-host/img-host/raw/master//2020/11/05/1604587962875.jpg',
183+
img: 'https://cdn.jsdelivr.net/gh/migrate-gitee/img-host/2020/11/05/1604587962875.jpg',
184184
},
185185
template: '',
186186
},

0 commit comments

Comments
 (0)