Skip to content

Commit 1c3feb7

Browse files
fix: navigator.language
add: proxy check
1 parent 95e9242 commit 1c3feb7

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

server/src/api/native.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ window.updateLaunchState = function () {
1212
updateRuningState()
1313
}
1414

15-
export async function chromeSend(name, ...params) {
15+
export async function chromeSendTimeout(name, timeout=2000, ...params) {
1616
const pTimeOut = (timeout) => {
1717
return new Promise((resolve, reject) => {
1818
setTimeout(() => {
@@ -31,7 +31,11 @@ export async function chromeSend(name, ...params) {
3131
chrome.send(name, args)
3232
})
3333

34-
return Promise.race([pCall, pTimeOut(2000)])
34+
return Promise.race([pCall, pTimeOut(timeout)])
35+
}
36+
37+
export async function chromeSend(name, ...params) {
38+
return chromeSendTimeout(name, 2000, ...params)
3539
}
3640

3741
export async function getBrowserList() {

server/src/styles/index.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,8 @@ aside {
208208
padding-left: 15px;
209209
}
210210
}
211+
212+
.el-message-box__message p {
213+
word-wrap: break-word;
214+
margin-bottom: .2em;
215+
}

server/src/views/browser/index.vue

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<el-table-column
6666
:label="$t('browser.ip_port')"
6767
width="200px"
68-
>
68+
>
6969
<template slot-scope="{ row }">
7070
<span>
7171
{{ row.proxy.protocol }}
@@ -236,6 +236,14 @@
236236
v-model="form.proxy.pass"
237237
style="max-width: 250px"
238238
/>
239+
&nbsp;
240+
<el-button
241+
type="primary"
242+
style="margin-left: 7px"
243+
:disabled2="checkProxyState.checking"
244+
:loading="checkProxyState.checking"
245+
@click="checkProxy"
246+
>检测{{ checkProxyState.checking ? '中':'' }}</el-button>
239247
</el-form-item>
240248
<!-- <el-form-item
241249
:label="$t('browser.proxy.value')"
@@ -724,7 +732,7 @@ import {
724732
updateBrowser,
725733
deleteBrowser,
726734
chromeSend,
727-
getBrowserVersion,
735+
chromeSendTimeout,
728736
updateRuningState,
729737
} from '@/api/native'
730738
import { saveAs } from 'file-saver'
@@ -770,7 +778,7 @@ export default {
770778
data() {
771779
const validateCookie = (rule, value, callback) => {
772780
if (this.form.cookie.mode === 0) {
773-
// this.form.cookie.mode = 0
781+
this.form.cookie.value = ''
774782
callback()
775783
return
776784
}
@@ -857,7 +865,7 @@ export default {
857865
'audio-context': {},
858866
media: {},
859867
'client-rects': {},
860-
'speech_voices': {},
868+
speech_voices: {},
861869
ssl: {},
862870
cpu: {},
863871
memory: {},
@@ -943,6 +951,9 @@ export default {
943951
"sameSite": "None"
944952
}]`,
945953
copied: false,
954+
checkProxyState: {
955+
checking: false
956+
},
946957
}
947958
},
948959
computed: {
@@ -1028,7 +1039,7 @@ export default {
10281039
this.$watch(
10291040
() => this.form['ua-language'].language,
10301041
(val) => {
1031-
this.form['ua-language'].value = [val, val.split('-')[0]]
1042+
this.form['ua-language'].value = [val, val.split('-')[0]].join(',')
10321043
this.form['time-zone'].locale = val
10331044
}
10341045
)
@@ -1196,9 +1207,9 @@ export default {
11961207
width: random.float(-1, 1),
11971208
height: random.float(-1, 1),
11981209
},
1199-
'speech_voices': {
1210+
speech_voices: {
12001211
mode: 1,
1201-
value: genRandomSpeechVoices()
1212+
value: genRandomSpeechVoices(),
12021213
},
12031214
ssl: {
12041215
mode: 0,
@@ -1434,6 +1445,22 @@ export default {
14341445
})
14351446
saveAs(blob, 'Virtual-Browser.json')
14361447
},
1448+
async checkProxy() {
1449+
this.checkProxyState.checking = true
1450+
this.preProcessData(this.form)
1451+
let timeout = false
1452+
const ret = await chromeSendTimeout('checkProxy', 10 * 1000, this.form.proxy.url).catch(err => { timeout = (err === 'timeout') })
1453+
this.$alert(
1454+
`<p>代理:${this.form.proxy.url}</p>
1455+
<p style="color:${ret ? '#67C23A' : '#F56C6C'}">检测${ret ? '成功' : (timeout ? '超时' : '失败')}</p>`,
1456+
'代理检测',
1457+
{
1458+
type: ret ? 'success' : 'error',
1459+
dangerouslyUseHTMLString: true,
1460+
}
1461+
)
1462+
this.checkProxyState.checking = false
1463+
},
14371464
},
14381465
}
14391466
</script>

0 commit comments

Comments
 (0)