Skip to content

Commit

Permalink
Merge branch 'hotfix/region'
Browse files Browse the repository at this point in the history
  • Loading branch information
gee1k committed Dec 21, 2019
2 parents 2c9752c + 441844a commit 1514660
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 25 deletions.
4 changes: 4 additions & 0 deletions uPic/Models/Aliyun/AliyunRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class AliyunRegion {

/// FIXME: 将旧版区域转为新版格式,几个版本的迭代后需删除
public static func upgradeFromOld(_ oldRegion: String) -> String {
if (oldRegion.starts(with: "oss-")) {
return oldRegion
}

if oldRegion.isEmpty {
return ""
}
Expand Down
13 changes: 8 additions & 5 deletions uPic/PreferencesWindow/ConfigView/Views/AliyunConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ class AliyunConfigView: ConfigView {
regionButtonPopUp.identifier = NSUserInterfaceItemIdentifier(rawValue: "region")

var selectRegion: NSMenuItem?
for region in AliyunRegion.allRegion {
let title = AliyunRegion.name(region.key)
let endPoint = AliyunRegion.endPoint(region.key)

let sortedKeys = Array(AliyunRegion.allRegion.keys).sorted()

for key in sortedKeys {
let title = AliyunRegion.name(key)
let endPoint = AliyunRegion.endPoint(key)
let menuItem = NSMenuItem(title: title, action: nil, keyEquivalent: "")
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: region.key)
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: key)
regionButtonPopUp.menu?.addItem(menuItem)
if endPoint.isEmpty {
menuItem.isEnabled = false
}

if data.region == region.key {
if data.region == key {
selectRegion = menuItem
}
}
Expand Down
13 changes: 8 additions & 5 deletions uPic/PreferencesWindow/ConfigView/Views/AmazonS3ConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ class AmazonS3ConfigView: ConfigView {
regionButtonPopUp.identifier = NSUserInterfaceItemIdentifier(rawValue: "region")

var selectRegion: NSMenuItem?
for region in AmazonS3Region.allRegion {
let title = AmazonS3Region.name(region.key)
let endPoint = AmazonS3Region.endPoint(region.key)

let sortedKeys = Array(AmazonS3Region.allRegion.keys).sorted()

for key in sortedKeys {
let title = AmazonS3Region.name(key)
let endPoint = AmazonS3Region.endPoint(key)
let menuItem = NSMenuItem(title: title, action: nil, keyEquivalent: "")
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: region.key)
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: key)
regionButtonPopUp.menu?.addItem(menuItem)
if endPoint.isEmpty {
menuItem.isEnabled = false
}

if data.region == region.key {
if data.region == key {
selectRegion = menuItem
}
}
Expand Down
13 changes: 8 additions & 5 deletions uPic/PreferencesWindow/ConfigView/Views/BaiduConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ class BaiduConfigView: ConfigView {
regionButtonPopUp.identifier = NSUserInterfaceItemIdentifier(rawValue: "region")

var selectRegion: NSMenuItem?
for region in BaiduRegion.allRegion {
let title = BaiduRegion.name(region.key)
let endPoint = BaiduRegion.endPoint(region.key)

let sortedKeys = Array(BaiduRegion.allRegion.keys).sorted()

for key in sortedKeys {
let title = BaiduRegion.name(key)
let endPoint = BaiduRegion.endPoint(key)
let menuItem = NSMenuItem(title: title, action: nil, keyEquivalent: "")
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: region.key)
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: key)
regionButtonPopUp.menu?.addItem(menuItem)
if endPoint.isEmpty {
menuItem.isEnabled = false
}

if data.region == region.key {
if data.region == key {
selectRegion = menuItem
}
}
Expand Down
12 changes: 7 additions & 5 deletions uPic/PreferencesWindow/ConfigView/Views/QiniuConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ class QiniuConfigView: ConfigView {
regionButtonPopUp.identifier = NSUserInterfaceItemIdentifier(rawValue: "region")

var selectRegion: NSMenuItem?
for region in QiniuRegion.allRegion {
let title = QiniuRegion.name(region.key)
let endPoint = QiniuRegion.endPoint(region.key)
let sortedKeys = Array(QiniuRegion.allRegion.keys).sorted()

for key in sortedKeys {
let title = QiniuRegion.name(key)
let endPoint = QiniuRegion.endPoint(key)
let menuItem = NSMenuItem(title: title, action: nil, keyEquivalent: "")
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: region.key)
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: key)
regionButtonPopUp.menu?.addItem(menuItem)
if endPoint == nil || endPoint!.isEmpty {
menuItem.isEnabled = false
}

if data.region == region.key {
if data.region == key {
selectRegion = menuItem
}
}
Expand Down
13 changes: 8 additions & 5 deletions uPic/PreferencesWindow/ConfigView/Views/TencentConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ class TencentConfigView: ConfigView {
regionButtonPopUp.identifier = NSUserInterfaceItemIdentifier(rawValue: "region")

var selectRegion: NSMenuItem?
for region in TencentRegion.allRegion {
let title = TencentRegion.name(region.key)
let endPoint = TencentRegion.endPoint(region.key)

let sortedKeys = Array(TencentRegion.allRegion.keys).sorted()

for key in sortedKeys {
let title = TencentRegion.name(key)
let endPoint = TencentRegion.endPoint(key)
let menuItem = NSMenuItem(title: title, action: nil, keyEquivalent: "")
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: region.key)
menuItem.identifier = NSUserInterfaceItemIdentifier(rawValue: key)
regionButtonPopUp.menu?.addItem(menuItem)
if endPoint.isEmpty {
menuItem.isEnabled = false
}

if data.region == region.key {
if data.region == key {
selectRegion = menuItem
}
}
Expand Down

0 comments on commit 1514660

Please sign in to comment.