This commit is contained in:
2025-06-27 10:20:20 +08:00
9 changed files with 96 additions and 17 deletions

View File

@@ -35,3 +35,21 @@ MAX_ATTACHMENT_SIZE = 100mb; # 附件上传最大限制
[OPENAPI] [OPENAPI]
RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址 RESOURCE_IMAGES_DOMAIN = http://local.orico.com; # 图片资源服务器地址
RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址 RESOURCE_VIDEOS_DOMAIN = http://local.orico.com; # 视频资源服务器地址
# 视图模板规则配置
[VIEW_TPL]
# 视图目录
# query 规则URL参数 mtpl=1 表示移动端访问
# 例如http://xxxx.com?mtpl=1
# domain 规则:根据特定域名,判断是否移动端访问
# 例如http://mobile.orico.cn
RULE = query
# query 规则参数名
RULE_QUERY_NAME = mtpl
# query 规则参数值
RULE_QUERY_VALUE = 1
# domain 规则协议
RULE_DOMAIN_SCHEME[] = http
RULE_DOMAIN_SCHEME[] = https
# domain 规则域名
RULE_DOMAIN_HOST = mobile.orico.cn

View File

@@ -31,7 +31,7 @@ class Upload
$max_size = strtobytes(env('ADMIN_API.MAX_IMAGE_SIZE', '1mb')); $max_size = strtobytes(env('ADMIN_API.MAX_IMAGE_SIZE', '1mb'));
$validate = validate([ $validate = validate([
'module' => 'require|max:64', 'module' => 'require|max:64',
'image' => "fileSize:$max_size|fileExt:jpg,jpeg,png,gif" 'image' => "fileSize:$max_size|fileExt:jpg,jpeg,png,gif,webp"
]); ]);
if (!$validate->check(['module' => $param['module'], 'image' => $file])) { if (!$validate->check(['module' => $param['module'], 'image' => $file])) {
return error($validate->getError()); return error($validate->getError());
@@ -346,7 +346,7 @@ class Upload
try { try {
$max_size = strtobytes(env('ADMIN_API.MAX_ATTACHMENT_SIZE', '100mb')); $max_size = strtobytes(env('ADMIN_API.MAX_ATTACHMENT_SIZE', '100mb'));
$validate = validate([ $validate = validate([
'attachment' => "fileSize:$max_size|fileExt:biz,bz,bz2,gz,tgz,zip,rar,7z,doc,docx,xls,xlsx,csv,ppt,pptx,pdf,txt,jpg,jpeg,png,ttf" 'attachment' => "fileSize:$max_size|fileExt:biz,bz,bz2,gz,tgz,zip,rar,7z,doc,docx,xls,xlsx,csv,ppt,pptx,pdf,txt,jpg,jpeg,png,webp,ttf"
]); ]);
if (!$validate->check(['attachment' => $file])) { if (!$validate->check(['attachment' => $file])) {
return error($validate->getError()); return error($validate->getError());

View File

@@ -178,3 +178,47 @@ if (!function_exists('date_format_i18n')) {
return date($fmt, $timestamp); return date($fmt, $timestamp);
} }
} }
if (!function_exists('get_platform')) {
/**
* 获取平台
* @return string
*/
function get_platform(): string
{
$detect = new \Detection\MobileDetect();
$platform = 'pc';
if ($detect->isMobile() || $detect->isTablet()) {
$platform = 'mobile';
} else {
// 在非移动端环境,根据配置规则判断是否要显示移动端
$view_cfg = $view_cfg = [
'rule' => env('VIEW_TPL.RULE', 'query'),
'query' => [
'name' => env('VIEW_TPL.RULE_QUERY_NAME', 'mtpl'),
'value' => env('VIEW_TPL.RULE_QUERY_VALUE', '1'),
],
'domain' => [
'scheme' => env('VIEW_TPL.RULE_DOMAIN_SCHEME', ['http']),
'host' => env('VIEW_TPL.RULE_DOMAIN_HOST'),
],
];
if ($view_cfg['rule'] == 'query') {
$name = $view_cfg['query']['name'];
$value = $view_cfg['query']['value'];
if (request()->get($name) == $value) {
$platform = 'mobile';
}
} elseif ($view_cfg['rule'] == 'domain') {
$scheme = $view_cfg['domain']['scheme'];
$host = $view_cfg['domain']['host'];
if (in_array(request()->scheme(), $scheme) && $host == request()->host()) {
$platform = 'mobile';
}
}
}
return $platform;
}
}

View File

@@ -3,13 +3,7 @@
// | 模板设置 // | 模板设置
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
use Detection\MobileDetect; $view_device_name = get_platform();
$detect = new MobileDetect();
$view_device_name = 'pc';
if ($detect->isMobile() || $detect->isTablet() || request()->get('mtpl') == 1) {
$view_device_name = 'mobile';
}
return [ return [
// 模板引擎类型使用Think // 模板引擎类型使用Think

View File

@@ -15,10 +15,7 @@ class ConfirmRequestFrom
public function handle($request, \Closure $next) public function handle($request, \Closure $next)
{ {
// 确认请求来源 // 确认请求来源
$request->from = 'pc'; $request->from = get_platform();
if ($request->isMobile() || $request->get('mtpl') == 1) {
$request->from = 'mobile';
}
return $next($request); return $next($request);
} }

View File

@@ -30,7 +30,6 @@
{else/} {else/}
<div style="text-align: center; padding: 10%;">暂无数据</div> <div style="text-align: center; padding: 10%;">暂无数据</div>
{/notempty} {/notempty}
<div style=" text-align: center;padding: 10%;">暂无数据</div>
</div> </div>
</div> </div>
{/block} {/block}

View File

@@ -28,5 +28,31 @@
{include file="public/footer"/} {include file="public/footer"/}
{/block} {/block}
{block name="script"}{/block} {block name="script"}{/block}
<script>
$(window).ready(function () {
// 为所有站内链接,添加标识
// 使用mtpl=1参数标识解决ipad访问站点时从pc重定向到mobile每次页面都会pc - mobile闪现问题
var LURL = new URL(window.location.href);
if (LURL.searchParams.get('mtpl') == 1) {
$('a').each(function () {
var href = $(this).attr('href');
if (href) {
var origin = LURL.origin;
if (href.indexOf('http') == -1) {
href = new URL(href, origin);
href.searchParams.set('mtpl', '1');
$(this).attr('href', href);
} else {
href = new URL(href);
if (href.origin == origin) {
href.searchParams.set('mtpl', '1');
$(this).attr('href', href);
}
}
}
})
}
})
</script>
</body> </body>
</html> </html>

View File

@@ -18,7 +18,9 @@
{notempty name="fn.children"} {notempty name="fn.children"}
{volist name="fn.children" id="fnc"} {volist name="fn.children" id="fnc"}
<p> <p>
<a href="{$fnc.link}" target="_blank" class="inline-block link-faded break-all">{$fnc.name}</a> <a href="{$fnc.link}" {eq name="fnc.link" value="1"}target="_blank"{/eq} class="inline-block link-faded break-all">
{$fnc.name}
</a>
</p> </p>
{/volist} {/volist}
{/notempty} {/notempty}

View File

@@ -101,7 +101,6 @@
var windowHeight = $(window).height(); var windowHeight = $(window).height();
// 监听滚动事件 // 监听滚动事件
$(window).scroll(function() { $(window).scroll(function() {
console.log($(this).scrollTop(),windowHeight)
// 检查滚动距离是否超过一屏幕高度 // 检查滚动距离是否超过一屏幕高度
if ($(this).scrollTop() > windowHeight) { if ($(this).scrollTop() > windowHeight) {
// 如果超过,显示返回顶部按钮 // 如果超过,显示返回顶部按钮