兰空图床优化

简介

稳定
使用 Laravel 框架开发,庞大的生态系统和用户群体,为程序提供了健壮稳固的底层基础。
高效
多图上传、拖拽上传、粘贴上传、复制图片、复制链接、一键复制链接以及强大的图片管理功能。
安全
得益于强大的 Laravel 框架,我们无需在安全这方面考虑过多,它几乎已经帮我们做好了一切。

优化(社区版)

增加后台token获取

将以下代码加入/.../resources/views/common/api.blade.php合适位置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<div>
<p class="text-lg text-gray-700 font-semibold">Tonken获取</p>
<script src="//cdn.cnortles.top/npm/jquery/jquery.min.js"></script>
<form id="token" action="{{ request()->getSchemeAndHttpHost() }}/api/v1/tokens" method="POST">
<div class="my-2 text-sm">
<div class="form-group qqlogin" style="display: none;">
<div class="input-group-addon">邮箱</div>
<input type="email" id="email" name="email" value="{{ Auth::user()->email }}">
</div>
<div style="display: inline-flex;position: relative;">
<div class="px-4 py-3 text-right sm:px-6" style="color: #555;background-color: #eee;border: 1px solid #ccc;">密码</div>
<input type="password" id="password" name="password" placeholder="输入你的密码">
<a href="javascript:;" class="button px-4 py-3 sm:px-6" style="color: #fff;background-color: #337ab7;border-color: #2e6da4;margin-left:10px;">
<div>点击获取</div>
</a>
</div>
<div class="list-group">
<x-code>
<span style="color:tomato;user-select: none;">token:</span><span id="tokenCode"></span>
</x-code>
</div>
</form>
<script>
$(document).ready(function() {
$("#token .button").click(function() {
var url = $("#token").attr("action");
var email = $("#email").val();
var password = $("#password").val();
$.ajax({
type: 'post',
url: url,
data: {
email: email,
password: password
},
success: function(data) {
if (data.status == true) {
$("#tokenCode").html('Bearer ' + data.data.token)
} else {
if (data.message == "password 不能为空。") {
$("#tokenCode").html("密码不能为空!")
} else if (data.message == "The email address or password is incorrect.") {
$("#tokenCode").html("请确认密码是否正确!")
}
}
},
error: function() {
$("#tokenCode").html("请求过于频繁,请稍后再试!")
}
});

});
});
</script>
</div>

移除本地存储根目录限制

修改/.../app/Http/Requests/Admin/StrategyRequest.php文件的部分代码即可(注意缩进)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class StrategyRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$checkUrl = function ($attribute, $value, $fail) {
if ($this->input('key') == StrategyKey::Local) {
$folders = [config('app.thumbnail_path'), 'fonts', 'css', 'js'];
$symlink = Strategy::getRootPath($value);
// if (! $symlink) {
// return $fail('访问域名缺少根路径');
// }
// if (in_array($symlink, $folders)) {
// return $fail('系统保留路径:'. $symlink);
// }
// if (false !== strpbrk($symlink, "\\/?%*:|\"<>")) {
// return $fail('根路径名称不符合规则');
// }
// // 修改时单独判断
// if ($this->method() === 'PUT') {
// $symlinks = Strategy::query()
// ->where('id', '<>', $this->route('id'))
// ->pluck('configs')
// ->transform(function (Collection $configs) {
// return Strategy::getRootPath($configs->get('url'));
// })->merge($folders)->values()->toArray();
// if (in_array($symlink, $symlinks)) {
// return $fail('根路径已经存在');
// }
// } else {
// if (realpath(public_path($symlink))) {
// return $fail('根路径已经存在');
// }
// }
}
};