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
e770e834
Commit
e770e834
authored
Oct 27, 2016
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network
parent
c1251714
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
12 deletions
+113
-12
app/app-detail.component.html
app/app-detail.component.html
+1
-1
app/apps.service.ts
app/apps.service.ts
+46
-8
apps.json
apps.json
+11
-1
index.js
index.js
+9
-1
maotama.js
maotama.js
+41
-0
package.json
package.json
+5
-1
No files found.
app/app-detail.component.html
View file @
e770e834
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<button
(click)=
"startApp(appsService.currentApp)"
type=
"button"
class=
"btn btn-primary"
>
运行
</button>
<button
(click)=
"startApp(appsService.currentApp)"
type=
"button"
class=
"btn btn-primary"
>
运行
</button>
<button
type=
"button"
data-toggle=
"modal"
data-target=
"#settings-modal"
class=
"btn btn-secondary"
>
设置
</button>
<button
type=
"button"
data-toggle=
"modal"
data-target=
"#settings-modal"
class=
"btn btn-secondary"
>
设置
</button>
<!--<button (click)="appsService.browse(appsService.currentApp)" type="button" class="btn btn-secondary">游览本地文件</button>-->
<!--<button (click)="appsService.browse(appsService.currentApp)" type="button" class="btn btn-secondary">游览本地文件</button>-->
<button
type=
"button"
class=
"btn btn-secondary"
>
联机
</button>
<button
type=
"button"
class=
"btn btn-secondary"
(click)=
"appsService.network(appsService.currentApp)"
>
联机
</button>
</div>
</div>
<ygopro
*ngIf=
"isInstalled && (appsService.currentApp.id == 'ygopro')"
></ygopro>
<ygopro
*ngIf=
"isInstalled && (appsService.currentApp.id == 'ygopro')"
></ygopro>
...
...
app/apps.service.ts
View file @
e770e834
...
@@ -7,13 +7,32 @@ import {InstallConfig} from "./install-config";
...
@@ -7,13 +7,32 @@ import {InstallConfig} from "./install-config";
import
{
SettingsService
}
from
"
./settings.sevices
"
;
import
{
SettingsService
}
from
"
./settings.sevices
"
;
declare
var
process
;
declare
var
process
;
const
os
=
window
[
'
System
'
].
_nodeRequire
(
'
os
'
);
declare
var
System
;
const
fs
=
window
[
'
System
'
].
_nodeRequire
(
'
fs
'
);
const
os
=
System
.
_nodeRequire
(
'
os
'
);
const
path
=
window
[
'
System
'
].
_nodeRequire
(
'
path
'
);
const
fs
=
System
.
_nodeRequire
(
'
fs
'
);
const
mkdirp
=
window
[
'
System
'
].
_nodeRequire
(
'
mkdirp
'
);
const
path
=
System
.
_nodeRequire
(
'
path
'
);
const
electron
=
window
[
'
System
'
].
_nodeRequire
(
'
electron
'
);
const
readline
=
System
.
_nodeRequire
(
'
readline
'
);
const
Aria2
=
window
[
'
System
'
].
_nodeRequire
(
'
aria2
'
);
const
mkdirp
=
System
.
_nodeRequire
(
'
mkdirp
'
);
const
execFile
=
window
[
'
System
'
].
_nodeRequire
(
'
child_process
'
).
execFile
;
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
)
=>
{
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
})
};
//const sudo = System._nodeRequire('sudo-prompt');
@
Injectable
()
@
Injectable
()
export
class
AppsService
{
export
class
AppsService
{
...
@@ -476,4 +495,23 @@ export class AppsService {
...
@@ -476,4 +495,23 @@ export class AppsService {
browse
(
app
:
App
)
{
browse
(
app
:
App
)
{
electron
.
remote
.
shell
.
showItemInFolder
(
app
.
local
.
path
);
electron
.
remote
.
shell
.
showItemInFolder
(
app
.
local
.
path
);
}
}
}
/*child.on('exit', reject);
let rl = readline.createInterface({
input: child.stdout,
output: child.stdin
});
rl.on('line', (input) => {
resolve();
console.log(`Received: ${input}`);
});*/
network
(
app
:
App
)
{
sudo
.
fork
(
'
maotama
'
).
then
((
child
)
=>
{
//new WebSocket()
setInterval
(()
=>
{
child
.
send
({
action
:
'
connect
'
,
arguments
:
[
10800
,
10900
,
'
112.124.105.11
'
]})
},
200
);
});
}
}
\ No newline at end of file
apps.json
View file @
e770e834
...
@@ -1377,7 +1377,17 @@
...
@@ -1377,7 +1377,17 @@
"win32"
:
"http://thief.mycard.moe/metalinks/th123.meta4"
,
"win32"
:
"http://thief.mycard.moe/metalinks/th123.meta4"
,
"darwin"
:
"http://thief.mycard.moe/metalinks/th123.meta4"
"darwin"
:
"http://thief.mycard.moe/metalinks/th123.meta4"
},
},
"news"
:
[]
"news"
:
[],
"network"
:
{
"protocol"
:
"maotama"
,
"port"
:
10800
,
"servers"
:
[
{
"id"
:
"tiramisu"
,
"url"
:
"wss://tiramisu.mycard.moe:10800"
}
]
}
},
},
{
{
"id"
:
"th123-lang-zh-CN"
,
"id"
:
"th123-lang-zh-CN"
,
...
...
index.js
View file @
e770e834
...
@@ -10,7 +10,7 @@ const child_process = require('child_process');
...
@@ -10,7 +10,7 @@ const child_process = require('child_process');
const
path
=
require
(
'
path
'
);
const
path
=
require
(
'
path
'
);
// this should be placed at top of main.js to handle setup events quickly
// this should be placed at top of main.js to handle setup events quickly
if
(
handleSquirrelEvent
())
{
if
(
handleSquirrelEvent
()
||
handleElevate
()
)
{
// squirrel event handled and app will exit in 1000ms, so don't do anything else
// squirrel event handled and app will exit in 1000ms, so don't do anything else
return
;
return
;
}
}
...
@@ -78,6 +78,14 @@ function handleSquirrelEvent() {
...
@@ -78,6 +78,14 @@ function handleSquirrelEvent() {
}
}
};
};
function
handleElevate
()
{
if
(
process
.
argv
[
1
]
==
'
-e
'
)
{
app
.
dock
.
hide
();
require
(
"
./
"
+
process
.
argv
[
2
]);
return
true
;
}
}
function
createAria2c
()
{
function
createAria2c
()
{
let
aria2c_path
;
let
aria2c_path
;
switch
(
process
.
platform
)
{
switch
(
process
.
platform
)
{
...
...
maotama.js
0 → 100644
View file @
e770e834
const
os
=
require
(
'
os
'
);
const
readline
=
require
(
'
readline
'
);
process
.
send
=
(
message
,
sendHandle
,
options
,
callback
)
=>
{
process
.
stdout
.
write
(
JSON
.
stringify
(
message
)
+
os
.
EOL
);
if
(
callback
)
{
callback
()
}
};
process
.
stdin
.
on
(
'
end
'
,
()
=>
{
process
.
emit
(
'
disconnect
'
)
});
readline
.
createInterface
({
input
:
process
.
stdin
}).
on
(
'
line
'
,
(
line
)
=>
{
process
.
emit
(
'
message
'
,
JSON
.
parse
(
line
))
});
const
raw
=
require
(
"
raw-socket
"
);
let
socket
=
raw
.
createSocket
({
protocol
:
raw
.
Protocol
.
UDP
});
let
connect
=
(
local_port
,
remote_port
,
remote_address
)
=>
{
let
buffer
=
new
Buffer
(
9
);
buffer
.
writeUInt16BE
(
local_port
,
0
);
buffer
.
writeUInt16BE
(
remote_port
,
2
);
buffer
.
writeUInt16BE
(
buffer
.
length
,
4
);
socket
.
send
(
buffer
,
0
,
buffer
.
length
,
remote_address
,
(
error
,
bytes
)
=>
{
if
(
error
)
{
throw
(
error
);
}
})
};
let
handler
=
{
connect
:
connect
};
process
.
on
(
'
message
'
,
(
message
)
=>
{
handler
[
message
.
action
](...
message
.
arguments
);
});
process
.
on
(
'
disconnect
'
,
process
.
exit
);
\ No newline at end of file
package.json
View file @
e770e834
...
@@ -30,11 +30,14 @@
...
@@ -30,11 +30,14 @@
"
@angular/upgrade
"
:
"
latest
"
,
"
@angular/upgrade
"
:
"
latest
"
,
"
angular2-in-memory-web-api
"
:
"
latest
"
,
"
angular2-in-memory-web-api
"
:
"
latest
"
,
"
aria2
"
:
"
latest
"
,
"
aria2
"
:
"
latest
"
,
"
bluebird
"
:
"
^3.4.6
"
,
"
bootstrap
"
:
"
next
"
,
"
bootstrap
"
:
"
next
"
,
"
core-js
"
:
"
latest
"
,
"
core-js
"
:
"
latest
"
,
"
electron-sudo
"
:
"
latest
"
,
"
font-awesome
"
:
"
latest
"
,
"
font-awesome
"
:
"
latest
"
,
"
ini
"
:
"
latest
"
,
"
mkdirp
"
:
"
latest
"
,
"
ng2-translate
"
:
"
latest
"
,
"
ng2-translate
"
:
"
latest
"
,
"
raw-socket
"
:
"
^1.5.0
"
,
"
reflect-metadata
"
:
"
latest
"
,
"
reflect-metadata
"
:
"
latest
"
,
"
rxjs
"
:
"
5.0.0-beta.12
"
,
"
rxjs
"
:
"
5.0.0-beta.12
"
,
"
systemjs
"
:
"
latest
"
,
"
systemjs
"
:
"
latest
"
,
...
@@ -45,6 +48,7 @@
...
@@ -45,6 +48,7 @@
"
concurrently
"
:
"
latest
"
,
"
concurrently
"
:
"
latest
"
,
"
electron
"
:
"
latest
"
,
"
electron
"
:
"
latest
"
,
"
electron-builder
"
:
"
latest
"
,
"
electron-builder
"
:
"
latest
"
,
"
electron-rebuild
"
:
"
^1.3.0
"
,
"
lite-server
"
:
"
latest
"
,
"
lite-server
"
:
"
latest
"
,
"
typescript
"
:
"
latest
"
,
"
typescript
"
:
"
latest
"
,
"
typings
"
:
"
latest
"
"
typings
"
:
"
latest
"
...
...
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