save
This commit is contained in:
parent
0101e2437e
commit
ef3e693e48
@ -45,14 +45,7 @@ class PluginController extends Base
|
|||||||
*/
|
*/
|
||||||
public function list(Request $request): Response
|
public function list(Request $request): Response
|
||||||
{
|
{
|
||||||
$installed = [];
|
$installed = $this->getLocalPlugins();
|
||||||
clearstatcache();
|
|
||||||
$plugin_names = array_diff(scandir(base_path() . '/plugin/'), array('.', '..')) ?: [];
|
|
||||||
foreach ($plugin_names as $plugin_name) {
|
|
||||||
if (is_dir(base_path() . "/plugin/$plugin_name") && $version = $this->getPluginVersion($plugin_name)) {
|
|
||||||
$installed[$plugin_name] = $version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$client = $this->httpClient();
|
$client = $this->httpClient();
|
||||||
$query = $request->get();
|
$query = $request->get();
|
||||||
@ -67,13 +60,13 @@ class PluginController extends Base
|
|||||||
return $this->json(1, '获取数据出错');
|
return $this->json(1, '获取数据出错');
|
||||||
}
|
}
|
||||||
$disabled = is_phar();
|
$disabled = is_phar();
|
||||||
foreach ($data['result']['items'] as $key => $item) {
|
foreach ($data['data']['items'] as $key => $item) {
|
||||||
$name = $item['name'];
|
$name = $item['name'];
|
||||||
$data['result']['items'][$key]['installed'] = $installed[$name] ?? 0;
|
$data['data']['items'][$key]['installed'] = $installed[$name] ?? 0;
|
||||||
$data['result']['items'][$key]['disabled'] = $disabled;
|
$data['data']['items'][$key]['disabled'] = $disabled;
|
||||||
}
|
}
|
||||||
$items = $data['result']['items'];
|
$items = $data['data']['items'];
|
||||||
$count = $data['result']['total'];
|
$count = $data['data']['total'];
|
||||||
return json(['code' => 0, 'msg' => 'ok', 'data' => $items, 'count' => $count]);
|
return json(['code' => 0, 'msg' => 'ok', 'data' => $items, 'count' => $count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +81,7 @@ class PluginController extends Base
|
|||||||
$client = $this->httpClient();
|
$client = $this->httpClient();
|
||||||
$response = $client->get('/api/app/schema', ['query' => $request->get()]);
|
$response = $client->get('/api/app/schema', ['query' => $request->get()]);
|
||||||
$data = json_decode((string)$response->getBody(), true);
|
$data = json_decode((string)$response->getBody(), true);
|
||||||
$result = $data['result'];
|
$result = $data['data'];
|
||||||
foreach ($result as &$item) {
|
foreach ($result as &$item) {
|
||||||
$item['field'] = $item['field'] ?? $item['dataIndex'];
|
$item['field'] = $item['field'] ?? $item['dataIndex'];
|
||||||
unset($item['dataIndex']);
|
unset($item['dataIndex']);
|
||||||
@ -113,24 +106,13 @@ class PluginController extends Base
|
|||||||
|
|
||||||
$user = session('app-plugin-user');
|
$user = session('app-plugin-user');
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return $this->json(0, '请登录', [
|
return $this->json(-1, '请登录');
|
||||||
'code' => 401,
|
|
||||||
'msg' => '请登录'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取下载zip文件url
|
// 获取下载zip文件url
|
||||||
$data = $this->getDownloadUrl($name, $version);
|
$data = $this->getDownloadUrl($name, $version);
|
||||||
if ($data['code'] == -1) {
|
if ($data['code'] != 0) {
|
||||||
return $this->json(0, '请登录', [
|
return $this->json($data['code'], $data['msg'], $data['data'] ?? []);
|
||||||
'code' => 401,
|
|
||||||
'msg' => '请登录'
|
|
||||||
]);
|
|
||||||
} elseif ($data['code'] == -2) {
|
|
||||||
return $this->json(0, '未购买此插件', [
|
|
||||||
'code' => 402,
|
|
||||||
'msg' => '未购买此插件'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载zip文件
|
// 下载zip文件
|
||||||
@ -422,6 +404,34 @@ class PluginController extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取已安装的插件列表
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getLocalPlugins(): array
|
||||||
|
{
|
||||||
|
clearstatcache();
|
||||||
|
$installed = [];
|
||||||
|
$plugin_names = array_diff(scandir(base_path() . '/plugin/'), array('.', '..')) ?: [];
|
||||||
|
foreach ($plugin_names as $plugin_name) {
|
||||||
|
if (is_dir(base_path() . "/plugin/$plugin_name") && $version = $this->getPluginVersion($plugin_name)) {
|
||||||
|
$installed[$plugin_name] = $version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取已安装的插件列表
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function getInstalledPlugins(Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->json(0, 'ok', $this->getLocalPlugins());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取本地插件版本
|
* 获取本地插件版本
|
||||||
* @param $name
|
* @param $name
|
||||||
|
@ -98,7 +98,7 @@ CREATE TABLE IF NOT EXISTS `wa_users` (
|
|||||||
`mobile` varchar(16) DEFAULT NULL COMMENT '手机',
|
`mobile` varchar(16) DEFAULT NULL COMMENT '手机',
|
||||||
`level` tinyint(4) NOT NULL DEFAULT '0' COMMENT '等级',
|
`level` tinyint(4) NOT NULL DEFAULT '0' COMMENT '等级',
|
||||||
`birthday` date DEFAULT NULL COMMENT '生日',
|
`birthday` date DEFAULT NULL COMMENT '生日',
|
||||||
`money` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '余额(分)',
|
`money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '余额(元)',
|
||||||
`score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
|
`score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
|
||||||
`last_time` datetime DEFAULT NULL COMMENT '登录时间',
|
`last_time` datetime DEFAULT NULL COMMENT '登录时间',
|
||||||
`last_ip` varchar(50) DEFAULT NULL COMMENT '登录ip',
|
`last_ip` varchar(50) DEFAULT NULL COMMENT '登录ip',
|
||||||
|
Loading…
Reference in New Issue
Block a user