From 30aae7a17e65aa1aa4d2c2316eda713d1b3089b4 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Thu, 5 Jul 2018 11:22:49 +0800 Subject: [PATCH] Fix add | remove plugin, config option not-refresh bug. --- src/module/plugins.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/module/plugins.jsx b/src/module/plugins.jsx index ebf6291b..6902dd79 100644 --- a/src/module/plugins.jsx +++ b/src/module/plugins.jsx @@ -5,6 +5,7 @@ import * as run from 'runtime'; import * as ss from 'stylesheet'; import {browser} from 'browser'; import * as msg from 'message'; +import * as watch from 'watch'; import Button from 'button'; @@ -120,6 +121,10 @@ export default class PluginsOpt extends React.Component { plugins: [] }; + writecb() { + watch.SendMessage( "option", true ); + } + install() { const id = decodeURIComponent( location.hash ).replace( "#plugins?install=", "" ); run.Install( id, undefined, result => { @@ -137,7 +142,7 @@ export default class PluginsOpt extends React.Component { if ( !storage.option.plugins.includes( result.id ) ) { add(); storage.option.plugins.push( result.id ); - storage.Write(); + storage.Write( this.writecb ); } else if ( storage.plugins[result.id].version != result.version ) { new Notify().Render({ content: "本地版本与安装版本不一致,是否重新安装?", action: "安装", cancel: "取消", callback: type => { type == "action" && add(); @@ -155,7 +160,7 @@ export default class PluginsOpt extends React.Component { new Notify().Render({ mode: "snackbar", content: "是否清除本地全部插件?", action: "是的", cancel: "取消", callback: type => { if ( type == "action" ) { storage.option.plugins = []; - storage.Write(); + storage.Write( this.writecb ); storage.Plugins( () => { new Notify().Render( "snackbar", "清除成功,此页面需刷新后才能生效!", "刷新 ", ()=>{ location.href = location.origin + location.pathname + "#plugins"; @@ -223,7 +228,7 @@ export default class PluginsOpt extends React.Component { } onChange( type ) { - storage.Write(); + storage.Write( this.writecb ); storage.Plugins( () => { type == "update" && new Notify().Render( "当前插件已更新成功。" ); type == "delete" && new Notify().Render( "当前插件已删除成功。" );