diff --git a/src/Dashboard.vue b/src/Dashboard.vue index fc988bc..264c09d 100644 --- a/src/Dashboard.vue +++ b/src/Dashboard.vue @@ -167,11 +167,11 @@ const execServiceCmd = (operation) => { disablePull.value = true setTimeout(() => { execXrayHelperCmd("service " + operation.value).then(value => { - if(operation.value=="start"||operation.value=="restart"){ + if(operation.value==="start"||operation.value==="restart"){ execXrayHelperCmd("proxy refresh").then(value2 => { stdout.value=value+'\n'+value2; }) - }else if (operation.value=="stop"){ + }else if (operation.value==="stop"){ execXrayHelperCmd("proxy disable").then(value2 => { stdout.value=value+'\n'+value2; }) diff --git a/src/Manage.vue b/src/Manage.vue index 2833251..a5a28df 100644 --- a/src/Manage.vue +++ b/src/Manage.vue @@ -39,28 +39,22 @@ - @@ -119,6 +113,7 @@ const getConfig = async () => { }) } const switchChecked = (item) => { + item.switchLoading = true; //有BUG,如果在查找的情况下就会导致 console.info('switchChecked') let idx = allNodeList.value.indexOf(item); @@ -145,7 +140,8 @@ const switchChecked = (item) => { } else { showToast(i18n.global.t('dashboard.tool-switch-failed')) } - onRefresh(); + item.switchLoading = false + onRefresh() }) } const onLoad = () => { @@ -393,7 +389,7 @@ const convertObject = (arr, custom) => { obj['custom'] = custom; obj['hashId'] = cyrb53(JSON.stringify(obj)); // TODO 可能会出现多个相同节点? - obj['selected'] = lastSelected === obj.hashId; + obj['selected'] = lastSelected == obj.hashId; convertArr.push(obj); } return convertArr; @@ -441,6 +437,7 @@ initStatus() .custom-title { margin-right: 4px; vertical-align: middle; + white-space: nowrap; } .search-icon { diff --git a/src/Setting.vue b/src/Setting.vue index 190c70a..8d14873 100644 --- a/src/Setting.vue +++ b/src/Setting.vue @@ -246,7 +246,7 @@ import {ref} from 'vue' import i18n from "./locales/i18n.js" import YAML from "yaml" -import {callApi, readFile,execCmdWithErrNo,execXrayHelperCmd, saveFile, XRAYHELPER_CONFIG} from "./tools.js" +import {callApi, readFile,execCmdWithExitCode,execXrayHelperCmd, saveFile, XRAYHELPER_CONFIG} from "./tools.js" defineProps(["theme"]) const loading = ref(false) @@ -269,11 +269,10 @@ const changeCoreType = (core) => { saveConfig() showConfirmDialog({ message: i18n.global.t('setting.switch-core') - }) - .then(() => { - const basePath='/data/adb/xray' - const binPath=`${basePath}/bin/${core.value}` - config.value.xrayHelper.corePath=binPath + }).then(() => { + const basePath = '/data/adb/xray' + const binPath = `${basePath}/bin/${core.value}` + config.value.xrayHelper.corePath = binPath switch (core.value) { case 'v2ray': config.value.xrayHelper.coreConfig = `${basePath}/v2rayconfs/config.json` @@ -296,8 +295,7 @@ const changeCoreType = (core) => { } saveConfig() checkCoreBin(binPath) - }) - .catch(() => { + }).catch(() => { () => resolve(true) }); } @@ -350,8 +348,8 @@ const socksPortEditor = ref(false) const tunDeviceEditor = ref(false) const checkCoreBin = (corePath) => { - execCmdWithErrNo(`ls ${corePath}`).then(errno => { - if(errno!=0){ + execCmdWithExitCode(`ls ${corePath}`).then(errno => { + if(errno!==0){ showConfirmDialog({ message: i18n.global.t('setting.core-not-found'), }).then(() => { @@ -479,13 +477,14 @@ const saveConfig = () => { setTimeout(() => { callApi("get status").then(value => { if (value.pid.length > 0) { - execXrayHelperCmd("proxy refresh").then(value2 => { + execXrayHelperCmd("proxy refresh").then(() => { showToast(i18n.global.t('setting.refresh-proxy')) }) } }) }, 50) } + const onRefresh = () => { setTimeout(() => { initConfig() diff --git a/src/locales/en-US.js b/src/locales/en-US.js index 03e0a67..abd2814 100644 --- a/src/locales/en-US.js +++ b/src/locales/en-US.js @@ -53,7 +53,7 @@ export const manage = { 'placeholder-text': 'Please enter an Remarks.', 'speedtest-fail': 'The speed measurement failed and an exception occurred.', 'speedtest-reject': 'Wait patiently until the speed measurement of other nodes is completed before continuing.', - 'speedtest-all-warn': 'All nodes will be speed tested soon to prevent the airport from being blocked! Use with caution (ps: not recommended. Too many nodes will freeze the page). Confirm to continue?', + 'speedtest-all-warn': 'All nodes will be speed tested soon to prevent the airport from being blocked! Use with caution. Confirm to continue?', } export const setting = { 'xrayhelper': 'Config - XrayHelper', diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js index 78df72d..3abfd1b 100644 --- a/src/locales/zh-CN.js +++ b/src/locales/zh-CN.js @@ -53,7 +53,7 @@ export const manage = { 'placeholder-text': '请输入别名', 'speedtest-fail': '测速失败,发生异常。', 'speedtest-reject': '耐心等待其他节点测速结束后再继续。', - 'speedtest-all-warn': '即将测速所有节点,以防机场封号!谨慎使用(ps:不推荐,节点多页面会卡死),确认继续?', + 'speedtest-all-warn': '即将测速所有节点,以防机场封号!谨慎使用,确认继续?', } export const setting = { 'xrayhelper': '配置项 - XrayHelper', diff --git a/src/tools.js b/src/tools.js index 70dbf75..b877a52 100644 --- a/src/tools.js +++ b/src/tools.js @@ -4,7 +4,7 @@ import {Buffer} from 'buffer/' export const XRAYHELPER = "/data/adb/xray/bin/xrayhelper" export const XRAYHELPER_CONFIG = "/data/adb/xray/xrayhelper.yml" -export const execCmdWithErrNo = async (cmd) => { +export const execCmdWithExitCode = async (cmd) => { console.info(cmd) const {errno, stdout,stderr} = await exec(cmd, {cwd: '/'}) if (errno === 0) { @@ -51,15 +51,13 @@ export const callApi = async (api) => { } else if (!(api instanceof Array)) { api = api.split(" ") } - let params = ["-c", XRAYHELPER, "-c", XRAYHELPER_CONFIG, "api"] + let params = ["-c", XRAYHELPER, "-c", XRAYHELPER_CONFIG, "-t", "3", "api"] params.push(...api) let process = spawn('su', params); process.stdout.on('data', (data) => { - debugger result.data = JSON.parse(data) }) process.on('exit', () => { - debugger result.exited = true }) while (true) {