mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-22 07:04:24 +00:00
feat:优化内容分发网络URL相关处理
This commit is contained in:
parent
8e1e9e49bb
commit
d6a9b5cae3
@ -31,6 +31,7 @@ class Index extends Backend
|
||||
'siteConfig' => [
|
||||
'site_name' => get_sys_config('site_name'),
|
||||
'version' => get_sys_config('version'),
|
||||
'cdn_url' => full_url(),
|
||||
],
|
||||
'terminal' => [
|
||||
'install_service_port' => Config::get('buildadmin.install_service_port'),
|
||||
|
@ -21,6 +21,7 @@ class Index extends Frontend
|
||||
'site_name' => get_sys_config('site_name'),
|
||||
'record_number' => get_sys_config('record_number'),
|
||||
'version' => get_sys_config('version'),
|
||||
'cdn_url' => full_url(),
|
||||
],
|
||||
'open_member_center' => Config::get('buildadmin.open_member_center'),
|
||||
]);
|
||||
|
@ -150,15 +150,21 @@ if (!function_exists('full_url')) {
|
||||
*/
|
||||
function full_url($relativeUrl = false, $domain = true, $default = '')
|
||||
{
|
||||
$relativeUrl = $relativeUrl ? $relativeUrl : $default;
|
||||
if (!$relativeUrl) {
|
||||
return $domain === true ? request()->domain() : $domain;
|
||||
$cdnUrl = Config::get('buildadmin.cdn_url');
|
||||
if ($domain === true) {
|
||||
$domain = $cdnUrl ? $cdnUrl : request()->domain();
|
||||
} elseif ($domain === false) {
|
||||
$domain = '';
|
||||
}
|
||||
|
||||
$relativeUrl = $relativeUrl ? $relativeUrl : $default;
|
||||
if (!$relativeUrl) return $domain;
|
||||
|
||||
$regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i";
|
||||
if (preg_match('/^http(s)?:\/\//', $relativeUrl) || preg_match($regex, $relativeUrl) || $domain === false) {
|
||||
return $relativeUrl;
|
||||
}
|
||||
return $domain === true ? request()->domain() . $relativeUrl : $domain . $relativeUrl;
|
||||
return $domain . $relativeUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,8 @@ return [
|
||||
'auto_write_admin_log' => true,
|
||||
// 缺省头像图片路径
|
||||
'default_avatar' => '/static/images/avatar.png',
|
||||
// 内容分发网络URL
|
||||
'cdn_url' => '',
|
||||
// 版本号
|
||||
'version' => 'v1.0.3',
|
||||
];
|
@ -121,4 +121,5 @@ export interface SiteConfig {
|
||||
site_name: string
|
||||
record_number?: string
|
||||
version: string
|
||||
cdn_url: string
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ export const useSiteConfig = defineStore('siteConfig', {
|
||||
site_name: '',
|
||||
record_number: '',
|
||||
version: '',
|
||||
cdn_url: '',
|
||||
}
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user