Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
b8055429
Commit
b8055429
authored
Mar 24, 2017
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新的账号系统
parent
de224bfc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
24 deletions
+45
-24
app/apps.service.ts
app/apps.service.ts
+16
-15
app/lobby.component.ts
app/lobby.component.ts
+1
-1
app/login.component.ts
app/login.component.ts
+7
-7
locale/messages.en-US.xlf
locale/messages.en-US.xlf
+20
-0
package.json
package.json
+1
-1
No files found.
app/apps.service.ts
View file @
b8055429
import
{
Injectable
,
ApplicationRef
,
EventEmitter
,
NgZone
}
from
'
@angular/core
'
;
import
{
ApplicationRef
,
EventEmitter
,
Injectable
,
NgZone
}
from
'
@angular/core
'
;
import
{
Http
,
URLSearchParams
}
from
'
@angular/http
'
;
import
{
Http
,
URLSearchParams
}
from
'
@angular/http
'
;
import
*
as
crypto
from
'
crypto
'
;
import
*
as
crypto
from
'
crypto
'
;
import
{
A
pp
,
AppStatus
,
Action
}
from
'
./app
'
;
import
{
A
ction
,
App
,
AppStatus
}
from
'
./app
'
;
import
{
SettingsService
}
from
'
./settings.sevices
'
;
import
{
SettingsService
}
from
'
./settings.sevices
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
fs
from
'
fs
'
;
import
{
createReadStream
,
createWriteStream
}
from
'
fs
'
;
import
{
createReadStream
,
createWriteStream
}
from
'
fs
'
;
...
@@ -65,7 +65,7 @@ export class AppsService {
...
@@ -65,7 +65,7 @@ export class AppsService {
private
downloadService
:
DownloadService
,
private
ngZone
:
NgZone
,
private
loginService
:
LoginService
)
{
private
downloadService
:
DownloadService
,
private
ngZone
:
NgZone
,
private
loginService
:
LoginService
)
{
}
}
get
lastVisited
():
App
|
undefined
{
get
lastVisited
():
App
|
undefined
{
let
id
=
localStorage
.
getItem
(
'
last_visited
'
);
let
id
=
localStorage
.
getItem
(
'
last_visited
'
);
if
(
id
)
{
if
(
id
)
{
return
this
.
apps
.
get
(
id
);
return
this
.
apps
.
get
(
id
);
...
@@ -73,7 +73,7 @@ export class AppsService {
...
@@ -73,7 +73,7 @@ export class AppsService {
return
undefined
;
return
undefined
;
}
}
set
lastVisited
(
app
:
App
|
undefined
)
{
set
lastVisited
(
app
:
App
|
undefined
)
{
if
(
app
)
{
if
(
app
)
{
localStorage
.
setItem
(
'
last_visited
'
,
app
.
id
);
localStorage
.
setItem
(
'
last_visited
'
,
app
.
id
);
}
}
...
@@ -96,11 +96,12 @@ export class AppsService {
...
@@ -96,11 +96,12 @@ export class AppsService {
localStorage
.
setItem
(
'
apps_json
'
,
JSON
.
stringify
(
data
));
localStorage
.
setItem
(
'
apps_json
'
,
JSON
.
stringify
(
data
));
this
.
apps
=
this
.
loadAppsList
(
data
);
this
.
apps
=
this
.
loadAppsList
(
data
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
);
let
data
=
localStorage
.
getItem
(
'
apps_json
'
);
let
data
=
localStorage
.
getItem
(
'
apps_json
'
);
if
(
data
)
{
if
(
data
)
{
this
.
apps
=
this
.
loadAppsList
(
JSON
.
parse
(
data
));
this
.
apps
=
this
.
loadAppsList
(
JSON
.
parse
(
data
));
}
else
{
}
else
{
alert
(
'
读取游戏列表失败,可能是网络不通
'
)
alert
(
'
读取游戏列表失败,可能是网络不通
'
)
;
this
.
apps
=
new
Map
();
this
.
apps
=
new
Map
();
}
}
}
}
...
@@ -385,7 +386,7 @@ export class AppsService {
...
@@ -385,7 +386,7 @@ export class AppsService {
let
interval
=
setInterval
(()
=>
{
let
interval
=
setInterval
(()
=>
{
},
500
);
},
500
);
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
try
{
try
{
for
(
let
[
file
,
checksum
]
of
sortedFiles
)
{
for
(
let
[
file
,
checksum
]
of
sortedFiles
)
{
let
src
=
path
.
join
(
appPath
,
file
);
let
src
=
path
.
join
(
appPath
,
file
);
...
@@ -443,7 +444,7 @@ export class AppsService {
...
@@ -443,7 +444,7 @@ export class AppsService {
let
filePath
=
path
.
join
(
app
.
local
!
.
path
,
file
);
let
filePath
=
path
.
join
(
app
.
local
!
.
path
,
file
);
// 如果文件不存在,随便生成一个checksum
// 如果文件不存在,随便生成一个checksum
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
access
(
filePath
,
fs
.
constants
.
F_OK
,
async
(
err
:
Error
)
=>
{
fs
.
access
(
filePath
,
fs
.
constants
.
F_OK
,
async
(
err
:
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
result
.
set
(
file
,
Math
.
random
().
toString
());
result
.
set
(
file
,
Math
.
random
().
toString
());
}
else
if
(
checksum
===
''
)
{
}
else
if
(
checksum
===
''
)
{
...
@@ -478,14 +479,14 @@ export class AppsService {
...
@@ -478,14 +479,14 @@ export class AppsService {
try
{
try
{
Logger
.
info
(
'
Checking updating:
'
,
app
);
Logger
.
info
(
'
Checking updating:
'
,
app
);
let
latestFiles
=
await
this
.
getChecksumFile
(
app
);
let
latestFiles
=
await
this
.
getChecksumFile
(
app
);
let
localFiles
:
Map
<
string
,
string
>
|
undefined
;
let
localFiles
:
Map
<
string
,
string
>
|
undefined
;
if
(
verify
)
{
if
(
verify
)
{
// 刷新进度条
// 刷新进度条
let
interval
=
setInterval
(()
=>
{
let
interval
=
setInterval
(()
=>
{
},
500
);
},
500
);
app
.
status
.
total
=
latestFiles
.
size
;
app
.
status
.
total
=
latestFiles
.
size
;
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
try
{
try
{
localFiles
=
await
this
.
verifyFiles
(
app
,
latestFiles
,
()
=>
{
localFiles
=
await
this
.
verifyFiles
(
app
,
latestFiles
,
()
=>
{
app
.
status
.
progress
+=
1
;
app
.
status
.
progress
+=
1
;
...
@@ -667,7 +668,7 @@ export class AppsService {
...
@@ -667,7 +668,7 @@ export class AppsService {
async
install
(
app
:
App
,
option
:
InstallOption
)
{
async
install
(
app
:
App
,
option
:
InstallOption
)
{
const
tryToInstall
=
async
(
task
:
InstallTask
):
Promise
<
void
>
=>
{
const
tryToInstall
=
async
(
task
:
InstallTask
):
Promise
<
void
>
=>
{
if
(
!
task
.
app
.
readyForInstall
())
{
if
(
!
task
.
app
.
readyForInstall
())
{
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
eventEmitter
.
subscribe
(()
=>
{
this
.
eventEmitter
.
subscribe
(()
=>
{
...
@@ -681,7 +682,7 @@ export class AppsService {
...
@@ -681,7 +682,7 @@ export class AppsService {
}
}
await
this
.
doInstall
(
task
);
await
this
.
doInstall
(
task
);
};
};
const
addDownloadTask
=
async
(
_app
:
App
,
dir
:
string
):
Promise
<
{
app
:
App
,
files
:
string
[]}
>
=>
{
const
addDownloadTask
=
async
(
_app
:
App
,
dir
:
string
):
Promise
<
{
app
:
App
,
files
:
string
[]
}
>
=>
{
let
locale
=
this
.
settingsService
.
getLocale
();
let
locale
=
this
.
settingsService
.
getLocale
();
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
locale
=
'
en-US
'
;
locale
=
'
en-US
'
;
...
@@ -981,7 +982,7 @@ export class AppsService {
...
@@ -981,7 +982,7 @@ export class AppsService {
}
}
}
}
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
try
{
try
{
await
this
.
backupFiles
(
app
.
parent
!
.
local
!
.
path
,
backupPath
,
conflictFiles
,
(
n
)
=>
{
await
this
.
backupFiles
(
app
.
parent
!
.
local
!
.
path
,
backupPath
,
conflictFiles
,
(
n
)
=>
{
app
.
status
.
progress
+=
1
;
app
.
status
.
progress
+=
1
;
...
@@ -1134,7 +1135,7 @@ export class AppsService {
...
@@ -1134,7 +1135,7 @@ export class AppsService {
async
backupFiles
(
dir
:
string
,
backupDir
:
string
,
files
:
Iterable
<
string
>
,
callback
?:
(
progress
:
number
)
=>
void
)
{
async
backupFiles
(
dir
:
string
,
backupDir
:
string
,
files
:
Iterable
<
string
>
,
callback
?:
(
progress
:
number
)
=>
void
)
{
let
n
=
0
;
let
n
=
0
;
for
(
let
file
of
files
)
{
for
(
let
file
of
files
)
{
await
new
Promise
(
async
(
resolve
,
reject
)
=>
{
await
new
Promise
(
async
(
resolve
,
reject
)
=>
{
let
srcPath
=
path
.
join
(
dir
,
file
);
let
srcPath
=
path
.
join
(
dir
,
file
);
let
backupPath
=
path
.
join
(
backupDir
,
file
);
let
backupPath
=
path
.
join
(
backupDir
,
file
);
await
this
.
createDirectory
(
path
.
dirname
(
backupPath
));
await
this
.
createDirectory
(
path
.
dirname
(
backupPath
));
...
@@ -1166,7 +1167,7 @@ export class AppsService {
...
@@ -1166,7 +1167,7 @@ export class AppsService {
}
}
}
}
async
getChecksumFile
(
app
:
App
):
Promise
<
Map
<
string
,
string
>
>
{
async
getChecksumFile
(
app
:
App
):
Promise
<
Map
<
string
,
string
>>
{
let
locale
=
this
.
settingsService
.
getLocale
();
let
locale
=
this
.
settingsService
.
getLocale
();
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
if
(
!
[
'
zh-CN
'
,
'
en-US
'
,
'
ja-JP
'
].
includes
(
locale
))
{
...
@@ -1245,7 +1246,7 @@ export class AppsService {
...
@@ -1245,7 +1246,7 @@ export class AppsService {
let
interval
=
setInterval
(()
=>
{
let
interval
=
setInterval
(()
=>
{
},
500
);
},
500
);
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
this
.
ngZone
.
runOutsideAngular
(
async
()
=>
{
try
{
try
{
for
(
let
file
of
files
)
{
for
(
let
file
of
files
)
{
app
.
status
.
progress
+=
1
;
app
.
status
.
progress
+=
1
;
...
...
app/lobby.component.ts
View file @
b8055429
...
@@ -166,7 +166,7 @@ export class LobbyComponent implements OnInit {
...
@@ -166,7 +166,7 @@ export class LobbyComponent implements OnInit {
}
}
get
grouped_apps
()
{
get
grouped_apps
()
{
let
contains
=
[
'
game
'
,
'
music
'
,
'
book
'
,
'
test
'
].
map
((
value
)
=>
Category
[
value
]);
let
contains
=
[
'
game
'
,
'
music
'
,
'
book
'
].
map
((
value
)
=>
Category
[
value
]);
let
result
=
{
runtime
:
[]};
let
result
=
{
runtime
:
[]};
for
(
let
app
of
this
.
apps
.
values
())
{
for
(
let
app
of
this
.
apps
.
values
())
{
let
tag
:
string
;
let
tag
:
string
;
...
...
app/login.component.ts
View file @
b8055429
...
@@ -19,13 +19,13 @@ export class LoginComponent {
...
@@ -19,13 +19,13 @@ export class LoginComponent {
url
:
string
;
url
:
string
;
readonly
return_sso_url
=
'
https://mycard.moe/login_callback
'
;
// 这个url不会真的被使用,可以填写不存在的
readonly
return_sso_url
=
'
https://mycard.moe/login_callback
'
;
// 这个url不会真的被使用,可以填写不存在的
constructor
(
private
loginService
:
LoginService
)
{
constructor
(
private
loginService
:
LoginService
)
{
let
params
=
new
URLSearchParams
();
let
params
=
new
URLSearchParams
();
params
.
set
(
'
return_sso_url
'
,
this
.
return_sso_url
);
params
.
set
(
'
return_sso_url
'
,
this
.
return_sso_url
);
let
payload
=
Buffer
.
from
(
params
.
toString
()).
toString
(
'
base64
'
);
let
payload
=
Buffer
.
from
(
params
.
toString
()).
toString
(
'
base64
'
);
let
url
=
new
URL
(
'
https://
ygobbs.com/session/sso_provider
'
);
let
url
=
new
URL
(
'
https://
accounts.moecube.com
'
);
params
=
url
[
'
searchParams
'
];
params
=
url
[
'
searchParams
'
];
params
.
set
(
'
sso
'
,
payload
);
params
.
set
(
'
sso
'
,
payload
);
params
.
set
(
'
sig
'
,
crypto
.
createHmac
(
'
sha256
'
,
'
zsZv6LXHDwwtUAGa
'
).
update
(
payload
).
digest
(
'
hex
'
));
params
.
set
(
'
sig
'
,
crypto
.
createHmac
(
'
sha256
'
,
'
zsZv6LXHDwwtUAGa
'
).
update
(
payload
).
digest
(
'
hex
'
));
...
@@ -39,13 +39,13 @@ export class LoginComponent {
...
@@ -39,13 +39,13 @@ export class LoginComponent {
// 暂时 hack 一下登出,因为聊天室现在没办法重新初始化,于是登出后刷新页面。
// 暂时 hack 一下登出,因为聊天室现在没办法重新初始化,于是登出后刷新页面。
params
.
set
(
'
redirect
'
,
'
https://mycard.moe/logout_callback
'
);
params
.
set
(
'
redirect
'
,
'
https://mycard.moe/logout_callback
'
);
this
.
url
=
url
.
toString
()
this
.
url
=
url
.
toString
()
;
}
}
}
}
return_sso
(
return_url
:
string
)
{
return_sso
(
return_url
:
string
)
{
if
(
return_url
===
'
https://mycard.moe/logout_callback
'
)
{
if
(
return_url
===
'
https://mycard.moe/logout_callback
'
)
{
return
location
.
reload
()
return
location
.
reload
()
;
}
}
if
(
!
return_url
.
startsWith
(
this
.
return_sso_url
))
{
if
(
!
return_url
.
startsWith
(
this
.
return_sso_url
))
{
return
;
return
;
...
@@ -55,7 +55,7 @@ export class LoginComponent {
...
@@ -55,7 +55,7 @@ export class LoginComponent {
this
.
loginService
.
login
(
user
);
this
.
loginService
.
login
(
user
);
}
}
toObject
(
entries
:
Iterable
<
[
string
,
any
]
>
):
any
{
toObject
(
entries
:
Iterable
<
[
string
,
any
]
>
):
any
{
let
result
=
{};
let
result
=
{};
for
(
let
[
key
,
value
]
of
entries
)
{
for
(
let
[
key
,
value
]
of
entries
)
{
result
[
key
]
=
value
;
result
[
key
]
=
value
;
...
@@ -63,7 +63,7 @@ export class LoginComponent {
...
@@ -63,7 +63,7 @@ export class LoginComponent {
return
result
;
return
result
;
}
}
openExternal
(
url
:
string
)
{
openExternal
(
url
:
string
)
{
shell
.
openExternal
(
url
);
shell
.
openExternal
(
url
);
}
}
}
}
locale/messages.en-US.xlf
View file @
b8055429
...
@@ -60,6 +60,16 @@
...
@@ -60,6 +60,16 @@
<source>
随机
</source>
<source>
随机
</source>
<target>
Random
</target>
<target>
Random
</target>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"5018459a548611c5e7a8bb9f81f8871358089f69"
>
<source>
正在读取游戏列表...
</source>
<target>
Loading Game List...
</target>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"dc0c986dacfc57a3254d4164784a43c8c78cd5ef"
>
<source>
现在没有等待中的游戏,可以自行创建一个房间或者去匹配
</source>
<target>
There is no opening game available now, you can create a new game yourself, or play ranked game.
</target>
</trans-unit>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"e35d1bf7c735e8df55a62046cd2d9f820bf5bffd"
>
<trans-unit
datatype=
"html"
id=
"e35d1bf7c735e8df55a62046cd2d9f820bf5bffd"
>
<source>
游戏标题
</source>
<source>
游戏标题
</source>
...
@@ -220,6 +230,11 @@
...
@@ -220,6 +230,11 @@
<source><x
id=
"INTERPOLATION"
/>
购买
</source>
<source><x
id=
"INTERPOLATION"
/>
购买
</source>
<target><x
id=
"INTERPOLATION"
/>
Buy
</target>
<target><x
id=
"INTERPOLATION"
/>
Buy
</target>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"0415ea4132361a518cfb8b81e058f4238b85f071"
>
<source>
安装试玩版
</source>
<target>
Install Trial Version
</target>
</trans-unit>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"a8cae935472a05e1c8c9be436bb7b1bdea96a54a"
>
<trans-unit
datatype=
"html"
id=
"a8cae935472a05e1c8c9be436bb7b1bdea96a54a"
>
<source>
安装
</source>
<source>
安装
</source>
...
@@ -450,6 +465,11 @@
...
@@ -450,6 +465,11 @@
<source>
购买
</source>
<source>
购买
</source>
<target>
Buy
</target>
<target>
Buy
</target>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"e81bc577e08b01e7ebe9351760c0c845b3bb2fb4"
>
<source>
返回
</source>
<target>
Return
</target>
</trans-unit>
</trans-unit>
<trans-unit
datatype=
"html"
id=
"ef65da47763167a418e811d9007c53b896b50479"
>
<trans-unit
datatype=
"html"
id=
"ef65da47763167a418e811d9007c53b896b50479"
>
<source>
最小化
</source>
<source>
最小化
</source>
...
...
package.json
View file @
b8055429
{
{
"name"
:
"mycard"
,
"name"
:
"mycard"
,
"version"
:
"3.
0.26
"
,
"version"
:
"3.
1.0
"
,
"description"
:
"mycard"
,
"description"
:
"mycard"
,
"keywords"
:
[],
"keywords"
:
[],
"author"
:
"zh99998 <zh99998@gmail.com>"
,
"author"
:
"zh99998 <zh99998@gmail.com>"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment