mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-09-21 19:26:39 +08:00
插件中心更新
This commit is contained in:
parent
5ba4dfdc6c
commit
d6096d6ad9
8
.env
8
.env
@ -2,11 +2,11 @@ APP_DEBUG = true
|
|||||||
|
|
||||||
DB_TYPE = mysql
|
DB_TYPE = mysql
|
||||||
DB_HOST = 127.0.0.1
|
DB_HOST = 127.0.0.1
|
||||||
DB_NAME = test1
|
DB_NAME = mpay
|
||||||
DB_USER = a1
|
DB_USER = admin
|
||||||
DB_PASS = 123456
|
DB_PASS = Aa123456
|
||||||
DB_PORT = 3306
|
DB_PORT = 3306
|
||||||
DB_CHARSET = utf8mb4
|
DB_CHARSET = utf8
|
||||||
DB_PREFIX = mpay_
|
DB_PREFIX = mpay_
|
||||||
|
|
||||||
DEFAULT_LANG = zh-cn
|
DEFAULT_LANG = zh-cn
|
@ -12,7 +12,13 @@ class PluginController extends BaseController
|
|||||||
public function getPluginList()
|
public function getPluginList()
|
||||||
{
|
{
|
||||||
$local_plugin_config = self::getPluginConfig();
|
$local_plugin_config = self::getPluginConfig();
|
||||||
$plugin_config = \Plugin::getPluginList($local_plugin_config);
|
$show = $this->request->get('show', 1);
|
||||||
|
$plugin_config = match ((int)$show) {
|
||||||
|
0 => \Plugin::getAllPlugins($local_plugin_config),
|
||||||
|
1 => \Plugin::getInstall($local_plugin_config),
|
||||||
|
2 => \Plugin::getUninstallPlugins($local_plugin_config),
|
||||||
|
default => []
|
||||||
|
};
|
||||||
if ($plugin_config) {
|
if ($plugin_config) {
|
||||||
return json(['code' => 0, 'msg' => 'OK', 'count' => count($plugin_config), 'data' => $plugin_config]);
|
return json(['code' => 0, 'msg' => 'OK', 'count' => count($plugin_config), 'data' => $plugin_config]);
|
||||||
} else {
|
} else {
|
||||||
@ -83,11 +89,28 @@ class PluginController extends BaseController
|
|||||||
public function pluginEnable()
|
public function pluginEnable()
|
||||||
{
|
{
|
||||||
$info = $this->request->post();
|
$info = $this->request->post();
|
||||||
|
if ($this->isPluginInstall($info['platform']) == false) {
|
||||||
|
return json(backMsg(1, '插件未安装'));
|
||||||
|
}
|
||||||
$up_res = $this->setPlugin($info['platform'], ['state' => $info['state']]);
|
$up_res = $this->setPlugin($info['platform'], ['state' => $info['state']]);
|
||||||
if ($up_res) {
|
if ($up_res) {
|
||||||
return json(\backMsg(1, '失败'));
|
return json(backMsg(1, '失败'));
|
||||||
} else {
|
} else {
|
||||||
return json(\backMsg(0, '成功'));
|
return json(backMsg(0, '成功'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 检测插件是否安装
|
||||||
|
public function isPluginInstall(string $platform): bool
|
||||||
|
{
|
||||||
|
$config = self::getPluginConfig();
|
||||||
|
$platforms = [];
|
||||||
|
foreach ($config as $key => $value) {
|
||||||
|
$platforms[] = $value['platform'];
|
||||||
|
}
|
||||||
|
if (in_array($platform, $platforms)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 插件选项
|
// 插件选项
|
||||||
|
@ -50,5 +50,5 @@ return array (
|
|||||||
'store_sn' => '',
|
'store_sn' => '',
|
||||||
'type' => '30',
|
'type' => '30',
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,8 @@ use think\facade\Log;
|
|||||||
|
|
||||||
class Plugin
|
class Plugin
|
||||||
{
|
{
|
||||||
public static function getPluginList(array $local_plugin = []): array
|
// 获取全部插件(含本地)
|
||||||
|
public static function getAllPlugins(array $local_plugin = []): array
|
||||||
{
|
{
|
||||||
$app_plugin = [];
|
$app_plugin = [];
|
||||||
$app_plugin_all = self::getAllPlugin();
|
$app_plugin_all = self::getAllPlugin();
|
||||||
@ -15,6 +16,11 @@ class Plugin
|
|||||||
$app_plugin = array_merge($local_plugin, $plugin_uninstall);
|
$app_plugin = array_merge($local_plugin, $plugin_uninstall);
|
||||||
return $app_plugin;
|
return $app_plugin;
|
||||||
}
|
}
|
||||||
|
// 获取未安装插件
|
||||||
|
public static function getUninstallPlugins(array $local_plugin = []): array
|
||||||
|
{
|
||||||
|
return self::getUninstall(self::getAllPlugin(), $local_plugin);
|
||||||
|
}
|
||||||
// 获取已安装插件
|
// 获取已安装插件
|
||||||
public static function getInstall(array $local_plugin = []): array
|
public static function getInstall(array $local_plugin = []): array
|
||||||
{
|
{
|
||||||
@ -53,7 +59,7 @@ class Plugin
|
|||||||
'price' => '0.00',
|
'price' => '0.00',
|
||||||
'describe' => '支持微信个人收款码、赞赏码、经营码、商家码收款,监听回调',
|
'describe' => '支持微信个人收款码、赞赏码、经营码、商家码收款,监听回调',
|
||||||
'website' => 'https://weixin.qq.com/',
|
'website' => 'https://weixin.qq.com/',
|
||||||
'state' => 1,
|
'state' => 0,
|
||||||
'query' =>
|
'query' =>
|
||||||
array(),
|
array(),
|
||||||
),
|
),
|
||||||
@ -65,7 +71,7 @@ class Plugin
|
|||||||
'price' => '0.00',
|
'price' => '0.00',
|
||||||
'describe' => '支持支付宝个人收款码、经营码收款,监听回调',
|
'describe' => '支持支付宝个人收款码、经营码收款,监听回调',
|
||||||
'website' => 'https://www.alipay.com/',
|
'website' => 'https://www.alipay.com/',
|
||||||
'state' => 1,
|
'state' => 0,
|
||||||
'query' =>
|
'query' =>
|
||||||
array(),
|
array(),
|
||||||
),
|
),
|
||||||
@ -77,7 +83,7 @@ class Plugin
|
|||||||
'price' => '49.00',
|
'price' => '49.00',
|
||||||
'describe' => '主流移动支付全能收 信用卡,花呗都能用,生意帮手收钱吧,移动收款就用它!',
|
'describe' => '主流移动支付全能收 信用卡,花呗都能用,生意帮手收钱吧,移动收款就用它!',
|
||||||
'website' => 'https://www.shouqianba.com/',
|
'website' => 'https://www.shouqianba.com/',
|
||||||
'state' => 1,
|
'state' => 0,
|
||||||
'query' =>
|
'query' =>
|
||||||
array(
|
array(
|
||||||
'date_end' => NULL,
|
'date_end' => NULL,
|
||||||
@ -98,7 +104,7 @@ class Plugin
|
|||||||
'price' => '49.00',
|
'price' => '49.00',
|
||||||
'describe' => '数字门店',
|
'describe' => '数字门店',
|
||||||
'website' => 'https://store.zhihuijingyingba.com/',
|
'website' => 'https://store.zhihuijingyingba.com/',
|
||||||
'state' => 1,
|
'state' => 0,
|
||||||
'query' =>
|
'query' =>
|
||||||
array(
|
array(
|
||||||
'pageNo' => 1,
|
'pageNo' => 1,
|
||||||
|
@ -43,12 +43,19 @@
|
|||||||
<button class="layui-btn layui-btn-primary layui-bg-gray layui-btn-sm" grp-btn lay-event="showWaitInstall">待安装</button>
|
<button class="layui-btn layui-btn-primary layui-bg-gray layui-btn-sm" grp-btn lay-event="showWaitInstall">待安装</button>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="plugin-state">
|
<script type="text/html" id="plugin-state">
|
||||||
|
{{# if(d.install == true){ }}
|
||||||
<input type="checkbox" name="state" value="{{d.platform}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="pluginEnable" {{ d.state == 1 ? 'checked' : '' }} />
|
<input type="checkbox" name="state" value="{{d.platform}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="pluginEnable" {{ d.state == 1 ? 'checked' : '' }} />
|
||||||
|
{{# }else{ }}
|
||||||
|
<span class="layui-badge layui-bg-gray">未安装</span>
|
||||||
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="plugin-action">
|
<script type="text/html" id="plugin-action">
|
||||||
<a href="javascript:;" class="layui-font-green" lay-event="createConfig">配置</a><div class="divider-vl"></div>
|
{{# if(d.install == true){ }}
|
||||||
<a href="javascript:;" class="layui-font-green" lay-event="pluginUpdate">更新</a><div class="divider-vl"></div>
|
<a href="javascript:;" class="layui-font-green" lay-event="pluginUpdate">更新</a><div class="divider-vl"></div>
|
||||||
<a href="javascript:;" class="layui-font-green" lay-event="pluginUninstall">卸载</a>
|
<a href="javascript:;" class="layui-font-green" lay-event="pluginUninstall">卸载</a>
|
||||||
|
{{# }else{ }}
|
||||||
|
<a href="javascript:;" class="layui-font-green" lay-event="pluginInstall">立即安装</a>
|
||||||
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
<script src="/component/layui/layui.js"></script>
|
<script src="/component/layui/layui.js"></script>
|
||||||
<script src="/component/pear/pear.js"></script>
|
<script src="/component/pear/pear.js"></script>
|
||||||
@ -66,14 +73,13 @@
|
|||||||
{ title: '说明', field: 'describe', align: 'left' },
|
{ title: '说明', field: 'describe', align: 'left' },
|
||||||
{ title: '价格', field: 'price', align: 'center', maxWidth: 180, templet: `<div>{{= d.price==0 ? '免费' : d.price }}</div>` },
|
{ title: '价格', field: 'price', align: 'center', maxWidth: 180, templet: `<div>{{= d.price==0 ? '免费' : d.price }}</div>` },
|
||||||
{ title: '状态', field: 'state', align: 'center', maxWidth: 180, templet: `#plugin-state` },
|
{ title: '状态', field: 'state', align: 'center', maxWidth: 180, templet: `#plugin-state` },
|
||||||
{ title: '操作', align: 'right', maxWidth: 180, fixed: 'right', templet: `#plugin-action` },
|
{ title: '操作', align: 'center', maxWidth: 180, fixed: 'right', templet: `#plugin-action` },
|
||||||
]]
|
]]
|
||||||
|
|
||||||
table.render({
|
table.render({
|
||||||
id: 'plugin-table',
|
id: 'plugin-table',
|
||||||
elem: '#plugin-table',
|
elem: '#plugin-table',
|
||||||
url: '/api/Plugin/getPluginList',
|
url: '/api/Plugin/getPluginList',
|
||||||
page: true,
|
|
||||||
skin: 'line',
|
skin: 'line',
|
||||||
cols: cols,
|
cols: cols,
|
||||||
where: { show: 1 },
|
where: { show: 1 },
|
||||||
@ -84,20 +90,17 @@
|
|||||||
// 表头工具事件
|
// 表头工具事件
|
||||||
table.on('toolbar(plugin-table)', function (obj) {
|
table.on('toolbar(plugin-table)', function (obj) {
|
||||||
if (obj.event === 'showAllPlugin') {
|
if (obj.event === 'showAllPlugin') {
|
||||||
plugin.changClass(this);
|
table.reload('plugin-table', { where: { show: 0 }, done: () => { plugin.changClass(obj.event) } });
|
||||||
table.reload('plugin-table', { where: { show: 0 } });
|
|
||||||
} else if (obj.event === 'showInstalled') {
|
} else if (obj.event === 'showInstalled') {
|
||||||
plugin.changClass(this);
|
table.reload('plugin-table', { where: { show: 1 }, done: () => { plugin.changClass(obj.event) } });
|
||||||
table.reload('plugin-table', { where: { show: 1 } });
|
|
||||||
} else if (obj.event === 'showWaitInstall') {
|
} else if (obj.event === 'showWaitInstall') {
|
||||||
plugin.changClass(this);
|
table.reload('plugin-table', { where: { show: 2 }, done: () => { plugin.changClass(obj.event) } });
|
||||||
table.reload('plugin-table', { where: { show: 2 } });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 单元格事件
|
// 单元格事件
|
||||||
table.on('tool(plugin-table)', function (obj) {
|
table.on('tool(plugin-table)', function (obj) {
|
||||||
const id = obj.data.id;
|
const id = obj.data.id;
|
||||||
if (obj.event === 'createConfig') {
|
if (obj.event === 'pluginInstall') {
|
||||||
layer.msg(obj.event);
|
layer.msg(obj.event);
|
||||||
} else if (obj.event === 'pluginUpdate') {
|
} else if (obj.event === 'pluginUpdate') {
|
||||||
layer.msg(obj.event);
|
layer.msg(obj.event);
|
||||||
@ -117,9 +120,10 @@
|
|||||||
let plugin = {};
|
let plugin = {};
|
||||||
|
|
||||||
// 处理点击btn切换class
|
// 处理点击btn切换class
|
||||||
plugin.changClass = (ele) => {
|
plugin.changClass = (event) => {
|
||||||
const select = 'layui-btn layui-btn-primary layui-bg-green layui-btn-sm';
|
const select = 'layui-btn layui-btn-primary layui-bg-green layui-btn-sm';
|
||||||
const unselect = 'layui-btn layui-btn-primary layui-bg-gray layui-btn-sm';
|
const unselect = 'layui-btn layui-btn-primary layui-bg-gray layui-btn-sm';
|
||||||
|
const ele = document.querySelector(`button[lay-event="${event}"]`);
|
||||||
ele.className = select;
|
ele.className = select;
|
||||||
const btns = document.querySelectorAll(`button[grp-btn]`);
|
const btns = document.querySelectorAll(`button[grp-btn]`);
|
||||||
btns.forEach(val => {
|
btns.forEach(val => {
|
||||||
|
Loading…
Reference in New Issue
Block a user