Skip to content

Commit 5571041

Browse files
committed
Merge branch 'develop'
2 parents a0909b1 + 7404bba commit 5571041

15 files changed

+145
-75
lines changed

uPic/AppDelegate.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ extension AppDelegate {
131131

132132
// 注册拖拽文件格式支持。使其支持浏览器拖拽的URL、tiff。以及Safari 有些情况(例如,百度搜图,在默认搜索列表。不进入详情时)下拖拽的时候获取到的是图片URL字符串
133133
if #available(OSX 10.13, *) {
134-
button.window?.registerForDraggedTypes([.URL, .fileURL, .string])
134+
button.window?.registerForDraggedTypes([.URL, .fileURL, .string, .html])
135135
} else {
136136
// Fallback on earlier versions
137-
button.window?.registerForDraggedTypes([.png, .tiff, .pdf, .string])
137+
button.window?.registerForDraggedTypes([.png, .tiff, .pdf, .string, .html])
138138
}
139139

140140
}
@@ -372,7 +372,11 @@ extension AppDelegate {
372372
outputUrl = "<img src='\(url)'/>"
373373
break
374374
case 2:
375-
outputUrl = "![pic](\(url))"
375+
outputUrl = "![](\(url))"
376+
break
377+
case 3:
378+
// UBB
379+
outputUrl = "[img]\(url)[/img]"
376380
break
377381
default:
378382
outputUrl = url

uPic/Base.lproj/Main.storyboard

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,15 @@
163163
<action selector="ouputFormatMenuItemClicked:" target="veO-oa-UPB" id="Xxd-x1-2BP"/>
164164
</connections>
165165
</menuItem>
166+
<menuItem title="UBB" tag="3" id="Hz2-gj-luo">
167+
<modifierMask key="keyEquivalentModifierMask"/>
168+
<connections>
169+
<action selector="ouputFormatMenuItemClicked:" target="veO-oa-UPB" id="BYo-1k-amH"/>
170+
</connections>
171+
</menuItem>
166172
</items>
167173
</menu>
168174
</menuItem>
169-
<menuItem isSeparatorItem="YES" id="ijd-GZ-VTQ"/>
170175
<menuItem title="上传前压缩图片" id="eIU-EA-uQZ">
171176
<modifierMask key="keyEquivalentModifierMask"/>
172177
<menu key="submenu" title="上传前压缩图片" id="4yH-6k-LD0"/>
@@ -199,34 +204,35 @@
199204
<action selector="guideMenuItemClicked:" target="veO-oa-UPB" id="PRm-Bb-SKG"/>
200205
</connections>
201206
</menuItem>
202-
<menuItem title="赞助" id="yCF-Ec-Lgz">
207+
</items>
208+
</menu>
209+
</menuItem>
210+
<menuItem title="赞助" id="yCF-Ec-Lgz">
211+
<modifierMask key="keyEquivalentModifierMask"/>
212+
<menu key="submenu" title="赞助" id="iGe-NR-YFa">
213+
<items>
214+
<menuItem title="Paypal" id="70g-zL-O4p">
203215
<modifierMask key="keyEquivalentModifierMask"/>
204-
<menu key="submenu" title="赞助" id="iGe-NR-YFa">
205-
<items>
206-
<menuItem title="Paypal" id="70g-zL-O4p">
207-
<modifierMask key="keyEquivalentModifierMask"/>
208-
<connections>
209-
<action selector="paypalMenuItemClicked:" target="veO-oa-UPB" id="G5h-aO-WVm"/>
210-
</connections>
211-
</menuItem>
212-
<menuItem title="支付宝(Alipay)" id="aHw-Zc-eD7">
213-
<modifierMask key="keyEquivalentModifierMask"/>
214-
<connections>
215-
<action selector="alipayMenuItemClicked:" target="veO-oa-UPB" id="SQA-fB-WmZ"/>
216-
</connections>
217-
</menuItem>
218-
<menuItem title="微信(WeChat)" id="Qky-3r-Bgs">
219-
<modifierMask key="keyEquivalentModifierMask"/>
220-
<connections>
221-
<action selector="wechatPayMenuItemClicked:" target="veO-oa-UPB" id="vzQ-HN-NXw"/>
222-
</connections>
223-
</menuItem>
224-
</items>
225-
</menu>
216+
<connections>
217+
<action selector="paypalMenuItemClicked:" target="veO-oa-UPB" id="G5h-aO-WVm"/>
218+
</connections>
219+
</menuItem>
220+
<menuItem title="支付宝(Alipay)" id="aHw-Zc-eD7">
221+
<modifierMask key="keyEquivalentModifierMask"/>
222+
<connections>
223+
<action selector="alipayMenuItemClicked:" target="veO-oa-UPB" id="SQA-fB-WmZ"/>
224+
</connections>
225+
</menuItem>
226+
<menuItem title="微信(WeChat)" id="Qky-3r-Bgs">
227+
<modifierMask key="keyEquivalentModifierMask"/>
228+
<connections>
229+
<action selector="wechatPayMenuItemClicked:" target="veO-oa-UPB" id="vzQ-HN-NXw"/>
230+
</connections>
226231
</menuItem>
227232
</items>
228233
</menu>
229234
</menuItem>
235+
<menuItem isSeparatorItem="YES" id="M7L-b9-8Hc"/>
230236
<menuItem title="退出" keyEquivalent="q" id="0JF-m2-1iq">
231237
<connections>
232238
<action selector="quitMenuItemClicked:" target="veO-oa-UPB" id="e0d-Ue-lUF"/>

uPic/Models/Aliyun/AliyunRegion.swift

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ import Foundation
1010

1111
class AliyunRegionDict {
1212
static let allRegion = [
13-
"cn_hangzhou": ["name": "华东 1", "endPoint": "oss-cn-hangzhou.aliyuncs.com"],
14-
"cn_shanghai": ["name": "华东 2", "endPoint": "oss-cn-shanghai.aliyuncs.com"],
15-
"cn_qingdao": ["name": "华北 1", "endPoint": "oss-cn-qingdao.aliyuncs.com"],
16-
"cn_beijing": ["name": "华北 2", "endPoint": "oss-cn-beijing.aliyuncs.com"],
17-
"cn_zhangjiakou": ["name": "华北 3", "endPoint": "oss-cn-zhangjiakou.aliyuncs.com"],
18-
"cn_huhehaote": ["name": "华北 5", "endPoint": "oss-cn-huhehaote.aliyuncs.com"],
19-
"cn_shenzhen": ["name": "华南 1", "endPoint": "oss-cn-shenzhen.aliyuncs.com"],
20-
"cn_hongkong": ["name": "香港", "endPoint": "oss-cn-hongkong.aliyuncs.com"],
21-
"us_west_1": ["name": "美国西部 1(硅谷)", "endPoint": "oss-us-west-1.aliyuncs.com"],
22-
"us_east_1": ["name": "美国东部 1(弗吉尼亚)", "endPoint": "oss-us-east-1.aliyuncs.com"],
23-
"ap_southeast_1": ["name": "亚太东南 1(新加坡)", "endPoint": "oss-ap-southeast-1.aliyuncs.com"],
24-
"ap_southeast_2": ["name": "亚太东南 2(悉尼)", "endPoint": "oss-ap-southeast-2.aliyuncs.com"],
25-
"ap_southeast_3": ["name": "亚太东南 3(吉隆坡)", "endPoint": "oss-ap-southeast-3.aliyuncs.com"],
26-
"ap_southeast_5": ["name": "亚太东南 5 (雅加达)", "endPoint": "oss-ap-southeast-5.aliyuncs.com"],
27-
"ap_northeast_1": ["name": "亚太东北 1 (日本)", "endPoint": "oss-ap-northeast-1.aliyuncs.com"],
28-
"ap_south_1": ["name": "亚太南部 1 (孟买)", "endPoint": "oss-ap-south-1.aliyuncs.com"],
29-
"eu_central_1": ["name": "欧洲中部 1 (法兰克福)", "endPoint": "oss-eu-central-1.aliyuncs.com"],
30-
"eu_west_1": ["name": "英国(伦敦)", "endPoint": "oss-eu-west-1.aliyuncs.com"],
31-
"me_east_1": ["name": "中东东部 1 (迪拜)", "endPoint": "oss-me-east-1.aliyuncs.com"]
13+
"cn_hangzhou": ["name": "华东 1", "endPoint": "oss-cn-hangzhou"],
14+
"cn_shanghai": ["name": "华东 2", "endPoint": "oss-cn-shanghai"],
15+
"cn_qingdao": ["name": "华北 1", "endPoint": "oss-cn-qingdao"],
16+
"cn_beijing": ["name": "华北 2", "endPoint": "oss-cn-beijing"],
17+
"cn_zhangjiakou": ["name": "华北 3", "endPoint": "oss-cn-zhangjiakou"],
18+
"cn_huhehaote": ["name": "华北 5", "endPoint": "oss-cn-huhehaote"],
19+
"cn_shenzhen": ["name": "华南 1", "endPoint": "oss-cn-shenzhen"],
20+
"cn_hongkong": ["name": "香港", "endPoint": "oss-cn-hongkong"],
21+
"us_west_1": ["name": "美国西部 1(硅谷)", "endPoint": "oss-us-west-1"],
22+
"us_east_1": ["name": "美国东部 1(弗吉尼亚)", "endPoint": "oss-us-east-1"],
23+
"ap_southeast_1": ["name": "亚太东南 1(新加坡)", "endPoint": "oss-ap-southeast-1"],
24+
"ap_southeast_2": ["name": "亚太东南 2(悉尼)", "endPoint": "oss-ap-southeast-2"],
25+
"ap_southeast_3": ["name": "亚太东南 3(吉隆坡)", "endPoint": "oss-ap-southeast-3"],
26+
"ap_southeast_5": ["name": "亚太东南 5 (雅加达)", "endPoint": "oss-ap-southeast-5"],
27+
"ap_northeast_1": ["name": "亚太东北 1 (日本)", "endPoint": "oss-ap-northeast-1"],
28+
"ap_south_1": ["name": "亚太南部 1 (孟买)", "endPoint": "oss-ap-south-1"],
29+
"eu_central_1": ["name": "欧洲中部 1 (法兰克福)", "endPoint": "oss-eu-central-1"],
30+
"eu_west_1": ["name": "英国(伦敦)", "endPoint": "oss-eu-west-1"],
31+
"me_east_1": ["name": "中东东部 1 (迪拜)", "endPoint": "oss-me-east-1"]
3232
]
3333
}
3434

@@ -68,7 +68,14 @@ public enum AliyunRegion: String, CaseIterable {
6868
guard let regionDict = AliyunRegionDict.allRegion[self.rawValue], let endPoint = regionDict["endPoint"] else {
6969
return ""
7070
}
71-
return endPoint
71+
return "\(endPoint).aliyuncs.com"
7272
}
7373
}
74+
75+
public static func formatRegion(_ region: String?) -> AliyunRegion {
76+
if let region = region, !region.isEmpty {
77+
return AliyunRegion(rawValue: region)!
78+
}
79+
return AliyunRegion.cn_hangzhou
80+
}
7481
}

