Skip to content

Commit ba5fc7f

Browse files
committed
release 1.0
release 1.0
1 parent 039863e commit ba5fc7f

File tree

16 files changed

+421
-31
lines changed

16 files changed

+421
-31
lines changed

J2K/.DS_Store

6 KB
Binary file not shown.

J2K/J2K.xcodeproj/project.pbxproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/* End PBXBuildFile section */
1818

1919
/* Begin PBXFileReference section */
20+
DA25B3A32258616E00738C6F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
2021
DA4F727F2253048E00E51540 /* J2K.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = J2K.app; sourceTree = BUILT_PRODUCTS_DIR; };
2122
DA4F72822253048E00E51540 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2223
DA4F72842253049000E51540 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -40,11 +41,20 @@
4041
/* End PBXFrameworksBuildPhase section */
4142

4243
/* Begin PBXGroup section */
44+
DA25B3A22258616D00738C6F /* Frameworks */ = {
45+
isa = PBXGroup;
46+
children = (
47+
DA25B3A32258616E00738C6F /* Security.framework */,
48+
);
49+
name = Frameworks;
50+
sourceTree = "<group>";
51+
};
4352
DA4F72762253048E00E51540 = {
4453
isa = PBXGroup;
4554
children = (
4655
DA4F72812253048E00E51540 /* J2K */,
4756
DA4F72802253048E00E51540 /* Products */,
57+
DA25B3A22258616D00738C6F /* Frameworks */,
4858
);
4959
sourceTree = "<group>";
5060
};
@@ -105,6 +115,9 @@
105115
DA4F727E2253048E00E51540 = {
106116
CreatedOnToolsVersion = 10.2;
107117
SystemCapabilities = {
118+
com.apple.Keychain = {
119+
enabled = 0;
120+
};
108121
com.apple.Sandbox = {
109122
enabled = 0;
110123
};
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1020"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "DA4F727E2253048E00E51540"
18+
BuildableName = "J2K.app"
19+
BlueprintName = "J2K"
20+
ReferencedContainer = "container:J2K.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<MacroExpansion>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "DA4F727E2253048E00E51540"
36+
BuildableName = "J2K.app"
37+
BlueprintName = "J2K"
38+
ReferencedContainer = "container:J2K.xcodeproj">
39+
</BuildableReference>
40+
</MacroExpansion>
41+
<AdditionalOptions>
42+
</AdditionalOptions>
43+
</TestAction>
44+
<LaunchAction
45+
buildConfiguration = "Release"
46+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
48+
launchStyle = "0"
49+
useCustomWorkingDirectory = "NO"
50+
ignoresPersistentStateOnLaunch = "NO"
51+
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
53+
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "DA4F727E2253048E00E51540"
59+
BuildableName = "J2K.app"
60+
BlueprintName = "J2K"
61+
ReferencedContainer = "container:J2K.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
64+
<AdditionalOptions>
65+
</AdditionalOptions>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "DA4F727E2253048E00E51540"
78+
BuildableName = "J2K.app"
79+
BlueprintName = "J2K"
80+
ReferencedContainer = "container:J2K.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>

J2K/J2K.xcodeproj/xcuserdata/jiangyibo.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@
1010
<integer>0</integer>
1111
</dict>
1212
</dict>
13+
<key>SuppressBuildableAutocreation</key>
14+
<dict>
15+
<key>DA4F727E2253048E00E51540</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
20+
</dict>
1321
</dict>
1422
</plist>

J2K/J2K/Assets.xcassets/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "jike.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
14 KB
Loading

J2K/J2K/ConnectTool.swift

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ import Cocoa
1111
class ConnectTool {
1212

1313
let refreshUrl = "https://app.jike.ruguoapp.com/1.0/app_auth_tokens.refresh" // POST
14-
let refreshJWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiQnZZSmFwckg0QlQ1ZEJudWY0NUtWWU50cFB1WkFqKzVSMWtnb3pBNDVTTEhlXC9xdSt2QitvXC83SXh3cWI4STRvYXZqaStkcG5JZXF5WFFPZzdZZ1J3SHhGMDBPVTBPRytDbnRlTHl1OFJabkhLRk5qNG9QY3JXbUExRDlcL3gxa3NhdUVDa3dybjRhUTFQXC9nTmkyVnRZT0FzcEE2TUh3K2NFZHVHczdLYllVVT0iLCJ2IjozLCJpdiI6ImVHcjlBTEFJdTZrak1LK3krUzVMXC9nPT0iLCJpYXQiOjE1NTQxMDA2MTkuMzk2fQ.NedeubfCaKjlA4qPNfEMbY10WrmxUClfvrA10kzBk40"
1514
let dailyDataUrl = "https://app.jike.ruguoapp.com/1.0/dailyCards/list" // GET
1615

17-
func getDataJWT (success: @escaping (String) -> Void) {
16+
func getDataJWT (_ refreshToken: String, success: @escaping (String) -> Void, fail: @escaping () -> Void) {
1817
let session = URLSession(configuration: .default)
1918
let url = NSURL(string: refreshUrl)
2019
var request = URLRequest(url: url! as URL)
2120
request.httpMethod = "POST"
22-
request.addValue(refreshJWT, forHTTPHeaderField: "x-jike-refresh-token")
21+
request.addValue(refreshToken, forHTTPHeaderField: "x-jike-refresh-token")
2322
let task = session.dataTask(with: request) {(data, response, error) in
2423
do {
2524
let JWTData = try JSONSerialization.jsonObject(with: data!, options: []) as! NSDictionary
2625
let jwt = JWTData["x-jike-access-token"] as! String
2726
success(jwt)
2827
} catch {
2928
print("无法连接到服务器")
29+
fail()
3030
return
3131
}
3232
}
@@ -52,4 +52,80 @@ class ConnectTool {
5252

5353
}
5454

55+
func getQRUUID (success: @escaping (String) -> Void) {
56+
let urlStr = "https://app.jike.ruguoapp.com/sessions.create"
57+
let session = URLSession(configuration: .default)
58+
let url = NSURL(string: urlStr)
59+
let request = URLRequest(url: url! as URL)
60+
let task = session.dataTask(with: request) {(data, response, error) in
61+
do {
62+
let uuidData = try JSONSerialization.jsonObject(with: data!, options: []) as! NSDictionary as! Dictionary<String, Any>
63+
let uuid: String = uuidData["uuid"] as! String
64+
success(uuid)
65+
} catch {
66+
print("无法连接到服务器")
67+
return
68+
}
69+
}
70+
task.resume()
71+
}
72+
73+
func waitingforLogin (uuid: String, success: @escaping () -> Void, fail: @escaping () -> Void) {
74+
// 未登录204, 登录200, 超时xx
75+
let urlStr = "https://app.jike.ruguoapp.com/sessions.wait_for_login?uuid=\(uuid)"
76+
let session = URLSession(configuration: .default)
77+
let url = NSURL(string: urlStr)
78+
let request = URLRequest(url: url! as URL)
79+
let task = session.dataTask(with: request) {(data, response, error) in
80+
do {
81+
let res = try JSONSerialization.jsonObject(with: data!, options: []) as! NSDictionary as! Dictionary<String, Any>
82+
let logged_in: Int = res["logged_in"] as! Int
83+
// logged_in == 1
84+
if (logged_in == 1) {
85+
success()
86+
}
87+
} catch {
88+
let res: HTTPURLResponse = response as! HTTPURLResponse
89+
let code = res.statusCode
90+
if (code == 204) {
91+
// 未登录,再次请求 waitingforLogin
92+
self.waitingforLogin(uuid: uuid,success: success, fail: fail);
93+
} else {
94+
fail()
95+
}
96+
return
97+
}
98+
99+
}
100+
task.resume()
101+
}
102+
103+
func waitingforConfirm (uuid: String, success: @escaping (String) -> Void, fail: @escaping () -> Void) {
104+
let urlStr = "https://app.jike.ruguoapp.com/sessions.wait_for_confirmation?uuid=\(uuid)"
105+
let session = URLSession(configuration: .default)
106+
let url = NSURL(string: urlStr)
107+
let request = URLRequest(url: url! as URL)
108+
let task = session.dataTask(with: request) {(data, response, error) in
109+
do {
110+
let userdata = try JSONSerialization.jsonObject(with: data!, options: []) as! NSDictionary as! Dictionary<String, Any>
111+
let refreshToken: String = userdata["x-jike-refresh-token"] as! String
112+
success(refreshToken)
113+
} catch {
114+
print("无法连接到服务器")
115+
let res: HTTPURLResponse = response as! HTTPURLResponse
116+
let code = res.statusCode
117+
if (code == 204) {
118+
// 未登录,再次请求 waitingforLogin
119+
self.waitingforConfirm(uuid: uuid,success: success, fail: fail);
120+
} else {
121+
fail()
122+
}
123+
return
124+
}
125+
}
126+
task.resume()
127+
}
128+
129+
130+
55131
}

0 commit comments

Comments
 (0)