Skip to content

Commit 6ef275a

Browse files
committed
Update README.md
1 parent c2894f5 commit 6ef275a

9 files changed

+59
-245
lines changed

Bon/BIT.swift

-30
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,6 @@ class BIT {
5151
loginErrorMessage["mac_error"] = "Your MAC address is not valid"
5252
loginErrorMessage["sync_error"] = "Your information has been modified, waiting for synchronization, please try again after 2 minutes"
5353

54-
// loginStatus["user_tab_error"] = "认证程序未启动"
55-
// loginStatus["username_error"] = "用户名错误"
56-
// loginStatus["non_auth_error"] = "您无须认证,可直接上网"
57-
// loginStatus["password_error"] = "密码错误"
58-
// loginStatus["status_error"] = "用户已欠费,请尽快充值。"
59-
// loginStatus["available_error"] = "用户已禁用"
60-
// loginStatus["ip_exist_error"] = "您的IP尚未下线,请等待2分钟再试。"
61-
// loginStatus["usernum_error"] = "用户数已达上限"
62-
// loginStatus["online_num_error"] = "该帐号的登录人数已超过限额\n如果怀疑帐号被盗用,请联系管理员。"
63-
// loginStatus["mode_error"] = "系统已禁止WEB方式登录,请使用客户端"
64-
// loginStatus["time_policy_error"] = "当前时段不允许连接"
65-
// loginStatus["flux_error"] = "您的流量已超支"
66-
// loginStatus["minutes_error"] = "您的时长已超支"
67-
// loginStatus["ip_error"] = "您的IP地址不合法"
68-
// loginStatus["mac_error"] = "您的MAC地址不合法"
69-
// loginStatus["sync_error"] = "您的资料已修改,正在等待同步,请2分钟后再试。"
70-
7154
return loginErrorMessage
7255
}()
7356

@@ -80,13 +63,6 @@ class BIT {
8063
logoutMessage["logout_ok"] = "Logout success, please wait 1 minutes and login in。"
8164
logoutMessage["logout_error"] = "You are offline"
8265
logoutMessage["uid_error"] = "You are offline"
83-
84-
85-
// logoutStatus["user_tab_error"] = "认证程序未启动"
86-
// logoutStatus["username_error"] = "用户名错误"
87-
// logoutStatus["password_error"] = "密码错误"
88-
// logoutStatus["logout_ok"] = "注销成功,请等1分钟后登录。"
89-
// logoutStatus["logout_error"] = "您不在线上"
9066

9167
return logoutMessage
9268
}()
@@ -100,12 +76,6 @@ class BIT {
10076
keepLiveMessage["flux_error"] = "Your flow is overdrawn"
10177
keepLiveMessage["minutes_error"] = "Your time is overdrawn"
10278

103-
// keepLiveStatus["status_error"] = "您的帐户余额不足"
104-
// keepLiveStatus["available_error"] = "您的帐户被禁用"
105-
// keepLiveStatus["drop_error"] = "您被强制下线"
106-
// keepLiveStatus["flux_error"] = "您的流量已超支"
107-
// keepLiveStatus["minutes_error"] = "您的时长已超支"
108-
10979
return keepLiveMessage
11080
}()
11181
}

