- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs
Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
83 lines
2.0 KiB
JavaScript
83 lines
2.0 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
var _util = require("@antv/util");
|
|
var PluginBase = /** @class */function () {
|
|
/**
|
|
* 插件基类的构造函数
|
|
* @param cfgs 插件的配置项
|
|
*/
|
|
function PluginBase(cfgs) {
|
|
this._cfgs = (0, _util.deepMix)(this.getDefaultCfgs(), cfgs);
|
|
this._events = {};
|
|
this.destroyed = false;
|
|
}
|
|
/**
|
|
* 获取默认的插件配置
|
|
*/
|
|
PluginBase.prototype.getDefaultCfgs = function () {
|
|
return {};
|
|
};
|
|
/**
|
|
* 初始化插件
|
|
* @param graph IGraph 实例
|
|
*/
|
|
PluginBase.prototype.initPlugin = function (graph) {
|
|
var self = this;
|
|
self.set('graph', graph);
|
|
var events = self.getEvents();
|
|
var bindEvents = {};
|
|
(0, _util.each)(events, function (v, k) {
|
|
var event = (0, _util.wrapBehavior)(self, v);
|
|
bindEvents[k] = event;
|
|
graph.on(k, event);
|
|
});
|
|
this._events = bindEvents;
|
|
this.init();
|
|
};
|
|
/**
|
|
* 获取插件中的事件和事件处理方法,供子类实现
|
|
*/
|
|
PluginBase.prototype.getEvents = function () {
|
|
return {};
|
|
};
|
|
/**
|
|
* 获取配置项中的某个值
|
|
* @param key 键值
|
|
*/
|
|
PluginBase.prototype.get = function (key) {
|
|
var _a;
|
|
return (_a = this._cfgs) === null || _a === void 0 ? void 0 : _a[key];
|
|
};
|
|
/**
|
|
* 将指定的值存储到 cfgs 中
|
|
* @param key 键值
|
|
* @param val 设置的值
|
|
*/
|
|
PluginBase.prototype.set = function (key, val) {
|
|
this._cfgs[key] = val;
|
|
};
|
|
/**
|
|
* 销毁方法,供子类复写
|
|
*/
|
|
PluginBase.prototype.destroy = function () {};
|
|
/**
|
|
* 销毁插件
|
|
*/
|
|
PluginBase.prototype.destroyPlugin = function () {
|
|
this.destroy();
|
|
var graph = this.get('graph');
|
|
var events = this._events;
|
|
(0, _util.each)(events, function (v, k) {
|
|
graph.off(k, v);
|
|
});
|
|
this._events = null;
|
|
this._cfgs = null;
|
|
this.destroyed = true;
|
|
};
|
|
return PluginBase;
|
|
}();
|
|
var _default = exports.default = PluginBase; |