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
4498e177
Commit
4498e177
authored
Nov 05, 2016
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
运行和卸载mod
parent
6a4f6518
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
112 deletions
+108
-112
app/app-detail.component.html
app/app-detail.component.html
+4
-3
app/app-detail.component.ts
app/app-detail.component.ts
+5
-58
app/app.ts
app/app.ts
+1
-1
app/apps.service.ts
app/apps.service.ts
+44
-44
app/install.service.ts
app/install.service.ts
+54
-6
No files found.
app/app-detail.component.html
View file @
4498e177
...
...
@@ -12,7 +12,7 @@
class=
"progress progress-striped progress-animated"
value=
"{{currentApp.status.progress}}"
max=
"{{currentApp.status.total}}"
></progress>
<div
*ngIf=
"currentApp.status.status==='ready' && (currentApp.id != 'ygopro')"
>
<button
(click)=
"
start
App(currentApp)"
type=
"button"
class=
"btn btn-primary"
>
运行
</button>
<button
(click)=
"
run
App(currentApp)"
type=
"button"
class=
"btn btn-primary"
>
运行
</button>
<button
type=
"button"
data-toggle=
"modal"
data-target=
"#settings-modal"
class=
"btn btn-secondary"
>
设置
</button>
<!--<button (click)="appsService.browse(currentApp)" type="button" class="btn btn-secondary">游览本地文件</button>-->
...
...
@@ -114,7 +114,7 @@
<div
*ngIf=
"currentApp.isInstalled()"
>
<h2>
本地文件
</h2>
<button
(click)=
"appsService.browse(currentApp)"
type=
"button"
class=
"btn btn-secondary"
>
浏览本地文件
</button>
<button
(click)=
"uninstall(currentApp
.id
)"
type=
"button"
class=
"btn btn-secondary"
>
<button
(click)=
"uninstall(currentApp)"
type=
"button"
class=
"btn btn-secondary"
>
{{'uninstall'|translate}}
</button>
</div>
...
...
@@ -202,7 +202,8 @@
<h4>
{{'additions'|translate}}
</h4>
<div
*ngFor=
"let reference of installConfig.references"
>
<label>
<input
type=
"checkbox"
[(ngModel)]=
"reference.install"
name=
"references"
value=
"{{reference.app.id}}"
>
<input
type=
"checkbox"
[(ngModel)]=
"reference.install"
name=
"references"
value=
"{{reference.app.id}}"
>
{{reference.app.name}}
</label>
</div>
...
...
app/app-detail.component.ts
View file @
4498e177
...
...
@@ -30,11 +30,6 @@ export class AppDetailComponent implements OnInit {
}
ngOnInit
()
{
// this.updateInstallConfig();
ipcRenderer
.
on
(
'
download-message-reply
'
,
(
event
,
arg
)
=>
{
console
.
log
(
arg
);
});
ipcRenderer
.
send
(
"
download-message
"
,
"
ping
"
)
}
updateInstallConfig
()
{
...
...
@@ -54,14 +49,6 @@ export class AppDetailComponent implements OnInit {
return
this
.
currentApp
.
news
;
}
get
friends
()
{
return
false
;
}
get
achievement
()
{
return
false
;
}
get
mods
()
{
// let contains = ["optional", "language", "emulator"];
//
...
...
@@ -95,15 +82,11 @@ export class AppDetailComponent implements OnInit {
return
[];
}
uninstalling
:
boolean
;
uninstall
(
id
:
string
)
{
async
uninstall
(
app
:
App
)
{
if
(
confirm
(
"
确认删除?
"
))
{
this
.
uninstalling
=
true
;
// this.appsService.uninstall(id).then(()=> {
// this.uninstalling = false;
// }
// );
await
this
.
installService
.
uninstall
(
app
);
this
.
currentApp
.
status
.
status
=
"
init
"
;
}
}
...
...
@@ -148,9 +131,7 @@ export class AppDetailComponent implements OnInit {
return
this
.
installService
.
add
(
completeApp
,
options
);
});
}));
console
.
log
(
"
before
"
)
await
this
.
installService
.
getComplete
(
currentApp
);
console
.
log
(
"
install complete
"
);
currentApp
.
status
.
status
=
"
ready
"
;
this
.
ref
.
detectChanges
();
}
catch
(
e
)
{
...
...
@@ -167,42 +148,8 @@ export class AppDetailComponent implements OnInit {
return
dir
[
0
];
}
startApp
(
app
:
App
)
{
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
=
{
cwd
:
app
.
local
.
path
,
env
:
env
};
let
open
=
''
;
let
openApp
=
app
.
actions
.
get
(
"
main
"
).
open
;
if
(
openApp
)
{
open
=
path
.
join
(
openApp
.
local
.
path
,
openApp
.
actions
.
get
(
"
main
"
).
execute
);
args
.
push
(
execute
);
}
else
{
//没有需要通过open启动依赖,直接启动程序
open
=
execute
;
}
let
handle
=
child_process
.
spawn
(
open
,
args
,
opt
);
handle
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
});
handle
.
stderr
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stderr:
${
data
}
`
);
});
handle
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
remote
.
getCurrentWindow
().
restore
();
});
remote
.
getCurrentWindow
().
minimize
();
runApp
(
app
:
App
)
{
this
.
appsService
.
runApp
(
app
);
}
copy
(
text
)
{
...
...
app/app.ts
View file @
4498e177
...
...
@@ -55,7 +55,7 @@ export class App {
status
:
AppStatus
;
isInstalled
():
boolean
{
return
this
.
local
!==
undefined
;
return
!!
this
.
local
;
}
constructor
(
app
)
{
...
...
app/apps.service.ts
View file @
4498e177
...
...
@@ -35,6 +35,8 @@ Sudo.prototype.fork = function (modulePath, args, options) {
@
Injectable
()
export
class
AppsService
{
private
apps
:
Map
<
string
,
App
>
;
constructor
(
private
http
:
Http
,
private
settingsService
:
SettingsService
,
private
ref
:
ApplicationRef
,)
{
}
...
...
@@ -44,7 +46,8 @@ export class AppsService {
.
toPromise
()
.
then
((
response
)
=>
{
let
data
=
response
.
json
();
return
this
.
loadAppsList
(
data
);
this
.
apps
=
this
.
loadAppsList
(
data
);
return
this
.
apps
;
});
}
...
...
@@ -123,55 +126,52 @@ export class AppsService {
return
apps
;
};
deleteFile
(
path
:
string
):
Promise
<
string
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
lstat
(
path
,
(
err
,
stats
)
=>
{
if
(
err
)
return
resolve
(
path
);
if
(
stats
.
isDirectory
())
{
fs
.
rmdir
(
path
,
(
err
)
=>
{
resolve
(
path
);
});
}
else
{
fs
.
unlink
(
path
,
(
err
)
=>
{
resolve
(
path
);
});
}
});
})
findChildren
(
app
:
App
):
App
[]
{
let
children
=
[];
for
(
let
child
of
this
.
apps
.
values
())
{
if
(
child
.
parent
===
app
)
{
children
.
push
(
child
);
}
}
return
children
;
}
saveAppLocal
(
app
:
App
,
appLocal
:
AppLocal
)
{
localStorage
.
setItem
(
app
.
id
,
JSON
.
stringify
(
appLocal
));
}
runApp
(
app
:
App
)
{
let
children
=
this
.
findChildren
(
app
);
let
cwd
=
app
.
local
.
path
;
let
action
=
app
.
actions
.
get
(
'
main
'
);
let
args
=
[];
let
env
=
{};
for
(
let
child
of
children
)
{
action
=
child
.
actions
.
get
(
'
main
'
);
}
let
execute
=
path
.
join
(
cwd
,
action
.
execute
);
if
(
action
.
open
)
{
let
openAction
=
action
.
open
.
actions
.
get
(
'
main
'
);
args
=
args
.
concat
(
openAction
.
args
);
args
.
push
(
action
.
execute
);
execute
=
path
.
join
(
action
.
open
.
local
.
path
,
openAction
.
execute
);
env
=
Object
.
assign
(
env
,
openAction
.
env
);
}
args
=
args
.
concat
(
action
.
args
);
env
=
Object
.
assign
(
env
,
action
.
env
);
let
handle
=
child_process
.
spawn
(
execute
,
args
,
{
env
:
env
,
cwd
:
cwd
});
install
(
config
:
InstallConfig
)
{
let
app
=
config
.
app
;
}
handle
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
)
;
});
uninstall
(
id
:
string
)
{
// //let current = this;
// if (this.checkInstall(id)) {
// let files: string[] = this.searchApp(id).local.files.sort().reverse();
// // 删除本目录
// files.push('.');
// let install_dir = this.searchApp(id).local.path;
// return files
// .map((file)=>
// ()=>path.join(install_dir, file)
// )
// .reduce((promise: Promise<string>, task)=>
// promise.then(task).then(this.deleteFile)
// , Promise.resolve(''))
// .then((value)=> {
// this.searchApp(id).local = null;
// localStorage.setItem("localAppData", JSON.stringify(this.data));
// return Promise.resolve()
// });
// }
handle
.
stderr
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stderr:
${
data
}
`
);
});
}
handle
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
remote
.
getCurrentWindow
().
restore
();
});
remote
.
getCurrentWindow
().
minimize
();
}
browse
(
app
:
App
)
{
remote
.
shell
.
showItemInFolder
(
app
.
local
.
path
);
...
...
app/install.service.ts
View file @
4498e177
...
...
@@ -14,6 +14,7 @@ import {EventEmitter} from "events";
import
{
AppLocal
}
from
"
./app-local
"
;
import
{
Http
}
from
"
@angular/http
"
;
import
ReadableStream
=
NodeJS
.
ReadableStream
;
import
{
AppsService
}
from
"
./apps.service
"
;
@
Injectable
()
export
class
InstallService
{
...
...
@@ -25,7 +26,7 @@ export class InstallService {
checksumUri
=
"
http://thief.mycard.moe/checksums/
"
;
constructor
(
private
http
:
Http
)
{
constructor
(
private
http
:
Http
,
private
appsService
:
AppsService
)
{
if
(
process
.
platform
===
"
win32
"
)
{
this
.
tarPath
=
path
.
join
(
process
.
resourcesPath
,
'
bin/tar.exe
'
);
}
else
{
...
...
@@ -43,7 +44,6 @@ export class InstallService {
getComplete
(
app
:
App
):
Promise
<
App
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
eventEmitter
.
once
(
app
.
id
,
(
complete
)
=>
{
console
.
log
(
"
receive
"
,
app
.
id
);
resolve
();
});
});
...
...
@@ -103,9 +103,7 @@ export class InstallService {
saveAppLocal
(
app
:
App
)
{
if
(
app
.
local
)
{
let
a
=
JSON
.
stringify
(
app
.
local
)
console
.
log
(
a
);
localStorage
.
setItem
(
app
.
id
,
a
);
localStorage
.
setItem
(
app
.
id
,
JSON
.
stringify
(
app
.
local
));
}
}
...
...
@@ -164,7 +162,6 @@ export class InstallService {
local
.
version
=
app
.
version
;
app
.
local
=
local
;
this
.
saveAppLocal
(
app
);
console
.
log
(
"
send
"
,
app
.
id
);
this
.
eventEmitter
.
emit
(
app
.
id
,
'
install complete
'
);
this
.
installQueue
.
delete
(
app
);
this
.
installingQueue
.
delete
(
app
);
...
...
@@ -184,4 +181,55 @@ export class InstallService {
}
}
deleteFile
(
file
:
string
):
Promise
<
string
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
lstat
(
file
,
(
err
,
stats
)
=>
{
if
(
err
)
return
resolve
(
path
);
if
(
stats
.
isDirectory
())
{
fs
.
rmdir
(
file
,
(
err
)
=>
{
resolve
(
file
);
});
}
else
{
fs
.
unlink
(
file
,
(
err
)
=>
{
resolve
(
file
);
});
}
});
})
}
async
uninstall
(
app
:
App
)
{
if
(
!
app
.
parent
)
{
let
children
=
this
.
appsService
.
findChildren
(
app
);
for
(
let
child
of
children
)
{
if
(
child
.
isInstalled
())
{
await
this
.
uninstall
(
child
);
}
}
}
let
files
=
Array
.
from
(
app
.
local
.
files
.
keys
()).
sort
().
reverse
();
console
.
log
(
files
);
for
(
let
file
of
files
)
{
let
oldFile
=
file
;
if
(
!
path
.
isAbsolute
(
file
))
{
oldFile
=
path
.
join
(
app
.
local
.
path
,
file
);
}
await
this
.
deleteFile
(
oldFile
);
if
(
app
.
parent
)
{
let
backFile
=
path
.
join
(
app
.
local
.
path
,
"
backup
"
,
file
);
await
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
rename
(
backFile
,
oldFile
,
resolve
);
});
}
}
if
(
app
.
parent
)
{
await
this
.
deleteFile
(
path
.
join
(
app
.
local
.
path
,
"
backup
"
));
}
else
{
await
this
.
deleteFile
(
app
.
local
.
path
);
}
app
.
local
=
null
;
localStorage
.
removeItem
(
app
.
id
);
}
}
\ No newline at end of file
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