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
46875bb7
Commit
46875bb7
authored
Jan 28, 2016
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logout
parent
8c4a26b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
33 deletions
+62
-33
apps.js
apps.js
+23
-10
css/style.css
css/style.css
+1
-1
index.html
index.html
+4
-3
js/app.js
js/app.js
+34
-19
No files found.
apps.js
View file @
46875bb7
...
@@ -12,6 +12,7 @@ const EventEmitter = require('events');
...
@@ -12,6 +12,7 @@ const EventEmitter = require('events');
const
eventemitter
=
new
EventEmitter
();
const
eventemitter
=
new
EventEmitter
();
const
electron
=
require
(
'
electron
'
);
const
electron
=
require
(
'
electron
'
);
const
ipcMain
=
electron
.
ipcMain
;
const
app
=
electron
.
app
;
const
app
=
electron
.
app
;
const
BrowserWindow
=
electron
.
BrowserWindow
;
const
BrowserWindow
=
electron
.
BrowserWindow
;
...
@@ -169,19 +170,31 @@ function start_server() {
...
@@ -169,19 +170,31 @@ function start_server() {
}
}
connection
.
on
(
'
message
'
,
(
message
)
=>
{
connection
.
on
(
'
message
'
,
(
message
)
=>
{
message
=
JSON
.
parse
(
message
);
message
=
JSON
.
parse
(
message
);
eventemitter
.
emit
(
message
.
event
,
...
message
.
data
);
if
(
message
.
event
==
'
login
'
)
{
let
user
=
message
.
data
[
0
];
for
(
let
window
of
BrowserWindow
.
getAllWindows
())
{
window
.
webContents
.
send
(
'
login
'
,
user
);
}
message
=
JSON
.
stringify
({
event
:
'
login
'
,
data
:
[
user
]});
for
(
let
client
of
server
.
clients
)
{
if
(
client
!=
connection
)
{
client
.
send
(
message
);
}
}
}
else
{
eventemitter
.
emit
(
message
.
event
,
...
message
.
data
);
}
});
});
});
});
eventemitter
.
on
(
'
update
'
,
(
app
,
local
,
resson
)
=>
{
let
message
=
JSON
.
stringify
({
event
:
'
update
'
,
data
:
[
app
,
local
,
resson
]});
for
(
let
connection
of
server
.
clients
)
{
connection
.
send
(
message
);
}
save_db
();
})
}
}
eventemitter
.
on
(
'
update
'
,
(
app
,
local
,
resson
)
=>
{
let
message
=
JSON
.
stringify
({
event
:
'
update
'
,
data
:
[
app
,
local
,
resson
]});
for
(
let
connection
of
server
.
clients
)
{
connection
.
send
(
message
);
}
save_db
();
});
function
load
(
app
,
local
,
callback
)
{
function
load
(
app
,
local
,
callback
)
{
let
pending
=
1
;
let
pending
=
1
;
...
...
css/style.css
View file @
46875bb7
...
@@ -118,7 +118,7 @@ body.maximized #maximize {
...
@@ -118,7 +118,7 @@ body.maximized #maximize {
padding
:
0.175rem
;
padding
:
0.175rem
;
}
}
#
name
{
#
username
,
#logout
{
float
:
left
;
float
:
left
;
padding-top
:
.425rem
;
padding-top
:
.425rem
;
padding-bottom
:
.425rem
;
padding-bottom
:
.425rem
;
...
...
index.html
View file @
46875bb7
...
@@ -21,9 +21,10 @@
...
@@ -21,9 +21,10 @@
</li>
</li>
</ul>
</ul>
<div
class=
"navbar-right"
>
<div
class=
"navbar-right"
>
<div
id=
"user"
>
<div
id=
"user"
hidden
>
<img
id=
"avatar"
src=
"https://forum-cdn.touhou.cc/user_avatar/forum.touhou.cc/zh99998/36/167_1.png"
>
<img
id=
"avatar"
>
<div
id=
"name"
>
zh99998
</div>
<div
id=
"username"
></div>
<div
id=
"logout"
>
切换
</div>
</div>
</div>
<div
id=
"window-buttons"
hidden
>
<div
id=
"window-buttons"
hidden
>
<i
id=
"minimize"
class=
"icon-minimize"
></i>
<i
id=
"minimize"
class=
"icon-minimize"
></i>
...
...
js/app.js
View file @
46875bb7
var
platform
=
process
.
platform
;
'
use strict
'
;
var
remote
=
require
(
'
remote
'
);
var
current_window
=
remote
.
getCurrentWindow
();
document
.
getElementById
(
"
minimize
"
).
onclick
=
function
()
{
const
ipcRenderer
=
require
(
'
electron
'
).
ipcRenderer
;
const
remote
=
require
(
'
remote
'
);
const
current_window
=
remote
.
getCurrentWindow
();
document
.
getElementById
(
"
minimize
"
).
onclick
=
()
=>
{
current_window
.
minimize
()
current_window
.
minimize
()
};
};
document
.
getElementById
(
"
maximize
"
).
onclick
=
function
()
{
document
.
getElementById
(
"
maximize
"
).
onclick
=
()
=>
{
current_window
.
maximize
();
current_window
.
maximize
();
};
};
document
.
getElementById
(
"
restore
"
).
onclick
=
function
()
{
document
.
getElementById
(
"
restore
"
).
onclick
=
()
=>
{
current_window
.
unmaximize
();
current_window
.
unmaximize
();
};
};
document
.
getElementById
(
"
close
"
).
onclick
=
function
()
{
document
.
getElementById
(
"
close
"
).
onclick
=
()
=>
{
current_window
.
close
();
current_window
.
close
();
};
};
current_window
.
on
(
'
maximize
'
,
function
()
{
current_window
.
on
(
'
maximize
'
,
()
=>
{
document
.
body
.
className
=
platform
+
'
maximized
'
document
.
body
.
className
=
p
rocess
.
p
latform
+
'
maximized
'
});
});
current_window
.
on
(
'
unmaximize
'
,
function
()
{
current_window
.
on
(
'
unmaximize
'
,
()
=>
{
document
.
body
.
className
=
platform
document
.
body
.
className
=
p
rocess
.
p
latform
});
});
if
(
current_window
.
isMaximized
())
{
if
(
current_window
.
isMaximized
())
{
document
.
body
.
className
=
platform
+
'
maximized
'
document
.
body
.
className
=
p
rocess
.
p
latform
+
'
maximized
'
}
else
{
}
else
{
document
.
body
.
className
=
platform
document
.
body
.
className
=
p
rocess
.
p
latform
}
}
window
.
onhashchange
=
function
(
event
)
{
window
.
onhashchange
=
(
event
)
=>
{
var
hash
=
event
.
newURL
.
split
(
'
#
'
,
2
)[
1
];
let
hash
=
event
.
newURL
.
split
(
'
#
'
,
2
)[
1
];
document
.
getElementsByClassName
(
'
active
'
)[
0
].
className
=
""
;
document
.
getElementsByClassName
(
'
active
'
)[
0
].
className
=
""
;
document
.
getElementById
(
'
nav-
'
+
hash
).
className
=
"
active
"
;
document
.
getElementById
(
'
nav-
'
+
hash
).
className
=
"
active
"
;
document
.
getElementById
(
event
.
oldURL
.
split
(
'
#
'
,
2
)[
1
]).
style
.
display
=
'
none
'
;
document
.
getElementById
(
event
.
oldURL
.
split
(
'
#
'
,
2
)[
1
]).
style
.
display
=
'
none
'
;
document
.
getElementById
(
hash
).
style
.
display
=
'
block
'
;
document
.
getElementById
(
hash
).
style
.
display
=
'
block
'
;
};
};
var
hash
=
location
.
href
.
split
(
'
#
'
,
2
)[
1
];
let
hash
=
location
.
href
.
split
(
'
#
'
,
2
)[
1
];
document
.
getElementById
(
'
nav-
'
+
hash
).
className
=
"
active
"
;
document
.
getElementById
(
'
nav-
'
+
hash
).
className
=
"
active
"
;
document
.
getElementById
(
hash
).
style
.
display
=
'
block
'
;
document
.
getElementById
(
hash
).
style
.
display
=
'
block
'
;
var
webviews
=
document
.
getElementsByTagName
(
'
webview
'
);
let
webviews
=
document
.
getElementsByTagName
(
'
webview
'
);
for
(
var
i
=
0
;
i
<
webviews
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
webviews
.
length
;
i
++
)
{
webviews
.
item
(
i
).
addEventListener
(
'
new-window
'
,
function
(
event
)
{
webviews
.
item
(
i
).
addEventListener
(
'
new-window
'
,
(
event
)
=>
{
require
(
'
electron
'
).
shell
.
openExternal
(
event
.
url
);
require
(
'
electron
'
).
shell
.
openExternal
(
event
.
url
);
});
});
}
}
\ No newline at end of file
document
.
getElementById
(
"
logout
"
).
onclick
=
()
=>
{
current_window
.
webContents
.
session
.
clearStorageData
(()
=>
{
location
.
reload
();
})
};
ipcRenderer
.
on
(
'
login
'
,
(
event
,
user
)
=>
{
console
.
log
(
event
,
user
);
document
.
getElementById
(
'
avatar
'
).
src
=
user
.
avatar_url
;
document
.
getElementById
(
'
username
'
).
innerHTML
=
user
.
username
;
document
.
getElementById
(
'
user
'
).
removeAttribute
(
'
hidden
'
);
});
\ 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