1 Star 0 Fork 12

Andy_xu/Tadmin

forked from Jon Lee/Tadmin 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
Init.php 1.44 KB
Copy Edit Raw Blame History
Jon Lee authored 2020-11-06 18:41 +08:00 . feat: update to thinkphp6
<?php
namespace tadmin\command;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use League\Flysystem\MountManager;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Loader;
class Init extends Command
{
protected function configure()
{
$this->setName('tadmin:init')->setDescription('init tadmin');
}
protected function execute(Input $input, Output $output)
{
$this->publishAssets();
}
protected function publishAssets()
{
$source = new Filesystem(
new Local(__DIR__ . '/../../resource/assets')
);
$traget = new Filesystem(
new Local($this->app->getRootPath() . 'public/tmp/assets')
);
$manager = new MountManager([
'source' => $source,
'traget' => $traget,
]);
$contents = $manager->listContents('source://', true);
foreach ($contents as $entry) {
$update = false;
if (!$manager->has('traget://' . $entry['path'])) {
$update = true;
} elseif ($manager->getTimestamp('source://' . $entry['path']) > $manager->getTimestamp('traget://' . $entry['path'])) {
$update = true;
}
if ('file' === $entry['type'] && $update) {
$manager->put('traget://' . $entry['path'], $manager->read('source://' . $entry['path']));
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/Andy_Code/tadmin.git
git@gitee.com:Andy_Code/tadmin.git
Andy_Code
tadmin
Tadmin
master

Search