diff --git a/app/controllers/udid_controller.rb b/app/controllers/udid_controller.rb index d31406ed1..dd8c453e1 100644 --- a/app/controllers/udid_controller.rb +++ b/app/controllers/udid_controller.rb @@ -49,10 +49,11 @@ def update def register apple_key = AppleKey.find(device_params[:apple_keys]) name = device_params[:name] - name = [ 'Zealot', params[:product], SecureRandom.hex(4) ].compact.join('-') if name.blank? # Max 50 chars - udid = params[:udid] + udid = device_params[:udid] + platform = device_params[:platform].downcase.include?('iphone') ? 'IOS' : 'MAC_OS' + name = [ 'Zealot', platform, SecureRandom.hex(4) ].compact.join('-') if name.blank? # Max 50 chars - new_device = apple_key.register_device(udid, name) + new_device = apple_key.register_device(udid, name, platform) unless new_device.valid? logger.debug "Register failed with errors: #{new_device.errors}" error_message = new_device.errors.messages[:devices][0] @@ -130,6 +131,6 @@ def set_apple_key end def device_params - params.require(:device).permit(:name, :apple_keys, :sync_to_apple_key) + @device_params ||= params.require(:device).permit(:name, :udid, :platform, :apple_keys, :sync_to_apple_key) end end diff --git a/app/javascript/controllers/udid_controller.js b/app/javascript/controllers/udid_controller.js index 881238ae0..ad7b0a967 100644 --- a/app/javascript/controllers/udid_controller.js +++ b/app/javascript/controllers/udid_controller.js @@ -1,21 +1,22 @@ import { Controller } from "@hotwired/stimulus" -import { uaParser, isiOS, isNonAppleOS } from "./utils" +import { uaParser, isiOS, isMacOS } from "./utils" export default class extends Controller { static targets = ["qrcode", "install", "tip", "debug"] static values = { appleTip: String, + macosTip: String, nonappleTip: String } connect() { - if (isNonAppleOS()) { - this.installTarget.classList.add("d-none") - this.tipTarget.innerHTML = this.nonappleTipValue - } else if (isiOS()) { + if (isiOS()) { this.qrcodeTarget.classList.add("d-none") + } else if (isMacOS()) { + this.tipTarget.innerText = this.macosTipValue } else { this.installTarget.classList.add("d-none") + this.tipTarget.innerText = this.nonappleTipValue } this.renderDebugZone @@ -49,4 +50,4 @@ export default class extends Controller { this.debugTarget.value = message } -} \ No newline at end of file +} diff --git a/app/models/apple_key.rb b/app/models/apple_key.rb index 746e24466..dafba20a9 100644 --- a/app/models/apple_key.rb +++ b/app/models/apple_key.rb @@ -37,12 +37,12 @@ def sync_devices false end - def register_device(udid, name = nil) + def register_device(udid, name = nil, platform = 'IOS') if (existed_device = Device.find_by(udid: udid)) return existed_device end - response_device = client.create_device(udid, name).to_model + response_device = client.create_device(udid, name, platform: platform).to_model Device.create_from_api(response_device) do |device| devices << device diff --git a/app/views/udid/_register_form.html.slim b/app/views/udid/_register_form.html.slim index 7909c0a2c..476f1f620 100644 --- a/app/views/udid/_register_form.html.slim +++ b/app/views/udid/_register_form.html.slim @@ -1,6 +1,6 @@ .col-md-12 .card - = simple_form_for(Device.new, url: register_udid_path(udid: udid, product: product)) do |f| + = simple_form_for(Device.new, url: register_udid_path) do |f| .card-header h3.card-title = t("udid.show.register_device") @@ -8,6 +8,8 @@ .card-body = f.error_notification = f.input :name + = f.input :udid, as: :hidden, input_html: { value: udid } + = f.input :platform, as: :hidden, input_html: { value: product } = f.input :apple_keys, collection: AppleTeam.all_names, label_method: :first, value_method: :last, include_blank: false .card-footer diff --git a/app/views/udid/index.html.slim b/app/views/udid/index.html.slim index e7016e987..ddfa1edd6 100644 --- a/app/views/udid/index.html.slim +++ b/app/views/udid/index.html.slim @@ -8,6 +8,7 @@ .col-md-12[ data-controller="udid" data-udid-apple-tip-value="#{t('.apple_tip')}" + data-udid-macos-tip-value="#{t('.macos_tip')}" data-udid-nonapple-tip-value="#{t('.nonapple_tip')}" ] .card @@ -28,4 +29,4 @@ .card .card-header.card-border h3.card-title = t('.help.title') - .card-body = t('.help.body_html') \ No newline at end of file + .card-body = t('.help.body_html') diff --git a/config/locales/zealot/en.yml b/config/locales/zealot/en.yml index 57818bd5a..d794a8f80 100644 --- a/config/locales/zealot/en.yml +++ b/config/locales/zealot/en.yml @@ -689,6 +689,7 @@ en: title: Fetch UDID index: apple_tip: Use iPhone or iPad to scan the QR Code to install + macos_tip: System limited to detect macOS's chip. choose to use the iPhone and iPad scan code or press button to get the device UDID please. nonapple_tip: :udid.index.apple_tip fetch_udid: Get your UDID now help: @@ -696,17 +697,22 @@ en: body_html: |
UDID is an abbreviation for Unique Device Identifier (UDID). The UDID is a feature provided by Apple to identify iOS devices. - Apple uses the UDID to communicate between Apple servers and individual iOS devices. This allows Apple to associate the + Apple uses the UDID to communicate between Apple servers and individual iOS devices or macOS on arm chip. This allows Apple to associate the Apple ID and the Cloud ID with the corresponding iOS device. Each iOS device has an unique ID.
- The UDID of your iOS devices is needed if you want to install alpha and beta iOS apps onto your device before they are released to the official apple store. + The UDID of your iOS devices or macOS on arm chip is needed if you want to install alpha and beta apps onto your device before they are released to the official apple store.
Following the steps:install.mobileconfig
then open "System Settings" and click "Profile" in left sidebar menu.install.mobileconfig
,打开系统设置点击左侧菜单的 "描述文件"