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
3bdfcb80
Commit
3bdfcb80
authored
Oct 20, 2016
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加卸载
parent
6c86bc5d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
174 additions
and
96 deletions
+174
-96
app/app-detail.component.html
app/app-detail.component.html
+72
-11
app/app-detail.component.ts
app/app-detail.component.ts
+7
-5
app/apps.service.ts
app/apps.service.ts
+87
-78
i18n/zh-CN.json
i18n/zh-CN.json
+6
-1
index.js
index.js
+1
-1
systemjs.config.js
systemjs.config.js
+1
-0
No files found.
app/app-detail.component.html
View file @
3bdfcb80
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
</div>
</div>
<div
*ngIf=
"isInstalled"
>
<div
*ngIf=
"isInstalled"
>
<button
(click)=
"startApp(routingService.app)"
type=
"button"
class=
"btn btn-primary"
>
运行
</button>
<button
(click)=
"startApp(routingService.app)"
type=
"button"
class=
"btn btn-primary"
>
运行
</button>
<button
type=
"button"
class=
"btn btn-secondary"
>
设置
</button>
<button
type=
"button"
class=
"btn btn-secondary"
data-toggle=
"modal"
data-target=
"#settings-modal"
>
设置
</button>
<button
(click)=
"openDir(routingService.app)"
type=
"button"
class=
"btn btn-secondary"
>
游览本地文件
</button>
<button
(click)=
"openDir(routingService.app)"
type=
"button"
class=
"btn btn-secondary"
>
游览本地文件
</button>
<button
type=
"button"
class=
"btn btn-secondary"
>
联机
</button>
<button
type=
"button"
class=
"btn btn-secondary"
>
联机
</button>
</div>
</div>
...
@@ -65,12 +65,22 @@
...
@@ -65,12 +65,22 @@
<td>
{{'app.' + mod.id + '.name' | translate}}
</td>
<td>
{{'app.' + mod.id + '.name' | translate}}
</td>
<td>
{{mod.type}}
</td>
<td>
{{mod.type}}
</td>
<td
*ngIf=
"checkInstall(mod.id)"
>
<td
*ngIf=
"checkInstall(mod.id)"
>
<button
type=
"button"
class=
"btn btn-danger btn-sm"
>
卸载
</button></td>
<button
type=
"button"
class=
"btn btn-danger btn-sm"
>
卸载
</button>
</td>
<td
*ngIf=
"!checkInstall(mod.id)"
>
<td
*ngIf=
"!checkInstall(mod.id)"
>
<button
*ngIf=
"!appsService.getDownloadInfo(mod.id)"
(click)=
"install(mod.id)"
type=
"button"
class=
"btn btn-primary btn-sm"
>
安装
</button>
<button
*ngIf=
"!appsService.getDownloadInfo(mod.id)"
(click)=
"install(mod.id)"
type=
"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>
class=
"btn btn-primary btn-sm"
>
安装
<div
*ngIf=
"appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'wait'"
>
等待安装...
</div>
</button>
<div
*ngIf=
"appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'install'"
>
正在安装...
</div>
<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>
<div
*ngIf=
"appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'install'"
>
正在安装...
</div>
</td>
</td>
</tr>
</tr>
</tbody>
</tbody>
...
@@ -84,13 +94,60 @@
...
@@ -84,13 +94,60 @@
{{appsService.tarQueue | json}}
{{appsService.tarQueue | json}}
{{appsService.waitInstallQueue | json}}
{{appsService.waitInstallQueue | json}}
</pre>
</pre>
<button
(click)=
"appsService.doTar()"
>
DOTAR
</button>
<button
(click)=
"appsService.doTar()"
>
DOTAR
</button>
<div
class=
"modal fade"
id=
"settings-modal"
tabindex=
"-1"
>
<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"
>
<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>
</li>
<li
class=
"nav-item"
>
<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>
</li>
</ul>
</div>
<div
class=
"modal-body"
>
<div
class=
"tab-content"
>
<div
id=
"general"
role=
"tabpanel"
class=
"tab-pane fade active"
>
</div>
<div
id=
"updates"
role=
"tabpanel"
class=
"tab-pane fade"
>
</div>
<div
id=
"local-files"
role=
"tabpanel"
class=
"tab-pane fade"
>
<button
type=
"button"
(click)=
"uninstall()"
>
{{'uninstall'|translate}}
</button>
</div>
</div>
</div>
<div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<!-- Modal -->
<div
class=
"modal fade"
id=
"install-modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
<div
class=
"modal fade"
id=
"install-modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-dialog"
role=
"document"
>
<form
class=
"modal-content"
(ngSubmit)=
"installSubmit(theForm)"
#theForm
="
ngForm
"
>
<form
id=
"install-form"
class=
"modal-content"
(ngSubmit)=
"installSubmit(theForm)"
#theForm
="
ngForm
"
>
<div
class=
"modal-header"
>
<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>
<span
aria-hidden=
"true"
>
×
</span>
...
@@ -103,7 +160,8 @@
...
@@ -103,7 +160,8 @@
<h4>
安装位置
</h4>
<h4>
安装位置
</h4>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<input
type=
"text"
[(ngModel)]=
"appsService.installConfig.installDir"
name=
"installDir"
class=
"form-control"
placeholder=
"安装位置"
>
<input
type=
"text"
[(ngModel)]=
"appsService.installConfig.installDir"
name=
"installDir"
class=
"form-control"
placeholder=
"安装位置"
>
<span
class=
"input-group-btn"
>
<span
class=
"input-group-btn"
>
<button
(click)=
"selectDir()"
class=
"btn btn-secondary"
type=
"button"
>
浏览
</button>
<button
(click)=
"selectDir()"
class=
"btn btn-secondary"
type=
"button"
>
浏览
</button>
</span>
</span>
...
@@ -112,7 +170,8 @@
...
@@ -112,7 +170,8 @@
<h4>
快捷方式
</h4>
<h4>
快捷方式
</h4>
<div
class=
"checkbox"
>
<div
class=
"checkbox"
>
<label>
<label>
<input
type=
"checkbox"
[(ngModel)]=
"appsService.installConfig.shortcut.application"
name=
"application"
>
<input
type=
"checkbox"
[(ngModel)]=
"appsService.installConfig.shortcut.application"
name=
"application"
>
创建应用程序快捷方式
创建应用程序快捷方式
</label>
</label>
</div>
</div>
...
@@ -133,10 +192,12 @@
...
@@ -133,10 +192,12 @@
</div>
</div>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
取消
</button>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
取消
</button>
<button
type=
"submit"
[disabled]=
"!theForm.form.valid"
class=
"btn btn-primary"
>
安装
</button>
<button
id=
"submit"
type=
"submit"
[disabled]=
"!theForm.form.valid"
class=
"btn btn-primary"
>
安装
</button>
</div>
</div>
<!--
<!--
-->
-->
</form>
</form>
</div>
</div>
</div>
</div>
app/app-detail.component.ts
View file @
3bdfcb80
...
@@ -5,7 +5,6 @@ import {App} from "./app";
...
@@ -5,7 +5,6 @@ import {App} from "./app";
declare
var
process
;
declare
var
process
;
declare
var
$
;
declare
var
$
;
@
Component
({
@
Component
({
selector
:
'
app-detail
'
,
selector
:
'
app-detail
'
,
templateUrl
:
'
app/app-detail.component.html
'
,
templateUrl
:
'
app/app-detail.component.html
'
,
...
@@ -105,13 +104,18 @@ export class AppDetailComponent {
...
@@ -105,13 +104,18 @@ export class AppDetailComponent {
install
(
id
)
{
install
(
id
)
{
let
uri
=
this
.
appsService
.
searchApp
(
id
).
download
[
process
.
platform
];
let
uri
=
this
.
appsService
.
searchApp
(
id
).
download
[
process
.
platform
];
console
.
log
(
process
.
platform
);
$
(
'
#install-modal
'
).
modal
(
'
hide
'
);
if
(
uri
)
{
if
(
uri
)
{
this
.
appsService
.
download
(
id
,
uri
);
this
.
appsService
.
download
(
id
,
uri
);
}
else
{
}
else
{
console
.
log
(
"
lost download uri!
"
);
console
.
log
(
"
lost download uri!
"
);
}
}
}
uninstall
(
id
:
string
)
{
id
=
this
.
currentApp
.
id
;
this
.
appsService
.
uninstall
(
id
);
}
}
...
@@ -123,8 +127,6 @@ export class AppDetailComponent {
...
@@ -123,8 +127,6 @@ export class AppDetailComponent {
this
.
install
(
mod
);
this
.
install
(
mod
);
}
}
}
}
$
(
"
#install-modal
"
).
modal
(
"
hide
"
);
}
}
selectDir
()
{
selectDir
()
{
...
...
app/apps.service.ts
View file @
3bdfcb80
...
@@ -13,19 +13,15 @@ export class AppsService {
...
@@ -13,19 +13,15 @@ export class AppsService {
constructor
(
private
http
:
Http
,
private
translate
:
TranslateService
)
{
constructor
(
private
http
:
Http
,
private
translate
:
TranslateService
)
{
let
loop
=
setInterval
(()
=>
{
let
loop
=
setInterval
(()
=>
{
this
.
aria2
.
tellActive
().
then
((
res
)
=>
{
this
.
aria2
.
tellActive
().
then
((
res
)
=>
{
//console.log('res:', res);
if
(
res
)
{
if
(
res
)
{
res
.
map
((
v
)
=>
{
res
.
map
((
v
)
=>
{
let
index
=
this
.
downloadsInfo
.
findIndex
((
info
)
=>
{
let
index
=
this
.
downloadsInfo
.
findIndex
((
info
)
=>
{
return
info
.
gid
==
v
.
gid
;
return
info
.
gid
==
v
.
gid
;
});
});
this
.
downloadsInfo
[
index
].
progress
=
(
v
.
completedLength
/
v
.
totalLength
)
*
100
;
this
.
downloadsInfo
[
index
].
progress
=
(
v
.
completedLength
/
v
.
totalLength
)
*
100
;
});
});
}
}
//this.downloadsInfo = res;
})
})
},
1000
);
},
1000
);
...
@@ -67,12 +63,13 @@ export class AppsService {
...
@@ -67,12 +63,13 @@ export class AppsService {
this
.
aria2IsOpen
=
false
;
this
.
aria2IsOpen
=
false
;
};
};
this
.
_aria2
.
onDownloadComplete
=
(
response
)
=>
{
this
.
_aria2
.
onDownloadComplete
=
(
response
)
=>
{
console
.
log
(
response
);
console
.
log
(
"
download response:
"
,
response
);
this
.
_aria2
.
tellStatus
(
response
.
gid
,
(
err
,
res
)
=>
{
this
.
_aria2
.
tellStatus
(
response
.
gid
,
(
err
,
res
)
=>
{
console
.
log
(
res
);
let
index
=
this
.
downloadsInfo
.
findIndex
((
v
)
=>
{
let
index
=
this
.
downloadsInfo
.
findIndex
((
v
)
=>
{
return
v
.
gid
==
res
.
gid
});
return
v
.
gid
==
res
.
gid
if
(
index
!==
-
1
)
{
});
if
(
res
.
followedBy
)
{
if
(
index
!==
-
1
)
{
if
(
res
.
followedBy
)
{
this
.
downloadsInfo
[
index
].
gid
=
res
.
followedBy
[
0
];
this
.
downloadsInfo
[
index
].
gid
=
res
.
followedBy
[
0
];
this
.
downloadsInfo
[
index
].
progress
=
0
;
this
.
downloadsInfo
[
index
].
progress
=
0
;
...
@@ -83,18 +80,18 @@ export class AppsService {
...
@@ -83,18 +80,18 @@ export class AppsService {
xzFile
:
res
.
files
[
0
].
path
,
xzFile
:
res
.
files
[
0
].
path
,
installDir
:
this
.
installConfig
.
installDir
installDir
:
this
.
installConfig
.
installDir
};
};
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
let
promise
=
new
Promise
((
resolve
,
reject
)
=>
{
let
refs
=
this
.
searchApp
(
this
.
downloadsInfo
[
index
].
id
).
references
;
let
refs
=
this
.
searchApp
(
this
.
downloadsInfo
[
index
].
id
).
references
;
console
.
log
(
refs
);
console
.
log
(
refs
);
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
let
waitObj
;
let
waitObj
;
let
waitRef
=
[
"
runtime
"
,
"
emulator
"
,
"
dependency
"
];
let
waitRef
=
[
"
runtime
"
,
"
emulator
"
,
"
dependency
"
];
if
(
!
this
.
isEmptyObject
(
refs
))
{
if
(
!
this
.
isEmptyObject
(
refs
))
{
refs
[
process
.
platform
].
map
((
ref
)
=>
{
refs
[
process
.
platform
].
map
((
ref
)
=>
{
if
(
waitRef
.
includes
(
ref
.
type
))
{
if
(
waitRef
.
includes
(
ref
.
type
))
{
if
(
!
this
.
checkInstall
(
ref
.
id
))
{
if
(
!
this
.
checkInstall
(
ref
.
id
))
{
if
(
!
waitObj
)
{
if
(
!
waitObj
)
{
waitObj
=
{
waitObj
=
{
id
:
this
.
downloadsInfo
[
index
].
id
,
id
:
this
.
downloadsInfo
[
index
].
id
,
wait
:
[
ref
.
id
],
wait
:
[
ref
.
id
],
...
@@ -110,17 +107,17 @@ export class AppsService {
...
@@ -110,17 +107,17 @@ export class AppsService {
}
}
console
.
log
(
"
wait obj:
"
,
waitObj
);
console
.
log
(
"
wait obj:
"
,
waitObj
);
if
(
waitObj
)
{
if
(
waitObj
)
{
this
.
waitInstallQueue
.
push
(
waitObj
);
this
.
waitInstallQueue
.
push
(
waitObj
);
}
else
{
}
else
{
resolve
();
resolve
();
}
}
}).
then
(()
=>
{
}).
then
(()
=>
{
console
.
log
(
tarObj
);
console
.
log
(
tarObj
);
this
.
tarPush
(
tarObj
);
this
.
tarPush
(
tarObj
);
});
});
promise
.
catch
((
err
)
=>
{
promise
.
catch
((
err
)
=>
{
console
.
log
(
"
err
"
,
err
);
console
.
log
(
"
err
"
,
err
);
})
})
}
}
...
@@ -170,12 +167,12 @@ export class AppsService {
...
@@ -170,12 +167,12 @@ export class AppsService {
.
map
(
response
=>
{
.
map
(
response
=>
{
let
apps
=
response
.
json
();
let
apps
=
response
.
json
();
let
localAppData
=
JSON
.
parse
(
localStorage
.
getItem
(
"
localAppData
"
));
let
localAppData
=
JSON
.
parse
(
localStorage
.
getItem
(
"
localAppData
"
));
console
.
log
(
"
app:
"
,
apps
);
console
.
log
(
"
app:
"
,
apps
);
console
.
log
(
"
store:
"
,
localAppData
);
console
.
log
(
"
store:
"
,
localAppData
);
apps
=
apps
.
map
((
app
)
=>
{
apps
=
apps
.
map
((
app
)
=>
{
if
(
localAppData
)
{
if
(
localAppData
)
{
localAppData
.
map
((
v
)
=>
{
localAppData
.
map
((
v
)
=>
{
if
(
v
.
id
==
app
.
id
)
{
if
(
v
.
id
==
app
.
id
)
{
app
.
local
=
v
.
local
;
app
.
local
=
v
.
local
;
}
}
});
});
...
@@ -191,7 +188,9 @@ export class AppsService {
...
@@ -191,7 +188,9 @@ export class AppsService {
for
(
let
app
of
data
)
{
for
(
let
app
of
data
)
{
//console.log(app)
//console.log(app)
for
(
let
attribute
of
[
'
name
'
,
'
description
'
])
{
for
(
let
attribute
of
[
'
name
'
,
'
description
'
])
{
if
(
!
app
[
attribute
]){
continue
}
//这句应当是不需要的, 如果转换成了 App 类型, 应当保证一定有这些属性
if
(
!
app
[
attribute
])
{
continue
}
//这句应当是不需要的, 如果转换成了 App 类型, 应当保证一定有这些属性
for
(
let
locale
of
Object
.
keys
(
app
[
attribute
]))
{
for
(
let
locale
of
Object
.
keys
(
app
[
attribute
]))
{
let
result
=
{};
let
result
=
{};
result
[
`app.
${
app
[
'
id
'
]}
.
${
attribute
}
`
]
=
app
[
attribute
][
locale
];
result
[
`app.
${
app
[
'
id
'
]}
.
${
attribute
}
`
]
=
app
[
attribute
][
locale
];
...
@@ -210,44 +209,59 @@ export class AppsService {
...
@@ -210,44 +209,59 @@ export class AppsService {
searchApp
(
id
):
App
{
searchApp
(
id
):
App
{
let
data
=
this
.
data
;
let
data
=
this
.
data
;
let
tmp
;
let
tmp
;
if
(
data
)
{
if
(
data
)
{
tmp
=
data
.
find
((
v
)
=>
v
.
id
===
id
);
tmp
=
data
.
find
((
v
)
=>
v
.
id
===
id
);
return
tmp
;
return
tmp
;
}
}
}
}
checkInstall
(
id
):
boolean
{
checkInstall
(
id
):
boolean
{
if
(
this
.
searchApp
(
id
))
{
if
(
this
.
searchApp
(
id
))
{
if
(
this
.
searchApp
(
id
).
local
.
path
)
{
if
(
this
.
searchApp
(
id
).
local
.
path
)
{
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
}
}
download
(
id
,
uri
)
{
deleteFile
(
path
:
string
)
{
//console.log(id);
return
new
Promise
((
resolve
,
reject
)
=>
{
//console.log(uri);
this
.
fs
.
unlink
(
path
,
(
err
)
=>
{
//console.log(i);
resolve
(
path
);
if
(
this
.
downloadsInfo
.
findIndex
((
v
)
=>
{
return
v
.
id
==
id
})
!==
-
1
)
{
});
console
.
log
(
"
this app downloading
"
)
});
}
uninstall
(
id
)
{
if
(
this
.
checkInstall
(
id
))
{
let
files
=
this
.
searchApp
(
id
).
local
.
files
.
sort
().
reverse
();
files
.
reduce
((
pre
,
curr
,
index
,
arr
)
=>
{
this
.
deleteFile
(
curr
).
then
((
path
)
=>
{
console
.
log
(
"
delete
"
,
path
)
});
return
"
1
"
})
}
}
download
(
id
,
uri
)
{
if
(
this
.
downloadsInfo
.
findIndex
((
v
)
=>
{
return
v
.
id
==
id
})
!==
-
1
)
{
console
.
log
(
"
this app is downloading
"
)
}
else
{
}
else
{
this
.
aria2
.
addUri
([
uri
],
{
'
dir
'
:
this
.
download_dir
},
(
error
,
gid
)
=>
{
this
.
aria2
.
addUri
([
uri
],
{
'
dir
'
:
this
.
download_dir
},
(
error
,
gid
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
error
);
console
.
error
(
error
);
}
}
//console.log(gid);
this
.
downloadsInfo
.
push
({
"
id
"
:
id
,
"
gid
"
:
gid
,
"
status
"
:
"
active
"
,
"
progress
"
:
0
});
this
.
downloadsInfo
.
push
({
"
id
"
:
id
,
"
gid
"
:
gid
,
"
status
"
:
"
active
"
,
"
progress
"
:
0
});
});
});
}
}
}
}
getDownloadInfo
(
id
)
{
getDownloadInfo
(
id
)
{
let
info
;
let
info
;
info
=
this
.
downloadsInfo
.
find
((
v
)
=>
{
info
=
this
.
downloadsInfo
.
find
((
v
)
=>
{
return
v
.
id
==
id
;
return
v
.
id
==
id
;
});
});
...
@@ -255,12 +269,15 @@ export class AppsService {
...
@@ -255,12 +269,15 @@ export class AppsService {
}
}
installConfig
;
installConfig
;
createInstallConfig
(
id
)
{
createInstallConfig
(
id
)
{
let
app
=
this
.
data
.
find
((
app
)
=>
{
return
app
.
id
==
id
;});
let
app
=
this
.
data
.
find
((
app
)
=>
{
return
app
.
id
==
id
;
});
let
platform
=
process
.
platform
;
let
platform
=
process
.
platform
;
let
mods
=
{};
let
mods
=
{};
if
(
app
.
references
[
platform
])
{
if
(
app
.
references
[
platform
])
{
app
.
references
[
platform
].
map
((
mod
)
=>
{
app
.
references
[
platform
].
map
((
mod
)
=>
{
mods
[
mod
.
id
]
=
false
;
mods
[
mod
.
id
]
=
false
;
});
});
...
@@ -287,11 +304,10 @@ export class AppsService {
...
@@ -287,11 +304,10 @@ export class AppsService {
tarPush
(
tarObj
)
{
tarPush
(
tarObj
)
{
this
.
tarQueue
.
push
(
tarObj
);
this
.
tarQueue
.
push
(
tarObj
);
if
(
this
.
tarQueue
.
length
>
0
&&
!
this
.
isExtracting
)
{
if
(
this
.
tarQueue
.
length
>
0
&&
!
this
.
isExtracting
)
{
this
.
doTar
();
this
.
doTar
();
}
}
}
}
doTar
()
{
doTar
()
{
...
@@ -306,11 +322,10 @@ export class AppsService {
...
@@ -306,11 +322,10 @@ export class AppsService {
default
:
default
:
throw
'
unsupported platform
'
;
throw
'
unsupported platform
'
;
}
}
let
opt
=
{
let
opt
=
{};
};
let
tarObj
;
let
tarObj
;
if
(
this
.
tarQueue
.
length
>
0
)
{
if
(
this
.
tarQueue
.
length
>
0
)
{
tarObj
=
this
.
tarQueue
[
0
];
tarObj
=
this
.
tarQueue
[
0
];
}
else
{
}
else
{
console
.
log
(
"
Empty Queue!
"
);
console
.
log
(
"
Empty Queue!
"
);
...
@@ -321,16 +336,16 @@ export class AppsService {
...
@@ -321,16 +336,16 @@ export class AppsService {
this
.
isExtracting
=
true
;
this
.
isExtracting
=
true
;
console
.
log
(
"
Start tar
"
+
tarObj
.
id
);
console
.
log
(
"
Start tar
"
+
tarObj
.
id
);
let
downLoadsInfoIndex
=
this
.
downloadsInfo
.
findIndex
((
v
)
=>
{
return
v
.
id
==
tarObj
.
id
});
let
downLoadsInfoIndex
=
this
.
downloadsInfo
.
findIndex
((
v
)
=>
{
if
(
downLoadsInfoIndex
!==
-
1
)
{
return
v
.
id
==
tarObj
.
id
});
if
(
downLoadsInfoIndex
!==
-
1
)
{
this
.
downloadsInfo
[
downLoadsInfoIndex
].
status
=
"
install
"
;
this
.
downloadsInfo
[
downLoadsInfoIndex
].
status
=
"
install
"
;
}
else
{
}
else
{
console
.
log
(
"
cannot found download info!
"
);
console
.
log
(
"
cannot found download info!
"
);
}
}
let
xzFile
=
tarObj
.
xzFile
;
let
xzFile
=
tarObj
.
xzFile
;
let
installDir
=
this
.
path
.
join
(
tarObj
.
installDir
,
tarObj
.
id
);
let
installDir
=
this
.
path
.
join
(
tarObj
.
installDir
,
tarObj
.
id
);
if
(
!
this
.
fs
.
existsSync
(
installDir
))
{
if
(
!
this
.
fs
.
existsSync
(
installDir
))
{
...
@@ -344,20 +359,14 @@ export class AppsService {
...
@@ -344,20 +359,14 @@ export class AppsService {
});
});
}
}
let
tar
=
this
.
execFile
(
tarPath
,
[
'
xvf
'
,
xzFile
,
'
-C
'
,
installDir
],
opt
,
(
err
,
stdout
,
stderr
)
=>
{
let
tar
=
this
.
execFile
(
tarPath
,
[
'
xvf
'
,
xzFile
,
'
-C
'
,
installDir
],
opt
,
(
err
,
stdout
,
stderr
)
=>
{
if
(
err
)
{
if
(
err
)
{
throw
err
;
throw
err
;
}
}
let
re
=
/^x
\s(
.*
)
/
;
let
logArr
=
stderr
.
toString
().
trim
().
split
(
"
\n
"
)
let
logArr
=
stderr
.
toString
().
trim
().
split
(
this
.
os
.
EOL
);
.
map
((
log
,
index
,
array
)
=>
{
logArr
=
logArr
.
map
((
v
)
=>
{
return
log
.
split
(
"
"
,
2
)[
1
];
if
(
v
.
match
(
re
))
{
return
v
.
match
(
re
)[
1
];
}
else
{
console
.
log
(
"
no match
"
);
return
v
;
}
});
});
let
appLocal
=
{
let
appLocal
=
{
...
@@ -370,14 +379,14 @@ export class AppsService {
...
@@ -370,14 +379,14 @@ export class AppsService {
};
};
let
localAppData
=
JSON
.
parse
(
localStorage
.
getItem
(
"
localAppData
"
));
let
localAppData
=
JSON
.
parse
(
localStorage
.
getItem
(
"
localAppData
"
));
if
(
!
localAppData
||
!
Array
.
isArray
(
localAppData
))
{
if
(
!
localAppData
||
!
Array
.
isArray
(
localAppData
))
{
localAppData
=
[];
localAppData
=
[];
}
}
let
index
=
localAppData
.
findIndex
((
v
)
=>
{
let
index
=
localAppData
.
findIndex
((
v
)
=>
{
return
v
.
id
==
tarObj
.
id
;
return
v
.
id
==
tarObj
.
id
;
});
});
if
(
index
===
-
1
)
{
if
(
index
===
-
1
)
{
localAppData
.
push
(
appLocal
);
localAppData
.
push
(
appLocal
);
}
else
{
}
else
{
localAppData
[
index
]
=
appLocal
;
localAppData
[
index
]
=
appLocal
;
...
@@ -388,16 +397,16 @@ export class AppsService {
...
@@ -388,16 +397,16 @@ export class AppsService {
this
.
isExtracting
=
false
;
this
.
isExtracting
=
false
;
this
.
downloadsInfo
[
downLoadsInfoIndex
].
status
=
"
complete
"
;
this
.
downloadsInfo
[
downLoadsInfoIndex
].
status
=
"
complete
"
;
this
.
data
=
this
.
data
.
map
((
app
)
=>
{
this
.
data
=
this
.
data
.
map
((
app
)
=>
{
if
(
app
.
id
==
tarObj
.
id
)
{
if
(
app
.
id
==
tarObj
.
id
)
{
app
.
local
=
appLocal
.
local
;
app
.
local
=
appLocal
.
local
;
}
}
return
app
;
return
app
;
});
});
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
//[{"id": "th01", "wait":["wine", "dx"], resolve: resolve, tarObj: tarObj}]
this
.
waitInstallQueue
=
this
.
waitInstallQueue
.
map
((
waitObj
)
=>
{
this
.
waitInstallQueue
=
this
.
waitInstallQueue
.
map
((
waitObj
)
=>
{
waitObj
.
wait
.
splice
(
waitObj
.
wait
.
findIndex
(()
=>
tarObj
.
id
),
1
);
waitObj
.
wait
.
splice
(
waitObj
.
wait
.
findIndex
(()
=>
tarObj
.
id
),
1
);
if
(
waitObj
.
wait
.
length
<=
0
)
{
if
(
waitObj
.
wait
.
length
<=
0
)
{
waitObj
.
resolve
();
waitObj
.
resolve
();
console
.
log
(
tarObj
);
console
.
log
(
tarObj
);
return
;
return
;
...
@@ -405,8 +414,8 @@ export class AppsService {
...
@@ -405,8 +414,8 @@ export class AppsService {
return
waitObj
;
return
waitObj
;
}
}
});
});
this
.
waitInstallQueue
=
this
.
waitInstallQueue
.
filter
((
waitObj
)
=>
{
this
.
waitInstallQueue
=
this
.
waitInstallQueue
.
filter
((
waitObj
)
=>
{
if
(
waitObj
)
{
if
(
waitObj
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
i18n/zh-CN.json
View file @
3bdfcb80
{
{
"library"
:
"游戏"
,
"library"
:
"游戏"
,
"community"
:
"社区"
"community"
:
"社区"
,
"settings"
:
"设置"
,
"uninstall"
:
"卸载"
,
"general"
:
"常规"
,
"updates"
:
"更新"
,
"local files"
:
"本地文件"
}
}
index.js
View file @
3bdfcb80
...
@@ -94,7 +94,7 @@ function createAria2c() {
...
@@ -94,7 +94,7 @@ function createAria2c() {
let
aria2c
=
child_process
.
spawn
(
aria2c_path
,
[
'
--enable-rpc
'
,
'
--rpc-allow-origin-all
'
,
"
--continue
"
,
"
--split=10
"
,
"
--min-split-size=1M
"
,
"
--max-connection-per-server=10
"
]);
let
aria2c
=
child_process
.
spawn
(
aria2c_path
,
[
'
--enable-rpc
'
,
'
--rpc-allow-origin-all
'
,
"
--continue
"
,
"
--split=10
"
,
"
--min-split-size=1M
"
,
"
--max-connection-per-server=10
"
]);
aria2c
.
on
(
'
data
'
,
(
data
)
=>
{
aria2c
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
data
);
console
.
log
(
data
);
})
})
;
return
aria2c
;
return
aria2c
;
}
}
...
...
systemjs.config.js
View file @
3bdfcb80
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
'
angular2-in-memory-web-api
'
:
'
node_modules/angular2-in-memory-web-api
'
,
'
angular2-in-memory-web-api
'
:
'
node_modules/angular2-in-memory-web-api
'
,
'
rxjs
'
:
'
node_modules/rxjs
'
,
'
rxjs
'
:
'
node_modules/rxjs
'
,
'
ng2-translate
'
:
'
node_modules/ng2-translate/bundles/ng2-translate.js
'
,
'
ng2-translate
'
:
'
node_modules/ng2-translate/bundles/ng2-translate.js
'
,
"
os
"
:
''
};
};
// packages tells the System loader how to load when no filename and/or no extension
// packages tells the System loader how to load when no filename and/or no extension
var
packages
=
{
var
packages
=
{
...
...
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