Skip to content

Commit bd5fbf2

Browse files
committed
Use consistent port, update electrom shell template to display proper IP
1 parent 9cdd0c8 commit bd5fbf2

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

shells/electron/app.html

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535

3636
#intro .content {
37-
width: 370px;
37+
width: 395px;
3838
font-size: 18px;
3939
line-height: 45px;
4040
text-align: center;
@@ -52,12 +52,13 @@
5252

5353
#intro .content-row input {
5454
flex: 1;
55-
margin-left: 10px;
56-
font-size: 14px;
5755
height: 32px;
56+
padding: 0 10px;
57+
margin-left: 10px;
5858
border: 1px solid #cacaca;
5959
border-radius: 2px;
60-
padding: 0 10px;
60+
text-align: center;
61+
font-size: 14px;
6162
}
6263
</style>
6364
</head>
@@ -81,6 +82,26 @@ <h2 class="title">
8182
</div>
8283
</div>
8384
</div>
85+
<script>
86+
const port = process.env.PORT || 8098
87+
const localIp = require('ip').address();
88+
const $ = document.querySelector.bind(document)
89+
90+
const $localhost = $('#script-localhost')
91+
const $byIp = $('#script-byip')
92+
const $intro = $('#intro')
93+
94+
$localhost.value = '<' + 'script src="http://localhost:' + port + '"><' + '/script>'
95+
$byIp.value = '<' + 'script src="http://' + localIp + ':' + port + '"><' + '/script>'
96+
97+
function selectAll () {
98+
this.selectionStart = 0
99+
this.selectionEnd = this.value.length
100+
}
101+
102+
$localhost.onclick = selectAll
103+
$byIp.onclick = selectAll
104+
</script>
84105
<script src="build/devtools.js"></script>
85106
</body>
86107
</html>

shells/electron/bin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
#!/usr/bin/env node
12
const electron = require('electron')
23
const spawn = require('cross-spawn')
4+
const argv = process.argv.slice(2)
35

46
const result = spawn.sync(
57
electron,
6-
[
7-
require.resolve('./app')
8-
],
8+
[require.resolve('./app')].concat(argv),
99
{ stdio: 'ignore' }
1010
)
1111

shells/electron/server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const http = require('http').Server(app)
33
const io = require('socket.io')(http)
44
const path = require('path')
55

6+
const port = process.env.PORT || 8098
7+
68
app.get('/', function (req, res) {
79
res.sendFile(path.join(__dirname, '/build/backend.js'))
810
})
@@ -17,6 +19,6 @@ io.on('connection', function (socket) {
1719
})
1820
})
1921

20-
http.listen(8098, () => {
21-
console.log('listening on *:8098')
22+
http.listen(port, () => {
23+
console.log('listening on *:' + port)
2224
})

shells/electron/src/devtools.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
import io from 'socket.io-client'
2-
import ip from 'ip'
32
import { initDevTools } from 'src/devtools'
43
import Bridge from 'src/bridge'
54

65
const port = process.env.PORT || 8098
76
const socket = io('http://localhost:' + port)
8-
const localIp = ip.address()
9-
const $ = document.querySelector.bind(document)
10-
11-
const $localhost = $('#script-localhost')
12-
const $byIp = $('#script-byip')
13-
const $intro = $('#intro')
14-
15-
$localhost.value = '<' + 'script src="http://localhost:' + port + '"><' + '/script>'
16-
$byIp.value = '<' + 'script src="http://' + localIp + ':' + port + '"><' + '/script>'
17-
18-
function selectAll () {
19-
this.selectionStart = 0
20-
this.selectionEnd = this.value.length
21-
}
22-
23-
$localhost.onclick = selectAll
24-
$byIp.onclick = selectAll
257

268
let reload = null
279

@@ -31,8 +13,6 @@ socket.on('vue-devtools-init', () => {
3113

3214
initDevTools({
3315
connect (callback) {
34-
$intro.classList.add('hidden')
35-
3616
const wall = {
3717
listen (fn) {
3818
socket.on('vue-message', data => fn(data))

0 commit comments

Comments
 (0)