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
xiaoye
mycard
Commits
48dfb3ba
Commit
48dfb3ba
authored
Oct 21, 2016
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Plain Diff
合并版本
parents
ad3c9453
07b9e520
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
363 additions
and
472 deletions
+363
-472
app/app-detail.component.css
app/app-detail.component.css
+3
-0
app/app-detail.component.html
app/app-detail.component.html
+33
-9
app/apps.service.ts
app/apps.service.ts
+8
-11
app/ygopro.component.html
app/ygopro.component.html
+165
-5
app/ygopro.component.ts
app/ygopro.component.ts
+116
-8
apps.json
apps.json
+38
-439
No files found.
app/app-detail.component.css
View file @
48dfb3ba
...
...
@@ -20,3 +20,6 @@ progress {
margin-top
:
2px
;
}
.carousel-inner
img
{
width
:
100%
;
}
\ No newline at end of file
app/app-detail.component.html
View file @
48dfb3ba
...
...
@@ -4,7 +4,7 @@
<div
*ngIf=
"!appsService.getDownloadInfo(routingService.app)"
>
<button
type=
"button"
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
>
<
!--<button type="button" class="btn btn-secondary">正版代购</button>--
>
</div>
<div
*ngIf=
"appsService.getDownloadInfo(routingService.app)"
>
<div
*ngIf=
"appsService.getDownloadInfo(routingService.app).status === 'install'"
>
正在安装...
</div>
...
...
@@ -18,23 +18,45 @@
<div
*ngIf=
"isInstalled && (routingService.app != 'ygopro')"
>
<button
(click)=
"startApp(routingService.app)"
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(routingService.app)"
type=
"button"
class=
"btn btn-secondary"
>
游览本地文件
</button
>
<
!--<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">游览本地文件</button>--
>
<button
type=
"button"
class=
"btn btn-secondary"
>
联机
</button>
</div>
<ygopro
*ngIf=
"isInstalled && (routingService.app == 'ygopro')"
></ygopro>
<br>
<h2>
新闻
</h2>
<h2
*ngIf=
"news"
>
新闻
</h2>
<p
*ngIf=
"!news"
>
没有新闻
</p>
<div
*ngIf=
"news"
>
<!--<div *ngIf="news">
<div class="list-group">
<a *ngFor="let item of news" href="{{item.url}}" class="list-group-item">{{item.title}}</a>
</div>
</div>-->
<div
id=
"carousel-example-generic"
class=
"carousel slide"
data-ride=
"carousel"
>
<ol
class=
"carousel-indicators"
>
<li
*ngFor=
"let item of news; let index = index;"
data-target=
"#carousel-example-generic"
[data-slide-to]=
"index"
[class.active]=
"index == 0"
></li>
</ol>
<div
class=
"carousel-inner"
role=
"listbox"
>
<div
*ngFor=
"let item of news; let index = index;"
class=
"carousel-item"
[class.active]=
"index == 0"
>
<img
[src]=
"item.image"
[alt]=
"item.title"
>
<div
class=
"carousel-caption"
>
<h3>
{{item.title}}
</h3>
<p>
{{item.text}}
</p>
</div>
</div>
</div>
<a
class=
"left carousel-control"
href=
"#carousel-example-generic"
role=
"button"
data-slide=
"prev"
>
<span
class=
"icon-prev"
aria-hidden=
"true"
></span>
<span
class=
"sr-only"
>
Previous
</span>
</a>
<a
class=
"right carousel-control"
href=
"#carousel-example-generic"
role=
"button"
data-slide=
"next"
>
<span
class=
"icon-next"
aria-hidden=
"true"
></span>
<span
class=
"sr-only"
>
Next
</span>
</a>
</div>
<br>
<div
*ngIf=
"friends"
>
...
...
@@ -88,7 +110,12 @@
</table>
</div>
<button
(click)=
"appsService.doTar()"
>
DOTAR
</button>
<div
*ngIf=
"isInstalled"
>
<h2>
本地文件
</h2>
<button
(click)=
"appsService.browse(routingService.app)"
type=
"button"
class=
"btn btn-secondary"
>
浏览本地文件
</button>
<button
(click)=
"uninstall()"
type=
"button"
class=
"btn btn-secondary"
>
{{'uninstall'|translate}}
</button>
</div>
<div
class=
"modal fade"
id=
"settings-modal"
tabindex=
"-1"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
...
...
@@ -191,10 +218,7 @@
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
取消
</button>
<button
id=
"submit"
type=
"submit"
[disabled]=
"!theForm.form.valid"
class=
"btn btn-primary"
>
安装
</button>
</div>
<!--
-->
</form>
</div>
</div>
...
...
app/apps.service.ts
View file @
48dfb3ba
...
...
@@ -229,18 +229,15 @@ export class AppsService {
deleteFile
(
path
:
string
):
Promise
<
string
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
lstat
(
path
,
(
err
,
stats
)
=>
{
if
(
!
err
)
{
if
(
stats
.
isDirectory
())
{
fs
.
rmdir
(
path
,
(
err
)
=>
{
resolve
(
path
);
});
}
else
{
fs
.
unlink
(
path
,
(
err
)
=>
{
resolve
(
path
);
});
}
if
(
err
)
return
resolve
(
path
);
if
(
stats
.
isDirectory
())
{
fs
.
rmdir
(
path
,
(
err
)
=>
{
resolve
(
path
);
});
}
else
{
resolve
(
path
);
fs
.
unlink
(
path
,
(
err
)
=>
{
resolve
(
path
);
});
}
});
})
...
...
app/ygopro.component.html
View file @
48dfb3ba
This diff is collapsed.
Click to expand it.
app/ygopro.component.ts
View file @
48dfb3ba
...
...
@@ -5,13 +5,14 @@ import {Component} from '@angular/core';
import
{
AppsService
}
from
"
./apps.service
"
;
import
{
RoutingService
}
from
"
./routing.service
"
;
declare
var
process
;
declare
var
System
;
const
fs
=
System
.
_nodeRequire
(
'
fs
'
);
const
path
=
System
.
_nodeRequire
(
'
path
'
);
const
Promise
=
System
.
_nodeRequire
(
'
bluebird
'
);
Promise
.
resolve
(
"
foo
"
).
then
(
function
(
msg
)
{
console
.
log
(
msg
)
}
);
const
child_process
=
System
.
_nodeRequire
(
'
child_process
'
);
//const Promise = System._nodeRequire('bluebird');
const
ini
=
System
.
_nodeRequire
(
'
ini
'
);
const
electron
=
System
.
_nodeRequire
(
'
electron
'
);
@
Component
({
selector
:
'
ygopro
'
,
...
...
@@ -21,16 +22,28 @@ Promise.resolve("foo").then(function (msg) {
export
class
YGOProComponent
{
app
=
this
.
appsService
.
searchApp
(
'
ygopro
'
);
decks
=
[];
current_deck
;
system_conf
=
path
.
join
(
this
.
app
.
local
.
path
,
'
system.conf
'
);
numfont
=
{
'
darwin
'
:
[
'
/System/Library/Fonts/PingFang.ttc
'
]};
textfont
=
{
'
darwin
'
:
[
'
/System/Library/Fonts/PingFang.ttc
'
]};
windbot
=
[
"
琪露诺
"
,
"
谜之剑士LV4
"
,
"
复制植物
"
,
"
尼亚
"
];
servers
=
[{
address
:
"
112.124.105.11
"
,
port
:
7911
}];
constructor
(
private
appsService
:
AppsService
,
private
routingService
:
RoutingService
)
{
this
.
refresh
()
}
refresh
()
{
refresh
=
()
=>
{
this
.
get_decks
().
then
((
decks
)
=>
{
this
.
decks
=
decks
;
if
(
!
(
this
.
current_deck
in
this
.
decks
))
{
this
.
current_deck
=
decks
[
0
];
}
})
}
}
;
get_decks
():
Promise
<
[
string
]
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -38,10 +51,105 @@ export class YGOProComponent {
if
(
error
)
{
reject
(
error
)
}
else
{
let
result
:
string
[]
=
files
.
filter
(
file
=>
path
.
extname
(
file
)
==
"
.ydk
"
).
map
(
file
=>
path
.
basename
(
file
,
'
.ydk
'
));
resolve
(
result
);
resolve
(
files
.
filter
(
file
=>
path
.
extname
(
file
)
==
"
.ydk
"
).
map
(
file
=>
path
.
basename
(
file
,
'
.ydk
'
)));
}
})
})
}
get_font
(
files
:
string
[])
{
return
new
Promise
((
resolve
,
reject
)
=>
{
files
.
reduce
((
promise
,
file
:
string
)
=>
{
return
promise
.
then
(()
=>
file
).
then
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
access
(
file
,
fs
.
constants
.
R_OK
,
(
error
)
=>
{
error
?
resolve
(
`can't find fonts
${
files
[
process
.
platform
]}
`
)
:
reject
(
file
)
});
}));
},
Promise
.
resolve
()).
then
(
reject
,
resolve
);
})
}
edit_deck
(
deck
)
{
this
.
load_system_conf
()
.
then
(
this
.
fix_fonts
)
.
then
(
data
=>
{
data
[
'
lastdeck
'
]
=
deck
;
return
data
})
.
then
(
this
.
save_system_conf
)
.
then
(()
=>
[
'
-d
'
])
.
then
(
this
.
start_game
)
.
catch
(
reason
=>
console
.
log
(
reason
))
}
delete_deck
(
deck
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
unlink
(
path
.
join
(
this
.
app
.
local
.
path
,
'
deck
'
,
deck
+
'
.ydk
'
),
resolve
)
}).
then
(
this
.
refresh
)
}
fix_fonts
=
(
data
)
=>
{
return
this
.
get_font
([
data
.
numfont
])
.
catch
(()
=>
this
.
get_font
(
this
.
numfont
[
process
.
platform
]).
then
(
font
=>
data
[
'
numfont
'
]
=
font
))
.
catch
()
.
then
(()
=>
this
.
get_font
([
data
.
textfont
.
split
(
'
'
,
2
)[
0
]]))
.
catch
(()
=>
this
.
get_font
(
this
.
textfont
[
process
.
platform
]).
then
(
font
=>
data
[
'
textfont
'
]
=
`
${
font
}
14`
))
.
catch
()
.
then
(()
=>
data
)
};
load_system_conf
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
readFile
(
this
.
system_conf
,
{
encoding
:
'
utf-8
'
},
(
error
,
data
)
=>
{
if
(
error
)
return
reject
(
error
);
resolve
(
ini
.
parse
(
data
));
});
})
};
save_system_conf
=
(
data
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
writeFile
(
this
.
system_conf
,
ini
.
stringify
(
data
,
{
whitespace
:
true
}),
(
error
)
=>
{
if
(
error
)
return
reject
(
error
);
resolve
(
data
);
});
})
};
join
(
name
,
server
)
{
this
.
load_system_conf
()
.
then
(
this
.
fix_fonts
)
.
then
(
data
=>
{
data
[
'
lastdeck
'
]
=
this
.
current_deck
;
data
[
'
lastip
'
]
=
server
.
address
;
data
[
'
lastport
'
]
=
server
.
port
;
data
[
'
roompass
'
]
=
name
;
return
data
})
.
then
(
this
.
save_system_conf
)
.
then
(()
=>
[
'
-j
'
])
.
then
(
this
.
start_game
)
.
catch
(
reason
=>
console
.
log
(
reason
))
};
join_windbot
(
name
)
{
this
.
join
(
name
,
this
.
servers
[
0
])
}
start_game
=
(
args
)
=>
{
let
win
=
electron
.
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
});
child
.
on
(
'
error
'
,
(
error
)
=>
{
reject
(
error
);
win
.
restore
()
});
child
.
on
(
'
exit
'
,
(
code
,
signal
)
=>
{
// error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。
resolve
(
code
);
win
.
restore
()
})
})
};
}
apps.json
View file @
48dfb3ba
This diff is collapsed.
Click to expand it.
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