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
a20ada6d
Commit
a20ada6d
authored
Dec 05, 2016
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自选路径
parent
14eeca64
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
2 deletions
+78
-2
app/app-detail.component.html
app/app-detail.component.html
+2
-1
app/app-detail.component.ts
app/app-detail.component.ts
+54
-1
app/settings.sevices.ts
app/settings.sevices.ts
+22
-0
No files found.
app/app-detail.component.html
View file @
a20ada6d
...
...
@@ -94,8 +94,9 @@
<p
i18n
>
即将开始安装 {{currentApp.name}}
</p>
<h4
i18n
>
安装位置
</h4>
<div
class=
"form-group"
>
<select
class=
"form-control"
name=
"installPath"
[(ngModel)]=
"installOption.installLibrary"
title=
"path"
>
<select
class=
"form-control"
name=
"installPath"
(change)=
"selectLibrary()"
[(ngModel)]=
"installOption.installLibrary"
title=
"path"
>
<option
*ngFor=
"let library of libraries"
value=
"{{library}}"
>
{{library}}
</option>
<option
*ngFor=
"let library of availableLibraries"
value=
"create_{{library}}"
>
在 {{library}}\ 盘新建 MyCard 库
</option>
</select></div>
<h4
i18n
>
快捷方式
</h4>
<div
class=
"checkbox"
>
...
...
app/app-detail.component.ts
View file @
a20ada6d
...
...
@@ -6,7 +6,9 @@ import {App} from "./app";
import
{
DownloadService
}
from
"
./download.service
"
;
import
{
clipboard
,
remote
}
from
"
electron
"
;
import
*
as
path
from
"
path
"
;
import
*
as
fs
from
'
fs
'
;
import
{
InstallService
}
from
"
./install.service
"
;
import
mkdirp
=
require
(
"
mkdirp
"
);
declare
const
Notification
:
any
;
declare
const
$
:
any
;
...
...
@@ -23,7 +25,7 @@ export class AppDetailComponent implements OnInit {
platform
=
process
.
platform
;
installOption
:
InstallOption
;
availableLibraries
:
string
[]
=
[];
references
:
App
[];
referencesInstall
:
{[
id
:
string
]:
boolean
};
...
...
@@ -32,7 +34,41 @@ export class AppDetailComponent implements OnInit {
private
ref
:
ChangeDetectorRef
)
{
}
// public File[] listRoots() {
// int ds = listRoots0();
// int n = 0;
// for (int i = 0; i < 26; i++) {
// if (((ds >> i) & 1) != 0) {
// if (!access((char)('A' + i) + ":" + slash))
// ds &= ~(1 << i);
// else
// n++;
// }
// }
// File[] fs = new File[n];
// int j = 0;
// char slash = this.slash;
// for (int i = 0; i < 26; i++) {
// if (((ds >> i) & 1) != 0)
// fs[j++] = new File((char)('A' + i) + ":" + slash);
// }
// return fs;
// }
ngOnInit
()
{
let
volume
=
'
A
'
;
for
(
let
i
=
0
;
i
<
26
;
i
++
)
{
new
Promise
((
resolve
,
reject
)
=>
{
let
currentVolume
=
String
.
fromCharCode
(
volume
.
charCodeAt
(
0
)
+
i
)
+
"
:
"
;
fs
.
access
(
currentVolume
,
(
err
)
=>
{
if
(
!
err
)
{
//判断是否已经存在Library
if
(
this
.
libraries
.
every
((
library
)
=>
!
library
.
startsWith
(
currentVolume
)))
{
this
.
availableLibraries
.
push
(
currentVolume
);
}
}
})
})
}
}
updateInstallOption
(
app
:
App
)
{
...
...
@@ -92,6 +128,23 @@ export class AppDetailComponent implements OnInit {
}
}
async
selectLibrary
()
{
if
(
this
.
installOption
.
installLibrary
.
startsWith
(
'
create_
'
))
{
let
volume
=
this
.
installOption
.
installLibrary
.
slice
(
7
);
let
library
=
path
.
join
(
volume
,
"
MyCardLibrary
"
);
try
{
await
this
.
installService
.
createDirectory
(
library
);
this
.
installOption
.
installLibrary
=
library
;
this
.
settingsService
.
addLibrary
(
library
,
true
);
}
catch
(
e
)
{
this
.
installOption
.
installLibrary
=
this
.
settingsService
.
getDefaultLibrary
().
path
;
alert
(
"
无法创建指定目录
"
);
}
}
else
{
this
.
settingsService
.
setDefaultLibrary
({
path
:
this
.
installOption
.
installLibrary
,
"
default
"
:
true
})
}
}
selectDir
()
{
let
dir
=
remote
.
dialog
.
showOpenDialog
({
properties
:
[
'
openFile
'
,
'
openDirectory
'
]});
console
.
log
(
dir
);
...
...
app/settings.sevices.ts
View file @
a20ada6d
...
...
@@ -36,6 +36,28 @@ export class SettingsService {
return
this
.
libraries
;
}
addLibrary
(
libraryPath
:
string
,
isDefault
:
boolean
)
{
let
libraries
=
this
.
getLibraries
();
if
(
isDefault
)
{
libraries
.
forEach
((
l
)
=>
{
l
.
default
=
false
;
});
}
libraries
.
push
({
"
default
"
:
isDefault
,
path
:
libraryPath
});
this
.
libraries
=
libraries
;
localStorage
.
setItem
(
SettingsService
.
SETTING_LIBRARY
,
JSON
.
stringify
(
libraries
));
}
setDefaultLibrary
(
library
:
Library
)
{
let
libraries
=
this
.
getLibraries
();
libraries
.
forEach
((
l
)
=>
{
l
.
default
=
library
.
path
==
l
.
path
;
});
this
.
libraries
=
libraries
;
localStorage
.
setItem
(
SettingsService
.
SETTING_LIBRARY
,
JSON
.
stringify
(
libraries
));
}
getDefaultLibrary
():
Library
{
if
(
!
this
.
libraries
)
{
this
.
getLibraries
()
...
...
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