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
0a5ddc82
Commit
0a5ddc82
authored
Oct 29, 2016
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize import
parent
ee74a9a4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
146 deletions
+83
-146
app/app-detail.component.html
app/app-detail.component.html
+17
-40
app/app-detail.component.ts
app/app-detail.component.ts
+6
-31
app/apps.service.ts
app/apps.service.ts
+30
-44
app/login.component.ts
app/login.component.ts
+3
-4
app/mycard.component.ts
app/mycard.component.ts
+4
-8
app/ygopro.component.ts
app/ygopro.component.ts
+12
-15
systemjs.config.js
systemjs.config.js
+7
-4
typings.json
typings.json
+4
-0
No files found.
app/app-detail.component.html
View file @
0a5ddc82
<h1>
{{appsService.currentApp.name}}
</h1>
<div
*ngIf=
"!isInstalled"
>
<div
*ngIf=
"!appsService.getDownloadInfo(appsService.currentApp)"
>
<button
type=
"button"
(click)=
"updateInstallConfig()"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#install-modal"
>
安装
<button
type=
"button"
(click)=
"updateInstallConfig()"
class=
"btn btn-primary"
data-toggle=
"modal"
data-target=
"#install-modal"
>
安装
</button>
<button
type=
"button"
class=
"btn btn-secondary"
>
导入
</button>
<!--<button type="button" class="btn btn-secondary">正版代购</button>-->
...
...
@@ -10,10 +9,7 @@
<div
*ngIf=
"appsService.getDownloadInfo(appsService.currentApp)"
>
<div
*ngIf=
"appsService.getDownloadInfo(appsService.currentApp).status === 'install'"
>
正在安装...
</div>
<div
*ngIf=
"appsService.getDownloadInfo(appsService.currentApp).status === 'wait'"
>
等待安装...
</div>
<progress
*ngIf=
"appsService.getDownloadInfo(appsService.currentApp).status === 'active'"
class=
"progress progress-striped progress-animated"
value=
"{{appsService.getDownloadInfo(appsService.currentApp).progress}}"
max=
"100"
>
</progress>
<progress
*ngIf=
"appsService.getDownloadInfo(appsService.currentApp).status === 'active'"
class=
"progress progress-striped progress-animated"
value=
"{{appsService.getDownloadInfo(appsService.currentApp).progress}}"
max=
"100"
></progress>
</div>
</div>
<div
*ngIf=
"isInstalled && (appsService.currentApp.id != 'ygopro')"
>
...
...
@@ -23,7 +19,7 @@
<div
id=
"network"
*ngIf=
"appsService.currentApp.network && appsService.currentApp.network.protocol == 'maotama'"
>
<div
class=
"input-group"
>
<input
*ngIf=
"appsService.connections.get(appsService.currentApp)"
[value]=
"appsService.connections.get(appsService.currentApp).address || 'Loading...'"
readonly
type=
"text"
class=
"form-control"
aria-label=
"Text input with dropdown button"
>
<input
*ngIf=
"appsService.connections.get(appsService.currentApp)"
[value]=
"appsService.connections.get(appsService.currentApp).address || 'Loading...'"
readonly
type=
"text"
class=
"form-control"
aria-label=
"Text input with dropdown button"
title=
"address"
>
<div
class=
"input-group-btn"
>
<button
*ngIf=
"!appsService.connections.get(appsService.currentApp)"
(click)=
"appsService.network(appsService.currentApp, appsService.currentApp.network.servers[0])"
type=
"button"
class=
"btn btn-secondary"
>
联机
...
...
@@ -31,14 +27,12 @@
<button
*ngIf=
"appsService.connections.get(appsService.currentApp)"
(click)=
"copy(appsService.connections.get(appsService.currentApp).address)"
[disabled]=
"!appsService.connections.get(appsService.currentApp).address"
type=
"button"
class=
"btn btn-secondary"
>
复制
</button>
<button
type=
"button"
class=
"btn btn-secondary dropdown-toggle dropdown-toggle-split"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
style=
"height: 38px;"
>
<button
type=
"button"
class=
"btn btn-secondary dropdown-toggle dropdown-toggle-split"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"false"
style=
"height: 38px;"
>
<span
class=
"sr-only"
>
Toggle Dropdown
</span>
</button>
<div
class=
"dropdown-menu"
[class.dropdown-menu-right]=
"appsService.connections.get(appsService.currentApp)"
>
<h6
class=
"dropdown-header"
>
选择服务器
</h6>
<a
*ngFor=
"let server of appsService.currentApp.network.servers"
(click)=
"appsService.network(appsService.currentApp, server)"
class=
"dropdown-item"
href=
"#"
>
{{server.id}}
</a>
<a
*ngFor=
"let server of appsService.currentApp.network.servers"
(click)=
"appsService.network(appsService.currentApp, server)"
class=
"dropdown-item"
href=
"#"
>
{{server.id}}
</a>
</div>
</div>
</div>
...
...
@@ -88,13 +82,9 @@
<button
type=
"button"
class=
"btn btn-danger btn-sm"
>
卸载
</button>
</td>
<td
*ngIf=
"!checkInstall(mod.id)"
>
<button
*ngIf=
"!appsService.getDownloadInfo(mod.id)"
(click)=
"install(mod.id)"
type=
"button"
class=
"btn btn-primary btn-sm"
>
安装
<button
*ngIf=
"!appsService.getDownloadInfo(mod.id)"
(click)=
"install(mod.id)"
type=
"button"
class=
"btn btn-primary btn-sm"
>
安装
</button>
<progress
*ngIf=
"appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'active'"
class=
"progress progress-striped progress-animated"
value=
"{{appsService.getDownloadInfo(mod.id).progress}}"
max=
"100"
></progress>
<progress
*ngIf=
"appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'active'"
class=
"progress progress-striped progress-animated"
value=
"{{appsService.getDownloadInfo(mod.id).progress}}"
max=
"100"
></progress>
<div
*ngIf=
"appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'wait'"
>
等待安装...
</div>
...
...
@@ -117,26 +107,19 @@
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
<h4
class=
"modal-title"
>
{{'settings'|translate}}
</h4>
<ul
class=
"nav nav-tabs"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link active"
data-toggle=
"tab"
href=
"#general"
>
{{'general'|translate}}
</a>
<a
class=
"nav-link active"
data-toggle=
"tab"
href=
"#general"
>
{{'general'|translate}}
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
data-toggle=
"tab"
href=
"#updates"
>
{{'updates'|translate}}
</a>
<a
class=
"nav-link"
data-toggle=
"tab"
href=
"#updates"
>
{{'updates'|translate}}
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
data-toggle=
"tab"
href=
"#local-files"
>
{{'local files'|translate}}
</a>
<a
class=
"nav-link"
data-toggle=
"tab"
href=
"#local-files"
>
{{'local files'|translate}}
</a>
</li>
</ul>
</div>
...
...
@@ -164,10 +147,8 @@
</div>
</div>
</div>
</div>
<!-- Modal -->
<div
class=
"modal fade"
id=
"install-modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
*ngIf=
"installConfig"
>
</div>
<!-- Modal -->
<div
class=
"modal fade"
id=
"install-modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
*ngIf=
"installConfig"
>
<div
class=
"modal-dialog"
role=
"document"
>
<form
id=
"install-form"
class=
"modal-content"
(ngSubmit)=
"install()"
#theForm
="
ngForm
"
>
<div
class=
"modal-header"
>
...
...
@@ -181,7 +162,7 @@
<!-- 安装位置选择只在 windows 下存在, 为了方便调试暂时不加ngif -->
<h4>
{{'install_path'|translate}}
</h4>
<div
class=
"form-group"
>
<select
class=
"form-control"
name=
"installPath"
[(ngModel)]=
"installConfig.installPath"
>
<select
class=
"form-control"
name=
"installPath"
[(ngModel)]=
"installConfig.installPath"
title=
"path"
>
<option
*ngFor=
"let library of settingsService.getLibraries()"
value=
"{{library['path']}}"
>
{{ library['path']}}
</option>
...
...
@@ -190,22 +171,18 @@
<h4>
{{'shortcut'|translate}}
</h4>
<div
class=
"checkbox"
>
<label>
<input
type=
"checkbox"
name=
"application"
[(ngModel)]=
"installConfig.createShortcut"
>
{{'create_shortcut'|translate}}
<input
type=
"checkbox"
name=
"application"
[(ngModel)]=
"installConfig.createShortcut"
>
{{'create_shortcut'|translate}}
</label>
</div>
<div
class=
"checkbox"
>
<label>
<input
type=
"checkbox"
name=
"desktop"
[(ngModel)]=
"installConfig.createDesktopShortcut"
>
{{'create_desktop_shortcut'|translate}}
<input
type=
"checkbox"
name=
"desktop"
[(ngModel)]=
"installConfig.createDesktopShortcut"
>
{{'create_desktop_shortcut'|translate}}
</label>
</div>
<h4>
{{'additions'|translate}}
</h4>
<div
*ngFor=
"let reference of installConfig.references"
>
<label>
<input
type=
"checkbox"
[(ngModel)]=
"reference.id"
name=
"references"
value=
"{{reference.id}}"
>
{{reference.name}}
<input
type=
"checkbox"
[(ngModel)]=
"reference.id"
name=
"references"
value=
"{{reference.id}}"
>
{{reference.name}}
</label>
</div>
</div>
...
...
app/app-detail.component.ts
View file @
0a5ddc82
...
...
@@ -4,31 +4,12 @@ import {InstallConfig} from "./install-config";
import
{
SettingsService
}
from
"
./settings.sevices
"
;
import
{
App
}
from
"
./app
"
;
import
{
DownloadService
}
from
"
./download.service
"
;
import
{
clipboard
,
remote
}
from
"
electron
"
;
import
*
as
path
from
"
path
"
;
import
*
as
child_process
from
"
child_process
"
;
declare
var
System
;
declare
var
$
;
import
*
as
readline
from
'
readline
'
;
import
*
as
os
from
'
os
'
;
import
{
clipboard
,
remote
}
from
'
electron
'
;
const
sudo
=
new
(
System
.
_nodeRequire
(
'
electron-sudo
'
).
default
)({
name
:
'
MyCard
'
});
sudo
.
fork
=
function
(
modulePath
,
args
,
options
)
{
return
sudo
.
spawn
(
remote
.
app
.
getPath
(
'
exe
'
),
[
'
-e
'
,
modulePath
]).
then
((
child
)
=>
{
readline
.
createInterface
({
input
:
child
.
stdout
}).
on
(
'
line
'
,
(
line
)
=>
{
child
.
emit
(
'
message
'
,
JSON
.
parse
(
line
));
});
child
.
send
=
(
message
,
sendHandle
,
options
,
callback
)
=>
{
child
.
stdin
.
write
(
JSON
.
stringify
(
message
)
+
os
.
EOL
);
if
(
callback
)
{
callback
()
}
};
return
child
})
};
@
Component
({
selector
:
'
app-detail
'
,
templateUrl
:
'
app/app-detail.component.html
'
,
...
...
@@ -37,12 +18,6 @@ sudo.fork = function (modulePath, args, options) {
})
export
class
AppDetailComponent
implements
OnInit
{
platform
=
process
.
platform
;
fs
=
window
[
'
System
'
].
_nodeRequire
(
'
fs
'
);
electron
=
window
[
'
System
'
].
_nodeRequire
(
'
electron
'
);
spawn
=
window
[
'
System
'
].
_nodeRequire
(
'
child_process
'
).
spawn
;
path
=
window
[
'
System
'
].
_nodeRequire
(
'
path
'
);
installConfig
:
InstallConfig
;
constructor
(
private
appsService
:
AppsService
,
private
settingsService
:
SettingsService
,
...
...
@@ -146,7 +121,7 @@ export class AppDetailComponent implements OnInit {
}
startApp
(
app
:
App
)
{
let
execute
=
this
.
path
.
join
(
app
.
local
.
path
,
app
.
actions
.
get
(
"
main
"
).
execute
);
let
execute
=
path
.
join
(
app
.
local
.
path
,
app
.
actions
.
get
(
"
main
"
).
execute
);
let
args
=
app
.
actions
.
get
(
"
main
"
).
args
;
let
env
=
app
.
actions
.
get
(
"
main
"
).
env
;
let
opt
=
{
...
...
@@ -158,7 +133,7 @@ export class AppDetailComponent implements OnInit {
let
openApp
=
app
.
actions
.
get
(
"
main
"
).
open
;
if
(
openApp
)
{
if
(
this
.
isInstalled
)
{
open
=
this
.
path
.
join
(
openApp
.
local
.
path
,
openApp
.
actions
.
get
(
"
main
"
).
execute
);
open
=
path
.
join
(
openApp
.
local
.
path
,
openApp
.
actions
.
get
(
"
main
"
).
execute
);
args
.
push
(
execute
);
}
else
{
console
.
error
(
'
open app not found
'
);
...
...
@@ -168,7 +143,7 @@ export class AppDetailComponent implements OnInit {
open
=
execute
;
}
let
handle
=
thi
s
.
spawn
(
open
,
args
,
opt
);
let
handle
=
child_proces
s
.
spawn
(
open
,
args
,
opt
);
handle
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
...
...
app/apps.service.ts
View file @
0a5ddc82
...
...
@@ -3,20 +3,19 @@ import {Http} from "@angular/http";
import
{
App
}
from
"
./app
"
;
import
{
InstallConfig
}
from
"
./install-config
"
;
import
{
SettingsService
}
from
"
./settings.sevices
"
;
declare
var
process
;
declare
var
System
;
const
os
=
System
.
_nodeRequire
(
'
os
'
);
const
fs
=
System
.
_nodeRequire
(
'
fs
'
);
const
path
=
System
.
_nodeRequire
(
'
path
'
);
const
readline
=
System
.
_nodeRequire
(
'
readline
'
);
const
mkdirp
=
System
.
_nodeRequire
(
'
mkdirp
'
);
const
electron
=
System
.
_nodeRequire
(
'
electron
'
);
const
Aria2
=
System
.
_nodeRequire
(
'
aria2
'
);
const
execFile
=
System
.
_nodeRequire
(
'
child_process
'
).
execFile
;
const
sudo
=
new
(
System
.
_nodeRequire
(
'
electron-sudo
'
).
default
)({
name
:
'
MyCard
'
});
sudo
.
fork
=
function
(
modulePath
,
args
,
options
)
{
return
sudo
.
spawn
(
electron
.
remote
.
app
.
getPath
(
'
exe
'
),
[
'
-e
'
,
modulePath
]).
then
((
child
)
=>
{
import
*
as
os
from
"
os
"
;
import
*
as
fs
from
"
fs
"
;
import
*
as
path
from
"
path
"
;
import
*
as
readline
from
"
readline
"
;
import
*
as
mkdirp
from
"
mkdirp
"
;
import
*
as
child_process
from
"
child_process
"
;
import
{
remote
}
from
"
electron
"
;
const
Aria2
=
require
(
'
aria2
'
);
const
Sudo
=
require
(
'
electron-sudo
'
).
default
;
Sudo
.
prototype
.
fork
=
function
(
modulePath
,
args
,
options
)
{
return
this
.
spawn
(
remote
.
app
.
getPath
(
'
exe
'
),
[
'
-e
'
,
modulePath
].
concat
(
args
),
options
).
then
((
child
)
=>
{
readline
.
createInterface
({
input
:
child
.
stdout
}).
on
(
'
line
'
,
(
line
)
=>
{
child
.
emit
(
'
message
'
,
JSON
.
parse
(
line
));
});
...
...
@@ -30,8 +29,6 @@ sudo.fork = function (modulePath, args, options) {
})
};
//const sudo = System._nodeRequire('sudo-prompt');
@
Injectable
()
export
class
AppsService
{
...
...
@@ -101,7 +98,7 @@ export class AppsService {
xzFile
:
res
.
files
[
0
].
path
,
installDir
:
this
.
installConfig
.
installPath
};
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
)
=>
{
let
refs
=
this
.
searchApp
(
this
.
downloadsInfo
[
index
].
id
).
references
;
console
.
log
(
refs
);
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
...
...
@@ -127,7 +124,7 @@ export class AppsService {
// }
// });
// }
console
.
log
(
"
wait obj:
"
,
waitObj
);
//
console.log("wait obj:", waitObj);
if
(
waitObj
)
{
this
.
waitInstallQueue
.
push
(
waitObj
);
...
...
@@ -148,16 +145,16 @@ export class AppsService {
}
});
};
this
.
_aria2
.
onmessage
=
(
m
)
=>
{
//console.log('IN:', m);
//console.log('download infoi:', this.downloadsInfo);
//
this._aria2.onmessage = (m)=> {
//console.log('IN:', m);
//console.log('download infoi:', this.downloadsInfo);
}
//
}
}
if
(
!
this
.
aria2IsOpen
)
{
this
.
_aria2
.
open
().
then
(()
=>
{
console
.
log
(
'
aria2 websocket open
'
)
console
.
log
(
'
aria2 websocket open
'
)
;
this
.
aria2IsOpen
=
true
;
});
}
...
...
@@ -166,9 +163,9 @@ export class AppsService {
}
_download_dir
;
//
_download_dir;
get
download_dir
()
{
const
dir
=
path
.
join
(
electron
.
remote
.
app
.
getAppPath
(),
'
cache
'
);
const
dir
=
path
.
join
(
remote
.
app
.
getAppPath
(),
'
cache
'
);
if
(
!
fs
.
existsSync
(
dir
))
{
console
.
log
(
'
cache not exists
'
);
...
...
@@ -189,7 +186,7 @@ export class AppsService {
.
map
(
response
=>
{
let
apps
=
response
.
json
();
let
localAppData
=
JSON
.
parse
(
localStorage
.
getItem
(
"
localAppData
"
));
apps
=
apps
.
map
((
app
)
=>
{
apps
=
apps
.
map
((
app
:
any
)
=>
{
if
(
localAppData
)
{
localAppData
.
map
((
v
)
=>
{
if
(
v
.
id
===
app
.
id
)
{
...
...
@@ -252,7 +249,7 @@ export class AppsService {
// 设置App关系
for
(
let
id
of
Array
.
from
(
apps
.
keys
()))
{
let
temp
=
apps
.
get
(
id
)[
"
actions
"
]
let
temp
=
apps
.
get
(
id
)[
"
actions
"
]
;
let
map
=
new
Map
<
string
,
any
>
();
for
(
let
action
of
Object
.
keys
(
temp
))
{
let
openId
=
temp
[
action
][
"
open
"
];
...
...
@@ -312,7 +309,7 @@ export class AppsService {
}
uninstall
(
id
:
string
)
{
let
current
=
this
;
//
let current = this;
if
(
this
.
checkInstall
(
id
))
{
let
files
:
string
[]
=
this
.
searchApp
(
id
).
local
.
files
.
sort
().
reverse
();
// 删除本目录
...
...
@@ -362,7 +359,7 @@ export class AppsService {
getInstallConfig
(
app
:
App
):
InstallConfig
{
let
id
=
app
.
id
;
//
let id = app.id;
this
.
installConfig
=
new
InstallConfig
(
app
);
let
platform
=
process
.
platform
;
let
references
:
InstallConfig
[]
=
[];
...
...
@@ -440,7 +437,7 @@ export class AppsService {
});
}
let
tar
=
execFile
(
tarPath
,
[
'
xvf
'
,
xzFile
,
'
-C
'
,
installDir
],
opt
,
(
err
,
stdout
,
stderr
)
=>
{
let
tar
=
child_process
.
execFile
(
tarPath
,
[
'
xvf
'
,
xzFile
,
'
-C
'
,
installDir
],
opt
,
(
err
,
stdout
,
stderr
)
=>
{
if
(
err
)
{
throw
err
;
}
...
...
@@ -494,11 +491,7 @@ export class AppsService {
}
});
this
.
waitInstallQueue
=
this
.
waitInstallQueue
.
filter
((
waitObj
)
=>
{
if
(
waitObj
)
{
return
true
;
}
else
{
return
false
;
}
return
waitObj
});
console
.
log
(
tmp
);
...
...
@@ -511,15 +504,8 @@ export class AppsService {
}
isEmptyObject
(
e
)
{
let
t
;
for
(
t
in
e
)
return
!
1
;
return
!
0
}
browse
(
app
:
App
)
{
electron
.
remote
.
shell
.
showItemInFolder
(
app
.
local
.
path
);
remote
.
shell
.
showItemInFolder
(
app
.
local
.
path
);
}
connections
=
new
Map
<
App
,
{
connection
:
WebSocket
,
address
:
string
}
>
();
...
...
@@ -527,7 +513,7 @@ export class AppsService {
network
(
app
:
App
,
server
)
{
if
(
!
this
.
maotama
)
{
this
.
maotama
=
sudo
.
fork
(
'
maotama
'
)
this
.
maotama
=
new
Sudo
({
name
:
'
MyCard
'
})
.
fork
(
'
maotama
'
)
}
this
.
maotama
.
then
((
child
)
=>
{
let
connection
=
this
.
connections
.
get
(
app
);
...
...
app/login.component.ts
View file @
0a5ddc82
...
...
@@ -3,10 +3,9 @@
*/
import
{
Component
}
from
"
@angular/core
"
;
import
{
LoginService
}
from
"
./login.service
"
;
declare
var
System
;
const
crypto
=
System
.
_nodeRequire
(
'
crypto
'
);
const
querystring
=
System
.
_nodeRequire
(
'
querystring
'
);
const
url
=
System
.
_nodeRequire
(
'
url
'
);
import
*
as
crypto
from
"
crypto
"
;
import
*
as
querystring
from
"
querystring
"
;
import
*
as
url
from
"
url
"
;
@
Component
({
selector
:
'
login
'
,
...
...
app/mycard.component.ts
View file @
0a5ddc82
import
{
Component
,
Renderer
}
from
"
@angular/core
"
;
import
{
TranslateService
}
from
"
ng2-translate
"
;
import
{
LoginService
}
from
"
./login.service
"
;
const
electron
=
System
.
_nodeRequire
(
'
electron
'
);
declare
var
process
;
declare
var
System
;
import
{
remote
}
from
"
electron
"
;
@
Component
({
selector
:
'
mycard
'
,
...
...
@@ -18,7 +14,7 @@ export class MyCardComponent {
platform
=
process
.
platform
;
constructor
(
private
renderer
:
Renderer
,
private
translate
:
TranslateService
,
private
loginService
:
LoginService
)
{
constructor
(
private
renderer
:
Renderer
,
private
translate
:
TranslateService
)
{
renderer
.
listenGlobal
(
'
window
'
,
'
message
'
,
(
event
)
=>
{
console
.
log
(
event
);
// Do something with 'event'
...
...
@@ -28,12 +24,12 @@ export class MyCardComponent {
translate
.
setDefaultLang
(
'
en-US
'
);
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate
.
use
(
electron
.
remote
.
app
.
getLocale
());
translate
.
use
(
remote
.
app
.
getLocale
());
}
refresh
()
{
electron
.
remote
.
getCurrentWindow
().
reload
()
remote
.
getCurrentWindow
().
reload
()
}
}
app/ygopro.component.ts
View file @
0a5ddc82
...
...
@@ -3,19 +3,16 @@
*/
import
{
Component
,
OnInit
,
ChangeDetectorRef
}
from
"
@angular/core
"
;
import
{
AppsService
}
from
"
./apps.service
"
;
import
*
as
fs
from
"
fs
"
;
import
*
as
path
from
"
path
"
;
import
*
as
crypto
from
"
crypto
"
;
import
*
as
child_process
from
"
child_process
"
;
import
{
remote
}
from
"
electron
"
;
import
*
as
ini
from
"
ini
"
;
import
{
EncodeOptions
}
from
"
ini
"
;
declare
var
process
;
declare
var
System
;
declare
var
$
;
const
fs
=
System
.
_nodeRequire
(
'
fs
'
);
const
path
=
System
.
_nodeRequire
(
'
path
'
);
const
crypto
=
System
.
_nodeRequire
(
'
crypto
'
);
const
child_process
=
System
.
_nodeRequire
(
'
child_process
'
);
const
ini
=
System
.
_nodeRequire
(
'
ini
'
);
const
electron
=
System
.
_nodeRequire
(
'
electron
'
);
@
Component
({
selector
:
'
ygopro
'
,
templateUrl
:
'
app/ygopro.component.html
'
,
...
...
@@ -170,7 +167,7 @@ export class YGOProComponent implements OnInit {
save_system_conf
=
(
data
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
writeFile
(
this
.
system_conf
,
ini
.
stringify
(
data
,
{
whitespace
:
true
}),
(
error
)
=>
{
fs
.
writeFile
(
this
.
system_conf
,
ini
.
stringify
(
data
,
<
EncodeOptions
>
{
whitespace
:
true
}),
(
error
)
=>
{
if
(
error
)
return
reject
(
error
);
resolve
(
data
);
});
...
...
@@ -186,7 +183,7 @@ export class YGOProComponent implements OnInit {
data
[
'
lastport
'
]
=
server
.
port
;
data
[
'
roompass
'
]
=
name
;
data
[
'
nickname
'
]
=
this
.
user
.
username
;
console
.
log
(
data
)
console
.
log
(
data
)
;
return
data
})
.
then
(
this
.
save_system_conf
)
...
...
@@ -200,10 +197,10 @@ export class YGOProComponent implements OnInit {
}
start_game
=
(
args
)
=>
{
let
win
=
electron
.
remote
.
getCurrentWindow
();
let
win
=
remote
.
getCurrentWindow
();
win
.
minimize
();
return
new
Promise
((
resolve
,
reject
)
=>
{
let
child
=
child_process
.
spawn
(
path
.
join
(
this
.
app
.
local
.
path
,
this
.
app
.
actions
[
process
.
platform
][
'
main
'
][
'
execute
'
]
),
args
,
{
cwd
:
this
.
app
.
local
.
path
});
let
child
=
child_process
.
spawn
(
path
.
join
(
this
.
app
.
local
.
path
,
this
.
app
.
actions
.
get
(
'
main
'
).
execute
),
args
,
{
cwd
:
this
.
app
.
local
.
path
});
child
.
on
(
'
error
'
,
(
error
)
=>
{
reject
(
error
);
win
.
restore
()
...
...
@@ -235,7 +232,7 @@ export class YGOProComponent implements OnInit {
}
let
password
=
options_buffer
.
toString
(
'
base64
'
)
+
options
.
title
.
replace
(
/
\s
/
,
String
.
fromCharCode
(
0xFEFF
));
let
room_id
=
crypto
.
createHash
(
'
md5
'
).
update
(
password
+
this
.
user
.
username
).
digest
(
'
base64
'
).
slice
(
0
,
10
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
)
let
room_id
=
crypto
.
createHash
(
'
md5
'
).
update
(
password
+
this
.
user
.
username
).
digest
(
'
base64
'
).
slice
(
0
,
10
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
)
;
this
.
join
(
password
,
this
.
servers
[
0
]);
}
...
...
systemjs.config.js
View file @
0a5ddc82
...
...
@@ -2,7 +2,6 @@
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(
function
(
global
)
{
// map tells the System loader where to look for things
var
map
=
{
'
app
'
:
'
app
'
,
// 'dist',
...
...
@@ -11,8 +10,7 @@
'
rxjs
'
:
'
node_modules/rxjs
'
,
'
ng2-translate
'
:
'
node_modules/ng2-translate/bundles/index.js
'
,
"
electron
"
:
"
@node/electron
"
,
"
readline
"
:
"
@node/readline
"
,
"
os
"
:
"
@node/os
"
"
ini
"
:
"
@node/ini
"
,
};
// packages tells the System loader how to load when no filename and/or no extension
var
packages
=
{
...
...
@@ -20,6 +18,12 @@
'
rxjs
'
:
{
defaultExtension
:
'
js
'
},
'
angular2-in-memory-web-api
'
:
{
main
:
'
index.js
'
,
defaultExtension
:
'
js
'
}
};
let
builtin_modules
=
[
"
buffer
"
,
"
querystring
"
,
"
events
"
,
"
http
"
,
"
cluster
"
,
"
zlib
"
,
"
os
"
,
"
https
"
,
"
punycode
"
,
"
repl
"
,
"
readline
"
,
"
vm
"
,
"
child_process
"
,
"
url
"
,
"
dns
"
,
"
net
"
,
"
dgram
"
,
"
fs
"
,
"
path
"
,
"
string_decoder
"
,
"
tls
"
,
"
crypto
"
,
"
stream
"
,
"
util
"
,
"
assert
"
,
"
tty
"
,
"
domain
"
,
"
constants
"
,
"
process
"
,
"
v8
"
,
"
timers
"
,
"
console
"
];
for
(
let
mod
of
builtin_modules
)
{
map
[
mod
]
=
`@node/
${
mod
}
`
;
}
var
ngPackageNames
=
[
'
common
'
,
'
compiler
'
,
...
...
@@ -51,4 +55,3 @@
packages
:
packages
};
System
.
config
(
config
);
})(
this
);
typings.json
View file @
0a5ddc82
...
...
@@ -2,7 +2,11 @@
"globalDependencies"
:
{
"core-js"
:
"registry:dt/core-js"
,
"electron/github-electron"
:
"registry:dt/electron/github-electron"
,
"ini"
:
"registry:dt/ini"
,
"jasmine"
:
"registry:dt/jasmine"
,
"node"
:
"registry:dt/node"
},
"dependencies"
:
{
"mkdirp"
:
"registry:npm/mkdirp"
}
}
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