Qyexternal.php 3.8 KB
<?php

namespace addons\qyexternal;

use app\common\library\Menu;
use think\Addons;
use think\Route;

/**
 * 插件
 */
class Qyexternal extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'qywx',
                'title'   => '企业微信客户',
                'icon'    => 'fa fa-id-badge',
                'remark'  => '企业微信客户管理,支持微信用户。',
                'sublist' => [
                    [
                        "name"    => "qywx/corp",
                        "title"   => "企业微信列表",
                        'icon'    => 'fa fa-window-restore',
                        "sublist" => [
                            ["name"  => "qywx/corp/index", "title" => "查看"],
                            ["name"  => "qywx/corp/add", "title" => "添加"],
                            ["name"  => "qywx/corp/edit", "title" => "编辑"],
                            ["name"  => "qywx/corp/del", "title" => "删除"],
                            ["name"  => "qywx/corp/multi", "title" => "批量更新"],
                            ["name"  => "qywx/corp/sync", "title" => "数据同步"],

                        ]
                    ], [
                        "name"    => "qywx/follow",
                        "title"   => "成员列表",
                        'icon'    => 'fa fa-id-badge',
                        "sublist" => [
                            ["name"  => "qywx/follow/index", "title" => "查看"],
                            ["name"  => "qywx/follow/data", "title" => "近30天数据"],
                        ]
                    ], [
                        "name"    => "qywx/contacts",
                        "title"   => "客户列表",
                        'icon'    => 'fa fa-users',
                        "sublist" => [
                            ["name"  => "qywx/contacts/index", "title" => "查看"],
                        ]
                    ], [
                        "name"    => "qywx/group",
                        "title"   => "客户群列表",
                        'icon'    => 'fa fa-group',
                        "sublist" => [
                            ["name"  => "qywx/group/index", "title" => "查看"],
                        ]
                    ], [
                        "name"   => "qywx/dashboard",
                        "title"  => "数据统计",
                        "icon"   => "fa fa-dashboard",
                        "sublist" => [
                            ["name"  => "qywx/dashboard/index", "title" => "查看"],
                        ]
                    ]
                ],
            ]
        ];

        Menu::create($menu);
        
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("qywx");

        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("qywx");

        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("qywx");
        
        return true;
    }

    /**
     * 应用初始化
     */
    public function appInit()
    {
        \think\Loader::addNamespace('Weasy\\External', ADDON_PATH . 'qyexternal' . DS . 'library' . DS . 'External' . DS);
        \think\Loader::addNamespace('Weasy\\Core', ADDON_PATH . 'qyexternal' . DS . 'library' . DS . 'Core' . DS);
        \think\Loader::addNamespace('Weasy\\Rboot\\Plugins\\Qywx', ADDON_PATH . 'qyexternal' . DS . 'library' . DS . 'Rboot' . DS);

        Route::any('qywx', 'addons\\qyexternal\\controller\\Index@index');
        Route::post('qywx/sync', 'addons\\qyexternal\\controller\\Index@sync');

    }

}