51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace addon\aikefu\event;
|
|
|
|
use app\model\system\Addon as AddonModel;
|
|
|
|
/**
|
|
* 智能客服插件安装
|
|
*/
|
|
class Install
|
|
{
|
|
public function handle()
|
|
{
|
|
$addon_model = new AddonModel();
|
|
$info = $addon_model->getAddonInfo(['name' => 'aikefu']);
|
|
|
|
if (empty($info['data'])) {
|
|
// 插件未安装,执行安装逻辑
|
|
$addon_model->addAddon([
|
|
'name' => 'aikefu',
|
|
'title' => '智能客服',
|
|
'description' => '基于Dify的智能客服系统',
|
|
'author' => 'admin',
|
|
'version' => '1.0.0',
|
|
'scene' => 'web',
|
|
'state' => 0,
|
|
'category' => 'business',
|
|
'need_install' => 1,
|
|
'need_cache' => 1,
|
|
'create_time' => time(),
|
|
'update_time' => time()
|
|
]);
|
|
} else {
|
|
// 插件已存在,更新插件信息
|
|
$addon_model->updateAddon([
|
|
'title' => '智能客服',
|
|
'description' => '基于Dify的智能客服系统',
|
|
'author' => 'admin',
|
|
'version' => '1.0.0',
|
|
'scene' => 'web',
|
|
'category' => 'business',
|
|
'need_install' => 1,
|
|
'need_cache' => 1,
|
|
'update_time' => time()
|
|
], ['name' => 'aikefu']);
|
|
}
|
|
|
|
return success(1);
|
|
}
|
|
}
|