File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -838,9 +838,6 @@ export const bazaar = {
838838 } , response => {
839839 this . _genMyHTML ( bazaarType , app ) ;
840840 bazaar . _onBazaar ( response , bazaarType , [ "themes" , "icons" ] . includes ( bazaarType ) ) ;
841- if ( bazaarType === "plugins" ) {
842- uninstall ( app , packageName , true ) ;
843- }
844841 } ) ;
845842 } ) ;
846843 }
@@ -923,7 +920,7 @@ export const bazaar = {
923920 if ( window . siyuan . config . bazaar . petalDisabled ) {
924921 bazaar . element . querySelectorAll ( "#configBazaarDownloaded .b3-card" ) . forEach ( item => {
925922 item . classList . add ( "b3-card--disabled" ) ;
926- uninstall ( app , JSON . parse ( item . getAttribute ( "data-obj" ) ) . name ) ;
923+ uninstall ( app , JSON . parse ( item . getAttribute ( "data-obj" ) ) . name , false ) ;
927924 } ) ;
928925 } else {
929926 bazaar . element . querySelectorAll ( "#configBazaarDownloaded .b3-card" ) . forEach ( item => {
@@ -961,7 +958,7 @@ export const bazaar = {
961958 }
962959 } ) ;
963960 } else {
964- uninstall ( app , dataObj . name ) ;
961+ uninstall ( app , dataObj . name , false ) ;
965962 target . parentElement . querySelector ( '[data-type="setting"]' ) . classList . add ( "fn__none" ) ;
966963 }
967964 } ) ;
Original file line number Diff line number Diff line change @@ -211,8 +211,11 @@ export const afterLoadPlugin = (plugin: Plugin) => {
211211} ;
212212
213213export const reloadPlugin = async ( app : App , data : { upsertPlugins : string [ ] , removePlugins : string [ ] } ) => {
214- data . removePlugins . concat ( data . upsertPlugins ) . forEach ( ( item ) => {
215- uninstall ( app , item ) ;
214+ data . removePlugins . forEach ( ( item ) => {
215+ uninstall ( app , item , true ) ;
216+ } ) ;
217+ data . upsertPlugins . forEach ( ( item ) => {
218+ uninstall ( app , item , false ) ;
216219 } ) ;
217220 loadPlugins ( app , data . upsertPlugins ) . then ( ( ) => {
218221 app . plugins . forEach ( item => {
Original file line number Diff line number Diff line change 11import { App } from "../index" ;
2- import { Plugin } from "../plugin " ;
2+ import { Plugin } from "./index " ;
33/// #if !MOBILE
44import { getAllModels } from "../layout/getAll" ;
55import { resizeTopBar } from "../layout/util" ;
@@ -8,20 +8,23 @@ import {Constants} from "../constants";
88import { setStorageVal } from "../protyle/util/compatibility" ;
99import { getAllEditor } from "../layout/getAll" ;
1010
11- export const uninstall = ( app : App , name : string , isUninstall = false ) => {
11+ export const uninstall = ( app : App , name : string , isUninstall : boolean ) => {
1212 app . plugins . find ( ( plugin : Plugin , index ) => {
1313 if ( plugin . name === name ) {
14- // rm command
1514 try {
1615 plugin . onunload ( ) ;
17- if ( isUninstall ) {
18- plugin . uninstall ( ) ;
19- window . siyuan . storage [ Constants . LOCAL_PLUGIN_DOCKS ] [ plugin . name ] = { } ;
20- setStorageVal ( Constants . LOCAL_PLUGIN_DOCKS , window . siyuan . storage [ Constants . LOCAL_PLUGIN_DOCKS ] ) ;
21- }
2216 } catch ( e ) {
2317 console . error ( `plugin ${ plugin . name } onunload error:` , e ) ;
2418 }
19+ if ( isUninstall ) {
20+ try {
21+ plugin . uninstall ( ) ;
22+ } catch ( e ) {
23+ console . error ( `plugin ${ plugin . name } uninstall error:` , e ) ;
24+ }
25+ window . siyuan . storage [ Constants . LOCAL_PLUGIN_DOCKS ] [ plugin . name ] = { } ;
26+ setStorageVal ( Constants . LOCAL_PLUGIN_DOCKS , window . siyuan . storage [ Constants . LOCAL_PLUGIN_DOCKS ] ) ;
27+ }
2528 // rm tab
2629 /// #if !MOBILE
2730 const modelsKeys = Object . keys ( plugin . models ) ;
You can’t perform that action at this time.
0 commit comments