Update application_controller.rb

This commit is contained in:
TianLun Song 2025-01-27 08:23:44 +08:00 committed by GitHub
parent a895216bda
commit 263c85486c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,41 +2,28 @@ class ApplicationController < ActionController::Base
include SeoConcern include SeoConcern
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
# allow_browser versions: :modern # allow_browser versions: :modern
allow_browser versions: :modern do |config| allow_browser versions: :modern,
# 通用移动浏览器 patterns: [
config.allow(/Mobile Safari/) # iOS Safari /Mobile Safari/,
config.allow(/Chrome\/[\d.]+/) # Chrome 内核浏览器 /Chrome\/[\d.]+/,
/Quark\/[\d.]+/,
# 国内主流浏览器 /HuaweiBrowser\/[\d.]+/,
config.allow(/Quark\/[\d.]+/) # 夸克浏览器 /MiuiBrowser\/[\d.]+/,
config.allow(/HuaweiBrowser\/[\d.]+/) # 华为浏览器 /VivoBrowser\/[\d.]+/,
config.allow(/MiuiBrowser\/[\d.]+/) # 小米浏览器 /OppoBrowser\/[\d.]+/,
config.allow(/VivoBrowser\/[\d.]+/) # vivo浏览器 /UCBrowser\/[\d.]+/,
config.allow(/OppoBrowser\/[\d.]+/) # OPPO浏览器 /QQBrowser\/[\d.]+/,
config.allow(/UCBrowser\/[\d.]+/) # UC浏览器 /MicroMessenger\/[\d.]+/,
config.allow(/QQBrowser\/[\d.]+/) # QQ浏览器 /Alipay/,
config.allow(/MicroMessenger\/[\d.]+/) # 微信内置浏览器 /BaiduBoxApp/,
config.allow(/Alipay/) # 支付宝内置浏览器 /baiduboxapp/i,
config.allow(/BaiduBoxApp/) # 百度 App /SogouMobile/,
config.allow(/baiduboxapp/i) # 百度 App (小写) /Weibo/,
config.allow(/SogouMobile/) # 搜狗移动浏览器 /DingTalk/,
config.allow(/Weibo/) # 微博内置浏览器 /ToutiaoMicroApp/,
config.allow(/DingTalk/) # 钉钉内置浏览器 /BytedanceWebview/,
config.allow(/ToutiaoMicroApp/) # 今日头条小程序 /ArkWeb/
config.allow(/BytedanceWebview/) # 字节跳动系浏览器 ]
config.allow(/ArkWeb/) # 鸿蒙浏览器
# 调试日志(开发环境)
if Rails.env.development?
config.on_failure do |browser|
Rails.logger.info <<~INFO
Browser blocked:
Name: #{browser.name}
Version: #{browser.version}
User Agent: #{browser.ua}
INFO
end
end
end end
before_action :set_locale before_action :set_locale
after_action :track_action after_action :track_action