Skip to content

Commit

Permalink
支持设置图片 url 额外参数 Closed #435
Browse files Browse the repository at this point in the history
  • Loading branch information
0xxb committed May 30, 2022
1 parent 8f0db08 commit c0513f8
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 175 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
[演示](https://pic.iqy.ink) ·
[Telegram 群组](https://t.me/lsky_pro)

> 正式版本请点击 [这里](https://github.com/lsky-org/lsky-pro/releases) 下载,发现 bug 请提交 [issues](https://github.com/lsky-org/lsky-pro/issues) (提问前建议阅读[提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md))
> master 分支为未安装三方拓展的版本,通常包含了最新未发布版本的一些实验性新特性和修复补丁,正式版本请点击 [这里](https://github.com/lsky-org/lsky-pro/releases) 下载。
> 发现 bug 请提交 [issues](https://github.com/lsky-org/lsky-pro/issues) (提问前建议阅读[提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md))
> 有任何想法、建议、或分享,请移步 [社区](https://github.com/lsky-org/lsky-pro/discussions)
![看不见图片请使用科学上网](https://user-images.githubusercontent.com/22728201/157242302-bfbd04a0-fb30-4241-800e-cc2b1dad9b19.png)
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Requests/Admin/StrategyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function rules()
'intro' => 'max:2000',
'key' => 'required|integer',
'configs.url' => ['required', 'url'],
'configs.queries' => '',
];

return array_merge($array, match((int)$this->input('key')) {
Expand Down Expand Up @@ -141,6 +142,7 @@ public function attributes()
'intro' => '简介',
'key' => '策略',
'configs.url' => '访问网址',
'configs.queries' => 'Url 额外参数',
];

return array_merge($array, match((int)$this->input('key')) {
Expand Down
7 changes: 5 additions & 2 deletions app/Models/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,13 @@ public function url(): Attribute
return new Attribute(function () {
// 是否启用原图保护功能
if ($this->group?->configs->get(GroupConfigKey::IsEnableOriginalProtection)) {
return asset("{$this->key}.{$this->extension}");
$url = asset("{$this->key}.{$this->extension}");
} else {
return rtrim($this->strategy?->configs->get('url'), '/').'/'.ltrim($this->pathname, '/');
$url = rtrim($this->strategy?->configs->get('url'), '/').'/'.ltrim($this->pathname, '/');
}

// 拼接图片 url
return $url.($this->strategy?->configs->get('queries') ?: '');
});
}

Expand Down
Loading

0 comments on commit c0513f8

Please sign in to comment.