Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
moecube
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
JoyJ
moecube
Commits
6d8cb676
Commit
6d8cb676
authored
Oct 27, 2016
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新解析apps.json
parent
cf931f9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
58 deletions
+53
-58
app/app-detail.component.ts
app/app-detail.component.ts
+4
-14
app/app.ts
app/app.ts
+4
-12
app/apps.service.ts
app/apps.service.ts
+45
-32
No files found.
app/app-detail.component.ts
View file @
6d8cb676
...
...
@@ -42,7 +42,9 @@ export class AppDetailComponent implements OnInit {
};
get
isInstalled
()
{
return
this
.
checkInstall
(
this
.
appsService
.
currentApp
.
id
);
let
currentApp
=
this
.
appsService
.
currentApp
;
return
!!
(
currentApp
.
local
&&
currentApp
.
local
.
path
);
}
...
...
@@ -93,17 +95,6 @@ export class AppDetailComponent implements OnInit {
}
}
checkInstall
(
id
):
boolean
{
if
(
this
.
appsService
.
searchApp
(
id
))
{
let
local
=
this
.
appsService
.
searchApp
(
id
).
local
;
if
(
local
&&
local
.
path
)
{
return
true
;
}
}
return
false
;
}
uninstalling
:
boolean
;
uninstall
(
id
:
string
)
{
...
...
@@ -141,8 +132,7 @@ export class AppDetailComponent implements OnInit {
let
open
=
''
;
let
openId
=
app
.
actions
[
process
.
platform
][
"
main
"
].
open
;
if
(
openId
)
{
//this.appsService.searchApp(openId).actions[process.platform]["main"].execute;
if
(
this
.
checkInstall
(
openId
))
{
if
(
this
.
isInstalled
)
{
open
=
this
.
path
.
join
(
this
.
appsService
.
searchApp
(
openId
).
local
.
path
,
this
.
appsService
.
searchApp
(
openId
).
actions
[
process
.
platform
][
"
main
"
].
execute
);
args
.
push
(
execute
);
}
else
{
...
...
app/app.ts
View file @
6d8cb676
...
...
@@ -29,7 +29,7 @@ export class App {
homepage
:
string
;
category
:
string
;
parent
:
App
;
actions
:
{[
platform
:
string
]:
{[
action
:
string
]:
{
execute
:
string
,
args
:
string
[],
env
:
{},
open
:
string
}
}};
actions
:
{[
action
:
string
]:
{
execute
:
string
,
args
:
string
[],
env
:
{},
open
:
App
}};
references
:
Map
<
string
,
App
>
;
dependencies
:
Map
<
string
,
App
>
;
locales
:
string
[];
...
...
@@ -39,7 +39,7 @@ export class App {
version
:
{[
platform
:
string
]:
string
};
local
:
AppLocal
;
constructor
(
app
:
AppInterface
)
{
constructor
(
app
)
{
this
.
id
=
app
.
id
;
this
.
name
=
app
.
name
;
this
.
description
=
app
.
description
;
...
...
@@ -47,6 +47,8 @@ export class App {
this
.
homepage
=
app
.
homepage
;
this
.
category
=
app
.
category
;
this
.
actions
=
app
.
actions
;
this
.
dependencies
=
app
.
dependencies
;
this
.
parent
=
app
.
parent
;
this
.
references
=
app
.
references
;
this
.
locales
=
app
.
locales
;
this
.
download
=
app
.
download
;
...
...
@@ -58,13 +60,3 @@ export class App {
}
export
interface
AppInterface
extends
App
{
}
/*export interface TestInterface {
id: string;
name: {[locale: string]: string};
}
let test: TestInterface = <TestInterface>{id: '1', name: {"x": "Guy"}};
console.log(test)*/
\ No newline at end of file
app/apps.service.ts
View file @
6d8cb676
import
{
Injectable
}
from
"
@angular/core
"
;
import
{
Http
}
from
"
@angular/http
"
;
import
"
rxjs/Rx
"
;
import
{
App
}
from
"
./app
"
;
import
{
TranslateService
}
from
"
ng2-translate
"
;
import
{
InstallConfig
}
from
"
./install-config
"
;
import
{
SettingsService
}
from
"
./settings.sevices
"
;
...
...
@@ -18,7 +16,6 @@ const execFile = window['System']._nodeRequire('child_process').execFile;
@
Injectable
()
export
class
AppsService
{
installConfig
:
InstallConfig
;
private
_currentApp
:
App
;
...
...
@@ -30,23 +27,8 @@ export class AppsService {
this
.
_currentApp
=
app
;
}
constructor
(
private
http
:
Http
,
private
translate
:
TranslateService
,
private
settingsService
:
SettingsService
)
{
let
loop
=
setInterval
(()
=>
{
this
.
aria2
.
tellActive
().
then
((
res
)
=>
{
if
(
res
)
{
res
.
map
((
v
)
=>
{
let
index
=
this
.
downloadsInfo
.
findIndex
((
info
)
=>
{
return
info
.
gid
==
v
.
gid
;
});
this
.
downloadsInfo
[
index
].
progress
=
(
v
.
completedLength
/
v
.
totalLength
)
*
100
;
});
}
})
},
1000
);
this
.
getApps
(()
=>
{
//console.log(appsService.data)
constructor
(
private
http
:
Http
,
private
settingsService
:
SettingsService
)
{
this
.
loadApps
(()
=>
{
if
(
this
.
data
.
size
>
0
)
{
this
.
currentApp
=
this
.
data
.
get
(
'
ygopro
'
);
}
...
...
@@ -182,7 +164,7 @@ export class AppsService {
return
dir
;
}
get
Apps
(
callback
)
{
load
Apps
(
callback
)
{
this
.
http
.
get
(
'
./apps.json
'
)
.
map
(
response
=>
{
let
apps
=
response
.
json
();
...
...
@@ -198,7 +180,7 @@ export class AppsService {
return
app
;
});
return
apps
;
}).
map
(
this
.
loadApps
)
}).
map
(
this
.
loadApps
List
)
.
subscribe
((
apps
)
=>
{
this
.
data
=
apps
;
if
(
typeof
(
callback
)
===
'
function
'
)
{
...
...
@@ -216,24 +198,55 @@ export class AppsService {
return
value
;
}
loadApps
=
(
data
:
any
):
Map
<
string
,
App
>
=>
{
let
result
=
new
Map
<
string
,
App
>
();
loadApps
List
=
(
data
:
any
):
Map
<
string
,
App
>
=>
{
let
apps
=
new
Map
<
string
,
App
>
();
let
locale
=
this
.
settingsService
.
getLocale
();
let
platform
=
process
.
platform
;
for
(
let
item
of
data
)
{
let
id
=
item
[
"
id
"
];
[
'
name
'
,
'
description
'
].
forEach
((
key
,
index
)
=>
{
let
value
=
item
[
key
][
locale
];
let
app
=
new
App
(
item
);
// 去除无关语言
[
'
name
'
,
'
description
'
].
forEach
((
key
)
=>
{
let
value
=
app
[
key
][
locale
];
if
(
!
value
)
{
value
=
item
[
key
][
"
en-US
"
];
value
=
app
[
key
][
"
en-US
"
];
}
item
[
key
]
=
value
;
app
[
key
]
=
value
;
});
let
app
=
new
App
(
item
);
result
.
set
(
id
,
app
);
// 去除平台无关的内容
[
'
actions
'
,
'
dependencies
'
,
'
references
'
,
'
download
'
].
forEach
((
key
)
=>
{
if
(
app
[
key
])
{
if
(
app
[
key
][
platform
])
{
app
[
key
]
=
app
[
key
][
platform
];
}
else
{
app
[
key
]
=
null
;
}
}
});
apps
.
set
(
item
.
id
,
app
);
}
for
(
let
id
of
Array
.
from
(
apps
.
keys
()))
{
[
'
dependencies
'
,
'
references
'
,
'
parent
'
].
forEach
((
key
)
=>
{
let
app
=
apps
.
get
(
id
);
let
value
=
app
[
key
];
if
(
value
)
{
if
(
Array
.
isArray
(
value
))
{
value
.
forEach
((
appId
,
index
,
array
)
=>
{
array
[
index
]
=
apps
.
get
(
appId
);
})
}
else
{
app
[
key
]
=
apps
.
get
(
value
);
}
}
});
}
return
result
;
return
apps
;
};
searchApp
(
id
):
App
{
...
...
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