Giter Site home page Giter Site logo

clipcc-extension_simple_template's Introduction

clipcc-extension_simple_template's People

Contributors

bddjr avatar

Watchers

 avatar

clipcc-extension_simple_template's Issues

今日发现:再次加载作品导致积木重复的bug

@ 9_1V }WZ7DD$@6~1M1NLB

预先装载一个扩展,然后加载一个项目,如果项目里包含这个扩展,那么这个扩展的装载函数 onInit 会被再次触发,由于在onInit触发前未触发onUninit,导致积木重复。

但加载项目的时候会触发 beforeProjectLoadExtension 和 beforeProjectLoad (先后顺序),如果以上描述的是特性,那就代表着大多数扩展的装载逻辑都是有问题的,包括官方示范。

既然多数过审的扩展都有这个问题,那直接摆烂不解决了(确信)


扩展自行解决的方法:

category_id 是指扩展添加的模块id
extension_id 是扩展ID

function my_onUninit(){
    api.removeCategory( category_id );
}

module.exports = class extends Extension {
    onUninit(){
        my_onUninit();
    }
    beforeProjectLoadExtension(data, extensions){
        // 修复再次加载作品导致积木重复的bug
        // 实测不能使用 this.onUninit()
        if( Object.keys( extensions ).includes( extension_id ) )
            my_onUninit();
    }

或者:

function my_onUninit(){
    api.removeCategory( category_id );
}

module.exports = class extends Extension {
    onUninit(){
        my_onUninit();
    }
    onInit(){
        my_onUninit();
        // 接着再装载积木

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.