[更新]修改代码结构

This commit is contained in:
Anyon 2017-05-15 16:21:22 +08:00
parent abce6fc35e
commit a41516814f
4 changed files with 21 additions and 23 deletions

View File

@ -67,7 +67,7 @@ class Menu extends BasicAdmin {
* 编辑菜单
*/
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) {
if (empty($_vo['is_menu'])) {
unset($nodes[$key]);

View File

@ -38,12 +38,11 @@ class Node extends BasicAdmin {
* 显示节点列表
*/
public function index() {
$alert = [
$this->assign('alert', [
'type' => 'danger',
'title' => '安全警告',
'content' => '结构为系统自动生成,状态数据请勿随意修改!'
];
$this->assign('alert', $alert);
]);
$this->assign('title', '系统节点管理');
$this->assign('nodes', ToolsService::arr2table(NodeService::get(), 'node', 'pnode'));
return view();

View File

@ -17,7 +17,6 @@ namespace hook;
use think\Config;
use think\exception\HttpResponseException;
use think\Request;
use think\Response;
use think\View;
/**

View File

@ -113,7 +113,7 @@ class FileService {
/**
* 获取AliOSS上传地址
* @return type
* @return string
*/
public static function getUploadOssUrl() {
return (request()->isSsl() ? 'https' : 'http') . '://' . sysconf('storage_oss_domain');
@ -198,30 +198,30 @@ class FileService {
/**
* 根据当前配置存储文件
* @param string $filename
* @param string $bodycontent
* @param string $content
* @param string|null $file_storage
* @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;
if (!method_exists(__CLASS__, $type)) {
Log::error("保存存储失败,调用{$type}存储引擎不存在!");
return false;
}
return self::$type($filename, $bodycontent);
return self::$type($filename, $content);
}
/**
* 文件储存在本地
* @param string $filename
* @param string $bodycontent
* @return string
* @param string $content
* @return array|null
*/
public static function local($filename, $bodycontent) {
public static function local($filename, $content) {
try {
$filepath = ROOT_PATH . 'static/upload/' . $filename;
!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;
return ['file' => $filepath, 'hash' => md5_file($filepath), 'key' => "upload/{$filename}", 'url' => $url];
}
@ -234,14 +234,14 @@ class FileService {
/**
* 七牛云存储
* @param string $filename
* @param string $bodycontent
* @return string
* @param string $content
* @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'));
$token = $auth->uploadToken(sysconf('storage_qiniu_bucket'));
$uploadMgr = new UploadManager();
list($result, $err) = $uploadMgr->put($token, $filename, $bodycontent);
list($result, $err) = $uploadMgr->put($token, $filename, $content);
if ($err !== null) {
Log::error('七牛云文件上传失败, ' . var_export($err, true));
return null;
@ -253,14 +253,14 @@ class FileService {
/**
* 阿里云OSS
* @param type $filename
* @param type $bodycontent
* @return type
* @param string $filename
* @param string $content
* @return array|null
*/
public static function oss($filename, $bodycontent) {
public static function oss($filename, $content) {
try {
$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']];
} catch (OssException $err) {
Log::error('阿里云OSS文件上传失败, ' . var_export($err, true));