1
0
mirror of https://gitee.com/zoujingli/ThinkAdmin.git synced 2025-04-06 03:58:04 +08:00

增加本地服务器上传返回类型配置

This commit is contained in:
Anyon 2020-01-11 15:43:58 +08:00
parent b860357780
commit 160f2cc88f
8 changed files with 56 additions and 23 deletions

@ -2,7 +2,7 @@
<div class="layui-card-body"> <div class="layui-card-body">
<div class="color-text margin-left-40 margin-bottom-20 layui-code text-center layui-bg-gray" style="border-left-width:1px"> <div class="color-text margin-left-40 margin-bottom-20 layui-code text-center layui-bg-gray" style="border-left-width:1px">
<p class="margin-bottom-5 font-w7">文件将上传到阿里云 OSS 存储,需要配置 OSS 公开访问及跨域策略</p> <p class="margin-bottom-5 font-w7">文件将上传到阿里云 OSS 存储,需要配置 OSS 公开访问及跨域策略</p>
<p>直传需要配置跨域规则,设置来源为 *,允许 Methods 为 POST允许 Headers 为 *</p> <p>直传需要配置跨域规则,设置来源为 *,允许 Methods 为 POST允许 Headers 为 *</p>
</div> </div>
@ -12,7 +12,7 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input"> <input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<p class="help-block">设置系统允许上传文件的后缀,多个以英文逗号隔开png,jpg,rar,doc</p> <p class="help-block">设置系统允许上传文件的后缀多个以英文逗号隔开如png,jpg,rar,doc</p>
</div> </div>
</div> </div>
@ -30,7 +30,7 @@
{/if} {/if}
</label> </label>
{/foreach} {/foreach}
<p class="help-block">阿里云OSS存储访问协议其中 https 需要配置证书才能使用auto 为相对协议。</p> <p class="help-block">阿里云OSS存储访问协议其中 https 需要配置证书才能使用auto 为相对协议)</p>
</div> </div>
</div> </div>
@ -48,7 +48,7 @@
{/if} {/if}
{/foreach} {/foreach}
</select> </select>
<p class="help-block">阿里云OSS存储空间所在区域需要严格对应储存所在区域才能上传文件</p> <p class="help-block">阿里云OSS存储空间所在区域需要严格对应储存所在区域才能上传文件</p>
</div> </div>
</div> </div>
@ -78,7 +78,7 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input id="storage.alioss_access_key" type="text" name="storage.alioss_access_key" required value="{:sysconf('storage.alioss_access_key')}" placeholder="请输入阿里云OSS存储 AccessKey (访问密钥)" class="layui-input"> <input id="storage.alioss_access_key" type="text" name="storage.alioss_access_key" required value="{:sysconf('storage.alioss_access_key')}" placeholder="请输入阿里云OSS存储 AccessKey (访问密钥)" class="layui-input">
<p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到访问密钥</p> <p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到访问密钥</p>
</div> </div>
</div> </div>
@ -88,7 +88,7 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input id="storage.alioss_secret_key" type="text" name="storage.alioss_secret_key" required value="{:sysconf('storage.alioss_secret_key')}" maxlength="43" placeholder="请输入阿里云OSS存储 SecretKey (安全密钥)" class="layui-input"> <input id="storage.alioss_secret_key" type="text" name="storage.alioss_secret_key" required value="{:sysconf('storage.alioss_secret_key')}" maxlength="43" placeholder="请输入阿里云OSS存储 SecretKey (安全密钥)" class="layui-input">
<p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到安全密钥</p> <p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到安全密钥</p>
</div> </div>
</div> </div>

@ -16,6 +16,24 @@
</div> </div>
</div> </div>
<div class="layui-form-item">
<label class="layui-form-label label-required">
<span class="color-green font-w7">Protocol</span><br><span class="nowrap color-desc">访问协议</span>
</label>
<div class="layui-input-block">
{foreach ['follow','http','https','path','auto'] as $pro}
<label class="think-radio">
{if sysconf('storage.local_http_protocol') eq $pro}
<input checked type="radio" name="storage.local_http_protocol" value="{$pro}" lay-ignore> {$pro}
{else}
<input type="radio" name="storage.local_http_protocol" value="{$pro}" lay-ignore> {$pro}
{/if}
</label>
{/foreach}
<p class="help-block">本地服务器访问协议,其中 https 需要配置证书才能使用follow 为跟随系统path 为文件路径auto 为相对协议)</p>
</div>
</div>
<div class="hr-line-dashed margin-left-40"></div> <div class="hr-line-dashed margin-left-40"></div>
<input type="hidden" name="storage.type" value="local"> <input type="hidden" name="storage.type" value="local">