uPic/Models/Aliyun/AliyunUploader.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AliyunUploader: BaseUploader {
3131
let secretKey = config.secretKey!
3232
let hostSaveKey = HostSaveKey(rawValue: config.saveKey!)!
3333
let domain = config.domain!
34-
let region = (config.region != nil ? AliyunRegion(rawValue: config.region!) : AliyunRegion.cn_hangzhou)!
34+
let region = AliyunRegion.formatRegion(config.region)
3535

3636
let url = AliyunUtil.computeUrl(bucket: bucket, region: region)
3737

@@ -96,7 +96,11 @@ class AliyunUploader: BaseUploader {
9696
}.response(completionHandler: { response -> Void in
9797
switch response.result {
9898
case .success(_):
99-
super.completed(url: "\(domain)/\(key)\(config.suffix ?? "")")
99+
if domain.isEmpty {
100+
super.completed(url: "\(url)/\(key)\(config.suffix ?? "")")
101+
} else {
102+
super.completed(url: "\(domain)/\(key)\(config.suffix ?? "")")
103+
}
100104
case .failure(let error):
101105
var errorMessage = error.localizedDescription
102106
if let data = response.data {

uPic/Models/Amazon_S3/AmazonS3Region.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ public class AmazonS3Region {
5151
}
5252
return "s3.\(key).amazonaws.com"
5353
}
54+
55+
public static func formatRegion(_ region: String?) -> String {
56+
if let region = region, !region.isEmpty {
57+
return region
58+
}
59+
return AmazonS3Region.allRegion.keys.first!
60+
}
5461
}

uPic/Models/Amazon_S3/AmazonS3Uploader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AmazonS3Uploader: BaseUploader {
3131
let secretKey = config.secretKey!
3232
let hostSaveKey = HostSaveKey(rawValue: config.saveKey!)!
3333
let domain = config.domain!
34-
let region = config.region!
34+
let region = AmazonS3Region.formatRegion(config.region)
3535

3636
let url = AmazonS3Util.computeUrl(bucket: bucket, region: region)
3737

uPic/Models/Qiniu/QiniuRegion.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ public enum QiniuRegion: String, CaseIterable {
4343
return url
4444
}
4545
}
46+
47+
public static func formatRegion(_ region: String?) -> QiniuRegion {
48+
if let region = region, !region.isEmpty {
49+
return QiniuRegion(rawValue: region)!
50+
}
51+
return QiniuRegion.z0
52+
}
4653
}

uPic/Models/Qiniu/QiniuUploader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class QiniuUploader: BaseUploader {
3232
let secretKey = config.secretKey!
3333
let hostSaveKey = HostSaveKey(rawValue: config.saveKey!)!
3434
let domain = config.domain!
35-
let region = (config.region != nil ? QiniuRegion(rawValue: config.region!) : QiniuRegion.z0)!
35+
var region = QiniuRegion.formatRegion(config.region)
3636

3737
var retData = fileData
3838
var fileName = ""

uPic/Models/Tencent/TencentRegion.swift

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ import Foundation
1111
class TencentRegionDict {
1212
static let allRegion = [
1313
// 内地
14-
"ap_beijing_1": ["name": "北京一区", "endPoint": "cos.ap-beijing-1.myqcloud.com"],
15-
"ap_beijing": ["name": "北京", "endPoint": "cos.ap-beijing.myqcloud.com"],
16-
"ap_shanghai": ["name": "上海(华东)", "endPoint": "cos.ap-shanghai.myqcloud.com"],
17-
"ap_guangzhou": ["name": "广州(华南)", "endPoint": "cos.ap-guangzhou.myqcloud.com"],
18-
"ap_chengdu": ["name": "成都(西南)", "endPoint": "cos.ap-chengdu.myqcloud.com"],
19-
"ap_chongqing": ["name": "重庆", "endPoint": "cos.ap-chongqing.myqcloud.com"],
20-
"ap_shenzhen_fsi": ["name": "深圳金融", "endPoint": "cos.ap-shenzhen-fsi.myqcloud.com"],
21-
"ap_shanghai_fsi": ["name": "上海金融", "endPoint": "cos.ap-shanghai-fsi.myqcloud.com"],
14+
"ap_beijing_1": ["name": "北京一区", "endPoint": "cos.ap-beijing-1"],
15+
"ap_beijing": ["name": "北京", "endPoint": "cos.ap-beijing"],
16+
"ap_shanghai": ["name": "上海(华东)", "endPoint": "cos.ap-shanghai"],
17+
"ap_guangzhou": ["name": "广州(华南)", "endPoint": "cos.ap-guangzhou"],
18+
"ap_chengdu": ["name": "成都(西南)", "endPoint": "cos.ap-chengdu"],
19+
"ap_chongqing": ["name": "重庆", "endPoint": "cos.ap-chongqing"],
20+
"ap_shenzhen_fsi": ["name": "深圳金融", "endPoint": "cos.ap-shenzhen-fsi"],
21+
"ap_shanghai_fsi": ["name": "上海金融", "endPoint": "cos.ap-shanghai-fsi"],
2222
// 中国香港及海外地域
23-
"ap_hongkong": ["name": "香港", "endPoint": "cos.ap-hongkong.myqcloud.com"],
24-
"ap_singapore": ["name": "新加坡", "endPoint": "cos.ap-singapore.myqcloud.com"],
25-
"ap_mumbai": ["name": "孟买", "endPoint": "cos.ap-mumbai.myqcloud.com"],
26-
"ap_seoul": ["name": "首尔", "endPoint": "cos.ap-seoul.myqcloud.com"],
27-
"ap_bangkok": ["name": "曼谷", "endPoint": "cos.ap-bangkok.myqcloud.com"],
28-
"ap_tokyo": ["name": "东京", "endPoint": "cos.ap-tokyo.myqcloud.com"],
29-
"na_siliconvalley": ["name": "硅谷", "endPoint": "cos.na-siliconvalley.myqcloud.com"],
30-
"na_ashburn": ["name": "弗吉尼亚", "endPoint": "cos.na-ashburn.myqcloud.com"],
31-
"na_toronto": ["name": "多伦多", "endPoint": "cos.na-toronto.myqcloud.com"],
32-
"eu_frankfurt": ["name": "法兰克福", "endPoint": "cos.eu-frankfurt.myqcloud.com"],
33-
"eu_moscow": ["name": "莫斯科", "endPoint": "cos.eu-moscow.myqcloud.com"]
23+
"ap_hongkong": ["name": "香港", "endPoint": "cos.ap-hongkong"],
24+
"ap_singapore": ["name": "新加坡", "endPoint": "cos.ap-singapore"],
25+
"ap_mumbai": ["name": "孟买", "endPoint": "cos.ap-mumbai"],
26+
"ap_seoul": ["name": "首尔", "endPoint": "cos.ap-seoul"],
27+
"ap_bangkok": ["name": "曼谷", "endPoint": "cos.ap-bangkok"],
28+
"ap_tokyo": ["name": "东京", "endPoint": "cos.ap-tokyo"],
29+
"na_siliconvalley": ["name": "硅谷", "endPoint": "cos.na-siliconvalley"],
30+
"na_ashburn": ["name": "弗吉尼亚", "endPoint": "cos.na-ashburn"],
31+
"na_toronto": ["name": "多伦多", "endPoint": "cos.na-toronto"],
32+
"eu_frankfurt": ["name": "法兰克福", "endPoint": "cos.eu-frankfurt"],
33+
"eu_moscow": ["name": "莫斯科", "endPoint": "cos.eu-moscow"]
3434
]
3535
}
3636

@@ -70,7 +70,14 @@ public enum TencentRegion: String, CaseIterable {
7070
guard let regionDict = TencentRegionDict.allRegion[self.rawValue], let endPoint = regionDict["endPoint"] else {
7171
return ""
7272
}
73-
return endPoint
73+
return "\(endPoint).myqcloud.com"
7474
}
7575
}
76+
77+
public static func formatRegion(_ region: String?) -> TencentRegion {
78+
if let region = region, !region.isEmpty {
79+
return TencentRegion(rawValue: region)!
80+
}
81+
return TencentRegion.ap_beijing_1
82+
}
7683
}

uPic/Models/Tencent/TencentUploader.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TencentUploader: BaseUploader {
3131
let secretKey = config.secretKey!
3232
let hostSaveKey = HostSaveKey(rawValue: config.saveKey!)!
3333
let domain = config.domain!
34-
let region = (config.region != nil ? TencentRegion(rawValue: config.region!) : TencentRegion.ap_shanghai)!
34+
let region = TencentRegion.formatRegion(config.region)
3535

3636
let url = TencentUtil.computeUrl(bucket: bucket, region: region)
3737
let hostUri = TencentUtil.computeHost(bucket: bucket, region: region)
@@ -113,7 +113,11 @@ class TencentUploader: BaseUploader {
113113
}.response(completionHandler: { response -> Void in
114114
switch response.result {
115115
case .success(_):
116-
super.completed(url: "\(domain)/\(key)\(config.suffix ?? "")")
116+
if domain.isEmpty {
117+
super.completed(url: "\(url)/\(key)\(config.suffix ?? "")")
118+
} else {
119+
super.completed(url: "\(domain)/\(key)\(config.suffix ?? "")")
120+
}
117121
case .failure(let error):
118122
var errorMessage = error.localizedDescription
119123
if let data = response.data {

uPic/PreferencesWindow/ConfigView/Views/AliyunConfigView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ class AliyunConfigView: ConfigView {
4545
selectRegion = menuItem
4646
}
4747
}
48+
49+
selectRegion = selectRegion ?? regionButtonPopUp.menu?.items.first
4850
if selectRegion != nil {
4951
regionButtonPopUp.select(selectRegion)
52+
// 初次设置,手动处罚一下事件,将数据写入data
53+
if (data.region == nil || data.region.isEmpty) {
54+
self.regionChange(regionButtonPopUp)
55+
}
5056
}
5157

5258
self.addSubview(regionLabel)

uPic/PreferencesWindow/ConfigView/Views/AmazonS3ConfigView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ class AmazonS3ConfigView: ConfigView {
4747
selectRegion = menuItem
4848
}
4949
}
50+
51+
selectRegion = selectRegion ?? regionButtonPopUp.menu?.items.first
5052
if selectRegion != nil {
5153
regionButtonPopUp.select(selectRegion)
54+
// 初次设置,手动处罚一下事件,将数据写入data
55+
if (data.region == nil || data.region.isEmpty) {
56+
self.regionChange(regionButtonPopUp)
57+
}
5258
}
5359

5460
self.addSubview(regionLabel)

0 commit comments

Comments
 (0)