mirror of
https://github.com/aoaostar/toolbox.git
synced 2025-12-27 15:01:17 +00:00
使用naive ui重构后台面板
重构用户系统,方便支持更多OAuth认证方式
重构插件系统,方便静态资源的添加
BREAKING CHANGE: 🧨 更改管理员身份认证为用户id
56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
||
declare (strict_types=1);
|
||
|
||
namespace app\command;
|
||
|
||
use think\console\Command;
|
||
use think\console\Input;
|
||
use think\console\input\Argument;
|
||
use think\console\Output;
|
||
use ZipArchive;
|
||
|
||
class PluginPackage extends Command
|
||
{
|
||
protected function configure()
|
||
{
|
||
// 指令配置
|
||
$this->setName('plugin:package')
|
||
->addArgument('space', Argument::REQUIRED, '插件域,例如:aoaostar_com')
|
||
->setDescription('打包指定域的所有插件');
|
||
}
|
||
|
||
protected function execute(Input $input, Output $output)
|
||
{
|
||
$space = $input->getArgument('space');
|
||
// 指令输出
|
||
$rootPath = app()->getRootPath() . '/plugin/';
|
||
if (!is_dir($rootPath . $space)) {
|
||
$output->writeln("该域不存在:[$space]");
|
||
return;
|
||
}
|
||
$plugins = glob($rootPath . $space . '/*');
|
||
$output->writeln("正在打包:[$space]下的文件");
|
||
foreach ($plugins as $plugin) {
|
||
$zip = new ZipArchive();
|
||
$filename = $rootPath . 'output/' . $space . DIRECTORY_SEPARATOR . basename($plugin) . '.zip';
|
||
if (!is_dir(dirname($filename))) {
|
||
mkdir(dirname($filename), 0755, true);
|
||
}
|
||
if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
|
||
|
||
$tree_relative = tree_relative($plugin);
|
||
$files = multi2one($tree_relative, '', '/');
|
||
foreach ($files as $file) {
|
||
if ($file !== '.' && $file !== '..') {
|
||
$zip->addFile($plugin . '/' . $file, $space . '/' . basename($plugin) . '/' . $file);
|
||
}
|
||
}
|
||
}
|
||
$zip->close();
|
||
$output->writeln("打包成功:[$filename]");
|
||
}
|
||
|
||
$output->writeln("该域所有文件都已打包完成:[$space]");
|
||
}
|
||
}
|