bddjr / clipcc-extension_simple_template Goto Github PK
View Code? Open in Web Editor NEW别针扩展简单模板(轻量级)
别针扩展简单模板(轻量级)
预先装载一个扩展,然后加载一个项目,如果项目里包含这个扩展,那么这个扩展的装载函数 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();
// 接着再装载积木
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.