@@ -69,46 +69,6 @@ export default class PluginSample extends Plugin {
69
69
<path d="M20 13.333c0-0.733 0.6-1.333 1.333-1.333s1.333 0.6 1.333 1.333c0 0.733-0.6 1.333-1.333 1.333s-1.333-0.6-1.333-1.333zM10.667 12h6.667v-2.667h-6.667v2.667zM29.333 10v9.293l-3.76 1.253-2.24 7.453h-7.333v-2.667h-2.667v2.667h-7.333c0 0-3.333-11.28-3.333-15.333s3.28-7.333 7.333-7.333h6.667c1.213-1.613 3.147-2.667 5.333-2.667 1.107 0 2 0.893 2 2 0 0.28-0.053 0.533-0.16 0.773-0.187 0.453-0.347 0.973-0.427 1.533l3.027 3.027h2.893zM26.667 12.667h-1.333l-4.667-4.667c0-0.867 0.12-1.72 0.347-2.547-1.293 0.333-2.347 1.293-2.787 2.547h-8.227c-2.573 0-4.667 2.093-4.667 4.667 0 2.507 1.627 8.867 2.68 12.667h2.653v-2.667h8v2.667h2.68l2.067-6.867 3.253-1.093v-4.707z"></path>
70
70
</symbol>` ) ;
71
71
72
- const topBarElement = this . addTopBar ( {
73
- icon : "iconFace" ,
74
- title : this . i18n . addTopBarIcon ,
75
- position : "right" ,
76
- callback : ( ) => {
77
- if ( this . isMobile ) {
78
- this . addMenu ( ) ;
79
- } else {
80
- let rect = topBarElement . getBoundingClientRect ( ) ;
81
- // 如果被隐藏,则使用更多按钮
82
- if ( rect . width === 0 ) {
83
- rect = document . querySelector ( "#barMore" ) . getBoundingClientRect ( ) ;
84
- }
85
- if ( rect . width === 0 ) {
86
- rect = document . querySelector ( "#barPlugins" ) . getBoundingClientRect ( ) ;
87
- }
88
- this . addMenu ( rect ) ;
89
- }
90
- }
91
- } ) ;
92
-
93
- const statusIconTemp = document . createElement ( "template" ) ;
94
- statusIconTemp . innerHTML = `<div class="toolbar__item ariaLabel" aria-label="Remove plugin-sample Data">
95
- <svg>
96
- <use xlink:href="#iconTrashcan"></use>
97
- </svg>
98
- </div>` ;
99
- statusIconTemp . content . firstElementChild . addEventListener ( "click" , ( ) => {
100
- confirm ( "⚠️" , this . i18n . confirmRemove . replace ( "${name}" , this . name ) , ( ) => {
101
- this . removeData ( STORAGE_NAME ) . then ( ( ) => {
102
- this . data [ STORAGE_NAME ] = { readonlyText : "Readonly" } ;
103
- showMessage ( `[${ this . name } ]: ${ this . i18n . removedData } ` ) ;
104
- } ) ;
105
- } ) ;
106
- } ) ;
107
-
108
- this . addStatusBar ( {
109
- element : statusIconTemp . content . firstElementChild as HTMLElement ,
110
- } ) ;
111
-
112
72
this . custom = this . addTab ( {
113
73
type : TAB_TYPE ,
114
74
init ( ) {
@@ -249,6 +209,43 @@ export default class PluginSample extends Plugin {
249
209
}
250
210
251
211
onLayoutReady ( ) {
212
+ const topBarElement = this . addTopBar ( {
213
+ icon : "iconFace" ,
214
+ title : this . i18n . addTopBarIcon ,
215
+ position : "right" ,
216
+ callback : ( ) => {
217
+ if ( this . isMobile ) {
218
+ this . addMenu ( ) ;
219
+ } else {
220
+ let rect = topBarElement . getBoundingClientRect ( ) ;
221
+ // 如果被隐藏,则使用更多按钮
222
+ if ( rect . width === 0 ) {
223
+ rect = document . querySelector ( "#barMore" ) . getBoundingClientRect ( ) ;
224
+ }
225
+ if ( rect . width === 0 ) {
226
+ rect = document . querySelector ( "#barPlugins" ) . getBoundingClientRect ( ) ;
227
+ }
228
+ this . addMenu ( rect ) ;
229
+ }
230
+ }
231
+ } ) ;
232
+ const statusIconTemp = document . createElement ( "template" ) ;
233
+ statusIconTemp . innerHTML = `<div class="toolbar__item ariaLabel" aria-label="Remove plugin-sample Data">
234
+ <svg>
235
+ <use xlink:href="#iconTrashcan"></use>
236
+ </svg>
237
+ </div>` ;
238
+ statusIconTemp . content . firstElementChild . addEventListener ( "click" , ( ) => {
239
+ confirm ( "⚠️" , this . i18n . confirmRemove . replace ( "${name}" , this . name ) , ( ) => {
240
+ this . removeData ( STORAGE_NAME ) . then ( ( ) => {
241
+ this . data [ STORAGE_NAME ] = { readonlyText : "Readonly" } ;
242
+ showMessage ( `[${ this . name } ]: ${ this . i18n . removedData } ` ) ;
243
+ } ) ;
244
+ } ) ;
245
+ } ) ;
246
+ this . addStatusBar ( {
247
+ element : statusIconTemp . content . firstElementChild as HTMLElement ,
248
+ } ) ;
252
249
this . loadData ( STORAGE_NAME ) ;
253
250
console . log ( `frontend: ${ getFrontend ( ) } ; backend: ${ getBackend ( ) } ` ) ;
254
251
}
0 commit comments