mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]修改代码结构
This commit is contained in:
parent
abce6fc35e
commit
a41516814f
@ -67,7 +67,7 @@ class Menu extends BasicAdmin {
|
|||||||
* 编辑菜单
|
* 编辑菜单
|
||||||
*/
|
*/
|
||||||
public function edit() {
|
public function edit() {
|
||||||
return $this->add();
|
return $this->_form($this->table, 'form');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +93,7 @@ class Menu extends BasicAdmin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 读取系统功能节点
|
// 读取系统功能节点
|
||||||
$nodes = NodeService::get(APP_PATH);
|
$nodes = NodeService::get();
|
||||||
foreach ($nodes as $key => $_vo) {
|
foreach ($nodes as $key => $_vo) {
|
||||||
if (empty($_vo['is_menu'])) {
|
if (empty($_vo['is_menu'])) {
|
||||||
unset($nodes[$key]);
|
unset($nodes[$key]);
|
||||||
|
@ -38,12 +38,11 @@ class Node extends BasicAdmin {
|
|||||||
* 显示节点列表
|
* 显示节点列表
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
$alert = [
|
$this->assign('alert', [
|
||||||
'type' => 'danger',
|
'type' => 'danger',
|
||||||
'title' => '安全警告',
|
'title' => '安全警告',
|
||||||
'content' => '结构为系统自动生成,状态数据请勿随意修改!'
|
'content' => '结构为系统自动生成,状态数据请勿随意修改!'
|
||||||
];
|
]);
|
||||||
$this->assign('alert', $alert);
|
|
||||||
$this->assign('title', '系统节点管理');
|
$this->assign('title', '系统节点管理');
|
||||||
$this->assign('nodes', ToolsService::arr2table(NodeService::get(), 'node', 'pnode'));
|
$this->assign('nodes', ToolsService::arr2table(NodeService::get(), 'node', 'pnode'));
|
||||||
return view();
|
return view();
|
||||||
|
@ -17,7 +17,6 @@ namespace hook;
|
|||||||
use think\Config;
|
use think\Config;
|
||||||
use think\exception\HttpResponseException;
|
use think\exception\HttpResponseException;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
use think\Response;
|
|
||||||
use think\View;
|
use think\View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +113,7 @@ class FileService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取AliOSS上传地址
|
* 获取AliOSS上传地址
|
||||||
* @return type
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getUploadOssUrl() {
|
public static function getUploadOssUrl() {
|
||||||
return (request()->isSsl() ? 'https' : 'http') . '://' . sysconf('storage_oss_domain');
|
return (request()->isSsl() ? 'https' : 'http') . '://' . sysconf('storage_oss_domain');
|
||||||
@ -198,30 +198,30 @@ class FileService {
|
|||||||
/**
|
/**
|
||||||
* 根据当前配置存储文件
|
* 根据当前配置存储文件
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param string $bodycontent
|
* @param string $content
|
||||||
* @param string|null $file_storage
|
* @param string|null $file_storage
|
||||||
* @return array|false
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
public static function save($filename, $bodycontent, $file_storage = null) {
|
public static function save($filename, $content, $file_storage = null) {
|
||||||
$type = empty($file_storage) ? sysconf('storage_type') : $file_storage;
|
$type = empty($file_storage) ? sysconf('storage_type') : $file_storage;
|
||||||
if (!method_exists(__CLASS__, $type)) {
|
if (!method_exists(__CLASS__, $type)) {
|
||||||
Log::error("保存存储失败,调用{$type}存储引擎不存在!");
|
Log::error("保存存储失败,调用{$type}存储引擎不存在!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return self::$type($filename, $bodycontent);
|
return self::$type($filename, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件储存在本地
|
* 文件储存在本地
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param string $bodycontent
|
* @param string $content
|
||||||
* @return string
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function local($filename, $bodycontent) {
|
public static function local($filename, $content) {
|
||||||
try {
|
try {
|
||||||
$filepath = ROOT_PATH . 'static/upload/' . $filename;
|
$filepath = ROOT_PATH . 'static/upload/' . $filename;
|
||||||
!file_exists(dirname($filepath)) && mkdir(dirname($filepath), '0755', true);
|
!file_exists(dirname($filepath)) && mkdir(dirname($filepath), '0755', true);
|
||||||
if (file_put_contents($filepath, $bodycontent)) {
|
if (file_put_contents($filepath, $content)) {
|
||||||
$url = pathinfo(request()->baseFile(true), PATHINFO_DIRNAME) . '/upload/' . $filename;
|
$url = pathinfo(request()->baseFile(true), PATHINFO_DIRNAME) . '/upload/' . $filename;
|
||||||
return ['file' => $filepath, 'hash' => md5_file($filepath), 'key' => "upload/{$filename}", 'url' => $url];
|
return ['file' => $filepath, 'hash' => md5_file($filepath), 'key' => "upload/{$filename}", 'url' => $url];
|
||||||
}
|
}
|
||||||
@ -234,14 +234,14 @@ class FileService {
|
|||||||
/**
|
/**
|
||||||
* 七牛云存储
|
* 七牛云存储
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param string $bodycontent
|
* @param string $content
|
||||||
* @return string
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function qiniu($filename, $bodycontent) {
|
public static function qiniu($filename, $content) {
|
||||||
$auth = new Auth(sysconf('storage_qiniu_access_key'), sysconf('storage_qiniu_secret_key'));
|
$auth = new Auth(sysconf('storage_qiniu_access_key'), sysconf('storage_qiniu_secret_key'));
|
||||||
$token = $auth->uploadToken(sysconf('storage_qiniu_bucket'));
|
$token = $auth->uploadToken(sysconf('storage_qiniu_bucket'));
|
||||||
$uploadMgr = new UploadManager();
|
$uploadMgr = new UploadManager();
|
||||||
list($result, $err) = $uploadMgr->put($token, $filename, $bodycontent);
|
list($result, $err) = $uploadMgr->put($token, $filename, $content);
|
||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
Log::error('七牛云文件上传失败, ' . var_export($err, true));
|
Log::error('七牛云文件上传失败, ' . var_export($err, true));
|
||||||
return null;
|
return null;
|
||||||
@ -253,14 +253,14 @@ class FileService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云OSS
|
* 阿里云OSS
|
||||||
* @param type $filename
|
* @param string $filename
|
||||||
* @param type $bodycontent
|
* @param string $content
|
||||||
* @return type
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public static function oss($filename, $bodycontent) {
|
public static function oss($filename, $content) {
|
||||||
try {
|
try {
|
||||||
$ossClient = new OssClient(sysconf('storage_oss_keyid'), sysconf('storage_oss_secret'), self::getBaseUriOss(), true);
|
$ossClient = new OssClient(sysconf('storage_oss_keyid'), sysconf('storage_oss_secret'), self::getBaseUriOss(), true);
|
||||||
$result = $ossClient->putObject(sysconf('storage_oss_bucket'), $filename, $bodycontent);
|
$result = $ossClient->putObject(sysconf('storage_oss_bucket'), $filename, $content);
|
||||||
return ['file' => $filename, 'hash' => $result['content-md5'], 'key' => $filename, 'url' => $result['oss-request-url']];
|
return ['file' => $filename, 'hash' => $result['content-md5'], 'key' => $filename, 'url' => $result['oss-request-url']];
|
||||||
} catch (OssException $err) {
|
} catch (OssException $err) {
|
||||||
Log::error('阿里云OSS文件上传失败, ' . var_export($err, true));
|
Log::error('阿里云OSS文件上传失败, ' . var_export($err, true));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user