Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
netdisc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rocosen
netdisc
Commits
364b555d
Commit
364b555d
authored
Dec 05, 2022
by
rocosen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
43ff9c90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
12 deletions
+46
-12
main.ts
src/main/main.ts
+23
-1
util.ts
src/main/util.ts
+16
-11
head.jsx
src/renderer/components/head.jsx
+7
-0
No files found.
src/main/main.ts
View file @
364b555d
...
...
@@ -17,6 +17,7 @@ import { resolveHtmlPath } from './util';
const
nativeImage
=
require
(
'electron'
).
nativeImage
;
const
positioner
=
require
(
'electron-traywindow-positioner'
);
const
storage
=
require
(
'electron-localstorage'
);
const
fs
=
require
(
'fs'
);
class
AppUpdater
{
constructor
()
{
log
.
transports
.
file
.
level
=
'info'
;
...
...
@@ -119,7 +120,7 @@ ipcMain.on('resize-home', (event) => {
homeWindown
.
loadURL
(
resolveHtmlPath
(
`index.html#/home`
));
positioner
.
position
(
homeWindown
,
tray
.
getBounds
(),
alignment
);
isDev
&&
homeWindown
.
webContents
.
openDevTools
();
//
homeWindown.webContents.openDevTools();
homeWindown
.
webContents
.
openDevTools
();
homeWindown
.
once
(
'ready-to-show'
,
()
=>
{
homeWindown
?.
show
();
});
...
...
@@ -133,6 +134,27 @@ ipcMain.on('resize-home', (event) => {
});
});
// 主进程
// path.join(__dirname, '../renderer/data/data.json'),
ipcMain
.
on
(
'asynchronous-message'
,
function
(
event
,
arg
)
{
// arg是从渲染进程返回来的数据
fs
.
writeFile
(
resolveHtmlPath
(
'/data/roco.json'
),
JSON
.
stringify
(
arg
),
'utf8'
,
(
err
:
any
)
=>
{
if
(
err
)
{
event
.
sender
.
send
(
'asynchronous-reply'
,
'写入失败'
);
// alert('222222');
}
else
{
event
.
sender
.
send
(
'asynchronous-reply'
,
'写入成功'
);
// alert('111111');
}
}
);
});
ipcMain
.
on
(
'window-close'
,
(
event
)
=>
{
app
.
quit
();
});
...
...
src/main/util.ts
View file @
364b555d
...
...
@@ -3,15 +3,20 @@ import { URL } from 'url';
import
path
from
'path'
;
export
function
resolveHtmlPath
(
htmlFileName
:
string
)
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
const
port
=
process
.
env
.
PORT
||
1212
;
const
url
=
new
URL
(
`http://localhost:
${
port
}
`
);
url
.
pathname
=
htmlFileName
let
goPath
=
url
.
href
.
replace
(
'%23'
,
'#'
)
return
goPath
;
}
else
{
let
openPath
=
`file://
${
path
.
resolve
(
__dirname
,
'../renderer/'
,
htmlFileName
)}
`
let
src
=
openPath
.
replace
(
/
\\
/g
,
'/'
)
return
src
;
}
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
const
port
=
process
.
env
.
PORT
||
1212
;
const
url
=
new
URL
(
`http://localhost:
${
port
}
`
);
url
.
pathname
=
htmlFileName
;
let
goPath
=
url
.
href
.
replace
(
'%23'
,
'#'
);
return
goPath
;
}
else
{
let
openPath
=
`file://
${
path
.
resolve
(
__dirname
,
'../renderer/'
,
htmlFileName
)}
`
;
let
src
=
openPath
.
replace
(
/
\\
/g
,
'/'
);
console
.
log
(
'src: '
,
src
);
return
src
;
}
}
src/renderer/components/head.jsx
View file @
364b555d
...
...
@@ -109,6 +109,13 @@ export default (props) => {
switch
(
e
)
{
case
'1'
:
return
;
case
'2'
:
console
.
log
(
'2222222222222222222222'
);
electron
.
ipcRenderer
.
send
(
'asynchronous-message'
,
'传递回去ping'
);
return
;
case
'4'
:
let
Token
=
localStorage
.
getItem
(
Constants
.
TOKEN_KEY
)
&&
...
...
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