@@ -148,7 +148,9 @@ export default class PluginSample extends Plugin {
148148 const textareaElement = document . createElement ( "textarea" ) ;
149149 this . setting = new Setting ( {
150150 confirmCallback : ( ) => {
151- this . saveData ( STORAGE_NAME , { readonlyText : textareaElement . value } ) ;
151+ this . saveData ( STORAGE_NAME , { readonlyText : textareaElement . value } ) . catch ( e => {
152+ showMessage ( `[${ this . name } ] save data [${ STORAGE_NAME } ] fail: ` , e ) ;
153+ } ) ;
152154 }
153155 } ) ;
154156 this . setting . addItem ( {
@@ -240,25 +242,30 @@ export default class PluginSample extends Plugin {
240242 this . removeData ( STORAGE_NAME ) . then ( ( ) => {
241243 this . data [ STORAGE_NAME ] = { readonlyText : "Readonly" } ;
242244 showMessage ( `[${ this . name } ]: ${ this . i18n . removedData } ` ) ;
245+ } ) . catch ( e => {
246+ showMessage ( `[${ this . name } ] remove data [${ STORAGE_NAME } ] fail: ` , e ) ;
243247 } ) ;
244248 } ) ;
245249 } ) ;
246250 this . addStatusBar ( {
247251 element : statusIconTemp . content . firstElementChild as HTMLElement ,
248252 } ) ;
249- this . loadData ( STORAGE_NAME ) ;
253+ this . loadData ( STORAGE_NAME ) . catch ( e => {
254+ console . log ( `[${ this . name } ] load data [${ STORAGE_NAME } ] fail: ` , e ) ;
255+ } ) ;
250256 console . log ( `frontend: ${ getFrontend ( ) } ; backend: ${ getBackend ( ) } ` ) ;
251257 }
252258
253259 onunload ( ) {
254260 console . log ( this . i18n . byePlugin ) ;
255261 }
256262
257- async uninstall ( ) {
263+ uninstall ( ) {
258264 // 卸载插件时删除插件数据
259265 // Delete plugin data when uninstalling the plugin
260- await this . removeData ( STORAGE_NAME ) ;
261- console . log ( "uninstall" ) ;
266+ this . removeData ( STORAGE_NAME ) . catch ( e => {
267+ showMessage ( `uninstall [${ this . name } ] remove data [${ STORAGE_NAME } ] fail: ${ e . msg } ` ) ;
268+ } ) ;
262269 }
263270
264271 // 使用 saveData() 存储的数据发生变更时触发,注释掉则自动禁用插件再重新启用
0 commit comments