File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ interface FontSource {
30
30
class FontPlugin {
31
31
public canvas : fabric . Canvas ;
32
32
public editor : IEditor ;
33
+ private tempPromise : Promise < FontSource [ ] > | null ;
33
34
static pluginName = 'FontPlugin' ;
34
35
static apis = [ 'getFontList' , 'loadFont' , 'getFontJson' , 'downFontByJSON' ] ;
35
36
repoSrc : string ;
@@ -39,6 +40,7 @@ class FontPlugin {
39
40
this . editor = editor ;
40
41
this . repoSrc = config . repoSrc ;
41
42
this . cacheList = [ ] ;
43
+ this . tempPromise = null ;
42
44
}
43
45
44
46
hookImportBefore ( json : string ) {
@@ -49,7 +51,8 @@ class FontPlugin {
49
51
if ( this . cacheList . length ) {
50
52
return Promise . resolve ( this . cacheList ) ;
51
53
}
52
- return axios
54
+ if ( this . tempPromise ) return this . tempPromise ;
55
+ this . tempPromise = axios
53
56
. get ( `${ this . repoSrc } /api/fonts?populate=*&pagination[pageSize]=100` )
54
57
. then ( ( res ) => {
55
58
const list = res . data . data . map ( ( item : any ) => {
@@ -64,6 +67,7 @@ class FontPlugin {
64
67
this . createFontCSS ( list ) ;
65
68
return list ;
66
69
} ) ;
70
+ return this . tempPromise ;
67
71
}
68
72
69
73
downFontByJSON ( str : string ) {
You can’t perform that action at this time.
0 commit comments