Bon/BonCell.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BonCell: NSTableCellView {
1313
@IBOutlet weak var typeImageView: NSImageView!
1414
@IBOutlet weak var nameLabel: NSTextField!
1515
@IBOutlet weak var infoLabel: NSTextField!
16-
@IBOutlet weak var circleView: NSView!
16+
//@IBOutlet weak var circleView: NSView!
1717

1818
private let squareWithCircleView: SquareWithCircleView = SquareWithCircleView(frame: CGRectZero)
1919

@@ -82,8 +82,8 @@ class BonCell: NSTableCellView {
8282
infoLabel.stringValue = item.infoText
8383
//circleView.layer?.backgroundColor = NSColor.bonTintColor().CGColor
8484

85-
circleView.addSubview(squareWithCircleView)
86-
squareWithCircleView.frame = circleView.bounds
85+
//circleView.addSubview(squareWithCircleView)
86+
//squareWithCircleView.frame = circleView.bounds
8787
//squareWithCircleView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
8888

8989
//typeImageView.image = NSImage(named: item.imageType)
@@ -119,8 +119,8 @@ class SquareWithCircleView: NSView{
119119
{
120120
let circleFillColor = NSColor.bonTintColor()
121121
let circleRect = NSMakeRect(dirtyRect.size.width/4, dirtyRect.size.height/4, dirtyRect.size.width/2, dirtyRect.size.height/2)
122-
let cPath: NSBezierPath = NSBezierPath(ovalInRect: circleRect)
122+
let path: NSBezierPath = NSBezierPath(ovalInRect: circleRect)
123123
circleFillColor.set()
124-
cPath.fill()
124+
path.fill()
125125
}
126126
}

Bon/BonNetwork.swift

+10-149
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,14 @@ import Alamofire
1111

1212
class BonNetwork: NSObject {
1313

14-
var alamoFireManager = Alamofire.Manager.sharedInstance
15-
16-
// let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
17-
// configuration.timeoutIntervalForRequest = 4 // seconds
18-
// configuration.timeoutIntervalForResource = 4
19-
// self.alamoFireManager = Alamofire.Manager(configuration: configuration)
20-
// let center = NSNotificationCenter.defaultCenter()
21-
// var alamoFireManager : Alamofire.Manager?
22-
//
23-
// var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
24-
// //configuration.timeoutIntervalForRequest = 4 // seconds
25-
// configuration.timeoutIntervalForResource = 4
26-
// self.alamoFireManager = Alamofire.Manager(configuration: configuration)
27-
28-
// var alamofireManager : Manager?
29-
// // 设置请求的超时时间
30-
// let config = NSURLSessionConfiguration.defaultSessionConfiguration()
31-
// config.timeoutIntervalForRequest = 5 // 秒
32-
// self.alamofireManager = Manager(configuration: config)
33-
3414
/**
35-
* login function
36-
* url : url
37-
* params : JSON
38-
* success : Request success callback function
15+
* post function
16+
* parameters: JSON
17+
* success: Request success callback function
3918
*/
4019

4120
static func post(parameters: [String : AnyObject]?, success: (value: String) -> Void) {
4221

43-
//UIApplication.sharedApplication().networkActivityIndicatorVisible = true
4422
Alamofire.request(.POST, BIT.URL.AuthActionURL, parameters: parameters)
4523
.responseString{ response in
4624
switch response.result {
@@ -55,10 +33,15 @@ class BonNetwork: NSObject {
5533

5634
}
5735

36+
/**
37+
* post function
38+
* parameters: JSON
39+
* success: Request success callback function
40+
* fail: Request fail callback function
41+
*/
5842

5943
static func post(parameters: [String : AnyObject]?, success: (value: String) -> Void, fail: (error : Any) -> Void) {
6044

61-
//UIApplication.sharedApplication().networkActivityIndicatorVisible = true
6245
Alamofire.request(.POST, BIT.URL.AuthActionURL, parameters: parameters)
6346
.responseString{ response in
6447
switch response.result {
@@ -74,61 +57,7 @@ class BonNetwork: NSObject {
7457
}
7558

7659

77-
/**
78-
* login function
79-
* url : url
80-
* params : JSON
81-
* success : Request success callback function
82-
*/
83-
84-
static func login(parameters: [String : AnyObject]?, success: (value: String) -> Void) {
85-
86-
//UIApplication.sharedApplication().networkActivityIndicatorVisible = true
87-
Alamofire.request(.POST, BIT.URL.DoLoginURL, parameters: parameters)
88-
.responseString{ response in
89-
switch response.result {
90-
case .Success(let value):
91-
success(value: value)
92-
93-
case .Failure(let error):
94-
print("Request failed with error: \(error)")
95-
}
96-
}
97-
98-
99-
}
100-
101-
102-
/**
103-
* keepLive function
104-
* parameters : JSON
105-
* success : Request success callback function
106-
*/
107-
108-
static func keepLive(parameters: [String : AnyObject]?, success: (value: String) -> Void) {
109-
110-
Alamofire.request(.POST, BIT.URL.KeepLiveURL, parameters: parameters)
111-
.responseString { response in
112-
switch response.result {
113-
case .Success(let value):
114-
success(value: value)
115-
116-
case .Failure(let error):
117-
print("Request failed with error: \(error)")
118-
}
119-
120-
}
121-
122-
}
123-
124-
/**
125-
* logout function
126-
* url : url
127-
* params : JSON
128-
* success : Request success callback function
129-
*/
130-
131-
func logout() {
60+
static func logout() {
13261

13362
let parameters = [
13463
"action": "auto_logout"
@@ -137,74 +66,6 @@ class BonNetwork: NSObject {
13766
}
13867
}
13968

140-
// FIXME: It doesn't work well
141-
142-
/**
143-
* forceLogout function
144-
* url : url
145-
* params : JSON
146-
* success : Request success callback function
147-
*/
148-
149-
static func forceLogout(parameters :[String : AnyObject]?, success :(value : String) -> Void) {
150-
151-
Alamofire.request(.POST, BIT.URL.ForceLogoutURL, parameters: parameters)
152-
.responseString { response in
153-
switch response.result {
154-
case .Success(let value):
155-
success(value: value)
156-
157-
case .Failure(let error):
158-
print("Request failed with error: \(error)")
159-
}
160-
}
161-
}
162-
163-
164-
// MARK: Get user balance, show it on another view
165-
166-
/**
167-
* getBalance function
168-
* url : url
169-
* params : JSON
170-
* success : Request success callback function
171-
*/
172-
173-
static func getBalance(parameters :[String : AnyObject]?, success :(value : AnyObject?) -> Void) {
174-
175-
Alamofire.request(.GET, BIT.URL.UserOnlineURL, parameters: parameters)
176-
.responseJSON { response in
177-
switch response.result {
178-
case .Success(let value):
179-
success(value: value)
180-
181-
case .Failure(let error):
182-
print("Request failed with error: \(error)")
183-
}
184-
}
185-
}
186-
187-
/**
188-
* getLoginState function
189-
* url : url
190-
* params : JSON
191-
* success : Request success callback function
192-
*/
193-
194-
195-
static func getOnlineInfo(success: (value : String) -> Void) {
196-
197-
let parameters = [
198-
"action": "get_online_info"
199-
]
200-
201-
post(parameters) { (value) in
202-
success(value: value)
203-
}
204-
205-
}
206-
207-
20869
static func updateLoginState() {
20970

21071
let parameters = [

Bon/BonUserDefaults.swift

-30
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,6 @@ let balanceKey = "balance"
1616
let usedDataKey = "usedData"
1717
let secondsKey = "seconds"
1818

19-
//Get balance success with string: {
20-
// "buy_mbytes" = "0.00";
21-
// "buy_minutes" = "<null>";
22-
// charge = "10.00";
23-
// client = WEB;
24-
// fid = 1304;
25-
// "flux_long" = "9.50G";
26-
// "flux_long1" = B;
27-
// "flux_long6" = B;
28-
// "free_in_bytes" = 1B;
29-
// "free_out_bytes" = 0B;
30-
// ipv = 4;
31-
// limit = 0;
32-
// "month_fee" = "10.00";
33-
// "remain_fee" = "1.53";
34-
// "remain_flux" = "2,030.82M";
35-
// "remain_timelong" = "<null>";
36-
// speed = 0;
37-
// "time_long" = 0;
38-
// "time_long1" = 0;
39-
// "time_long6" = 0;
40-
// uid = 44064;
41-
// "user_balance" = "11.53";
42-
// "user_in_bytes" = "22.98KB";
43-
// "user_ip" = "10.194.182.53";
44-
// "user_login_name" = 1120141755;
45-
// "user_login_time" = "2016-04-19 18:27:22";
46-
// "user_out_bytes" = "25.10KB";
47-
//}
48-
4919
class BonUserDefaults {
5020

5121
static let defaults = NSUserDefaults.standardUserDefaults()

Bon/BonViewController.swift

+2-13
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,11 @@ class BonViewController: NSViewController {
216216
infoTableView.reloadData()
217217
}
218218

219-
func updateTime() {
220-
seconds = seconds + 1
221-
// let date = NSDate()
222-
// let formatter = NSDateFormatter()
223-
// formatter.timeStyle = .MediumStyle
224-
// timeLabel.text = formatter.stringFromDate(date)
225-
}
226-
227-
func quit() {
228-
NSApplication.sharedApplication().terminate(self)
229-
}
230-
231-
232219
}
233220

234221

222+
// MARK: - Table view
223+
235224
extension BonViewController: NSTableViewDataSource {
236225

237226
func numberOfRowsInTableView(aTableView: NSTableView) -> Int {

0 commit comments

Comments
 (0)