@ -2,7 +2,7 @@
<div class="layui-card-body"> <div class="layui-card-body">
<div class="color-text margin-left-40 margin-bottom-20 layui-code text-center layui-bg-gray" style="border-left-width:1px"> <div class="color-text margin-left-40 margin-bottom-20 layui-code text-center layui-bg-gray" style="border-left-width:1px">
<p class="margin-bottom-5 font-w7">文件将上传到七牛云存储,对象存储需要配置为公开访问的 Bucket 空间</p> <p class="margin-bottom-5 font-w7">文件将上传到七牛云存储,对象存储需要配置为公开访问的 Bucket 空间</p>
完成实名认证后可获得10G免费存储空间哦<a target="_blank" href="https://portal.qiniu.com/signup?code=3lhz6nmnwbple">我要免费申请</a> 完成实名认证后可获得10G免费存储空间哦<a target="_blank" href="https://portal.qiniu.com/signup?code=3lhz6nmnwbple">我要免费申请</a>
</div> </div>
@ -12,7 +12,7 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input"> <input id="storage.allow_exts" type="text" name="storage.allow_exts" required value="{:sysconf('storage.allow_exts')}" placeholder="请输入系统文件上传后缀" class="layui-input">
<p class="help-block">设置系统允许上传文件的后缀,多个以英文逗号隔开png,jpg,rar,doc</p> <p class="help-block">设置系统允许上传文件的后缀多个以英文逗号隔开如png,jpg,rar,doc</p>
</div> </div>
</div> </div>
@ -30,7 +30,7 @@
{/if} {/if}
</label> </label>
{/foreach} {/foreach}
<p class="help-block">七牛云存储访问协议,其中 https 需要配置证书才能使用auto 为相对协议。</p> <p class="help-block">七牛云存储访问协议,其中 https 需要配置证书才能使用auto 为相对协议)</p>
</div> </div>
</div> </div>
@ -49,7 +49,7 @@
{$area} {$area}
</label> </label>
{/foreach} {/foreach}
<p class="help-block">七牛云存储空间所在区域,需要严格对应储存所在区域才能上传文件</p> <p class="help-block">七牛云存储空间所在区域,需要严格对应储存所在区域才能上传文件</p>
</div> </div>
</div> </div>
@ -79,7 +79,7 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input id="storage.qiniu_access_key" type="text" name="storage.qiniu_access_key" required value="{:sysconf('storage.qiniu_access_key')}" placeholder="请输入七牛云 AccessKey (访问密钥)" class="layui-input"> <input id="storage.qiniu_access_key" type="text" name="storage.qiniu_access_key" required value="{:sysconf('storage.qiniu_access_key')}" placeholder="请输入七牛云 AccessKey (访问密钥)" class="layui-input">
<p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到访问密钥</p> <p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到访问密钥</p>
</div> </div>
</div> </div>
@ -89,7 +89,7 @@
</label> </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input id="storage.qiniu_secret_key" type="text" name="storage.qiniu_secret_key" required value="{:sysconf('storage.qiniu_secret_key')}" maxlength="43" placeholder="请输入七牛云 SecretKey (安全密钥)" class="layui-input"> <input id="storage.qiniu_secret_key" type="text" name="storage.qiniu_secret_key" required value="{:sysconf('storage.qiniu_secret_key')}" maxlength="43" placeholder="请输入七牛云 SecretKey (安全密钥)" class="layui-input">
<p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到安全密钥</p> <p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到安全密钥</p>
</div> </div>
</div> </div>

@ -2,7 +2,7 @@
<html lang="zh"> <html lang="zh">
<head> <head>
<title></title> <title>{block name="title"}{$title|default=''}{if !empty($title)} · {/if}{:sysconf('site_name')}{/block}</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">

8
composer.lock generated

@ -909,12 +909,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "7d1a3dfdeab8aa4868dea3c1407170680127c412" "reference": "373ab0c31fc4247e9f71ecb86bf5f1e6e0dadea5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7d1a3dfdeab8aa4868dea3c1407170680127c412", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/373ab0c31fc4247e9f71ecb86bf5f1e6e0dadea5",
"reference": "7d1a3dfdeab8aa4868dea3c1407170680127c412", "reference": "373ab0c31fc4247e9f71ecb86bf5f1e6e0dadea5",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -958,7 +958,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top", "homepage": "http://framework.thinkadmin.top",
"time": "2020-01-10T04:15:10+00:00" "time": "2020-01-11T07:36:56+00:00"
}, },
{ {
"name": "zoujingli/wechat-developer", "name": "zoujingli/wechat-developer",

@ -935,12 +935,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "7d1a3dfdeab8aa4868dea3c1407170680127c412" "reference": "373ab0c31fc4247e9f71ecb86bf5f1e6e0dadea5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7d1a3dfdeab8aa4868dea3c1407170680127c412", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/373ab0c31fc4247e9f71ecb86bf5f1e6e0dadea5",
"reference": "7d1a3dfdeab8aa4868dea3c1407170680127c412", "reference": "373ab0c31fc4247e9f71ecb86bf5f1e6e0dadea5",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -956,7 +956,7 @@
"ext-json": "*", "ext-json": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-01-10T04:15:10+00:00", "time": "2020-01-11T07:36:56+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-01-11 12:10:01 // This file is automatically generated at:2020-01-11 15:43:21
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

@ -24,13 +24,28 @@ use think\admin\Storage;
*/ */
class LocalStorage extends Storage class LocalStorage extends Storage
{ {
/** /**
* 初始化入口 * 初始化入口
* @return LocalStorage * @return LocalStorage
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/ */
protected function initialize(): Storage protected function initialize(): Storage
{ {
$this->prefix = dirname($this->app->request->basefile(true)); // 计算链接前缀
$type = strtolower(sysconf('storage.local_http_protocol'));
if ($type === 'path') {
$file = $this->app->request->baseFile(false);
$this->prefix = dirname(strtr($file, '\\', '/'));
} else {
$this->prefix = dirname($this->app->request->basefile(true));
list(, $domain) = explode('://', strtr($this->prefix, '\\', '/'));
if ($type === 'auto') $this->prefix = "//{$domain}";
elseif ($type === 'http') $this->prefix = "http://{$domain}";
elseif ($type === 'https') $this->prefix = "https://{$domain}";
}
return $this; return $this;
} }