// +---------------------------------------------------------------------- declare (strict_types = 1); namespace addon\iot; use think\facade\Db; use ywxapp\AddonBase; /** * Addon 类 * * @author ywxapp */ class Addon extends AddonBase { /** * 安装钩子:表由 install.sql 统一创建,这里无需额外处理 */ public function install() { return true; } /** * 卸载钩子:清理本插件的数据表与菜单残留 */ public function uninstall() { $prefix = Db::getConfig('prefix'); $tables = [ 'iot_connection', 'iot_message', 'iot_topic', 'iot_auth', 'iot_acl', 'iot_retain', 'iot_offline', 'iot_stats', 'iot_rule', 'iot_outbox', 'iot_device', 'iot_sensor_cfg', ]; foreach ($tables as $t) { Db::execute("DROP TABLE IF EXISTS `{$prefix}{$t}`"); } // 清理框架菜单(后端权限 + 前端/会员规则),前缀同样动态获取 Db::execute("DELETE FROM `{$prefix}user_rule` WHERE name LIKE 'iot:%'"); Db::execute("DELETE FROM `{$prefix}admin_power` WHERE addon='iot'"); return true; } }