✨ 支持自定义客户端端口
This commit is contained in:
parent
e784092c1a
commit
da36ed9d1b
@ -4,7 +4,7 @@ consola.info('debug日志:', process.env.DEBUG === '1' ? '开启' : '关闭')
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
httpPort: 8082,
|
httpPort: 8082,
|
||||||
clientPort: 22022, // 暂不支持更改
|
clientDefaultPort: 22022,
|
||||||
uploadDir: path.join(process.cwd(),'app/db'),
|
uploadDir: path.join(process.cwd(),'app/db'),
|
||||||
staticDir: path.join(process.cwd(),'app/static'),
|
staticDir: path.join(process.cwd(),'app/static'),
|
||||||
sftpCacheDir: path.join(process.cwd(),'app/socket/sftp-cache'),
|
sftpCacheDir: path.join(process.cwd(),'app/socket/sftp-cache'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const { Server: ServerIO } = require('socket.io')
|
const { Server: ServerIO } = require('socket.io')
|
||||||
const { io: ClientIO } = require('socket.io-client')
|
const { io: ClientIO } = require('socket.io-client')
|
||||||
const { readHostList } = require('../utils/storage')
|
const { readHostList } = require('../utils/storage')
|
||||||
const { clientPort } = require('../config')
|
const { clientDefaultPort } = require('../config')
|
||||||
const { verifyAuthSync } = require('../utils/verify-auth')
|
const { verifyAuthSync } = require('../utils/verify-auth')
|
||||||
const { isAllowedIp } = require('../utils/tools')
|
const { isAllowedIp } = require('../utils/tools')
|
||||||
|
|
||||||
@ -15,9 +15,9 @@ async function getClientsInfo(clientSockets) {
|
|||||||
if (!hostList.some(item => item.host === clientItem.host)) clientItem.close && clientItem.close()
|
if (!hostList.some(item => item.host === clientItem.host)) clientItem.close && clientItem.close()
|
||||||
})
|
})
|
||||||
hostList
|
hostList
|
||||||
.map(({ host, name }) => {
|
.map(({ host, name, clientPort }) => {
|
||||||
if (clientSockets.some(item => item.host === host)) return { name, isIo: true } // 已经建立io连接(无论是否连接成功)的host不再重复建立连接,因为存在多次(reconnectionAttempts)的重试机制
|
if (clientSockets.some(item => item.host === host)) return { name, isIo: true } // 已经建立io连接(无论是否连接成功)的host不再重复建立连接,因为存在多次(reconnectionAttempts)的重试机制
|
||||||
let clientSocket = ClientIO(`http://${ host }:${ clientPort }`, {
|
let clientSocket = ClientIO(`http://${ host }:${ clientPort || clientDefaultPort }`, {
|
||||||
path: '/client/os-info',
|
path: '/client/os-info',
|
||||||
forceNew: true,
|
forceNew: true,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
|
@ -24,7 +24,6 @@ app.config.globalProperties.$store = useStore()
|
|||||||
|
|
||||||
const serviceURI = import.meta.env.DEV ? process.env.serviceURI : location.origin
|
const serviceURI = import.meta.env.DEV ? process.env.serviceURI : location.origin
|
||||||
app.config.globalProperties.$serviceURI = serviceURI
|
app.config.globalProperties.$serviceURI = serviceURI
|
||||||
app.config.globalProperties.$clientPort = process.env.clientPort || 22022
|
|
||||||
app.config.globalProperties.$store.$patch({ serviceURI })
|
app.config.globalProperties.$store.$patch({ serviceURI })
|
||||||
console.warn('ISDEV: ', import.meta.env.DEV)
|
console.warn('ISDEV: ', import.meta.env.DEV)
|
||||||
console.warn('serviceURI: ', serviceURI)
|
console.warn('serviceURI: ', serviceURI)
|
||||||
|
@ -21,7 +21,7 @@ const useStore = defineStore({
|
|||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async setJwtToken(token, isSession = true) {
|
async setJwtToken(token, isSession = true) {
|
||||||
if(isSession) sessionStorage.setItem('token', token)
|
if (isSession) sessionStorage.setItem('token', token)
|
||||||
else localStorage.setItem('token', token)
|
else localStorage.setItem('token', token)
|
||||||
this.$patch({ token })
|
this.$patch({ token })
|
||||||
},
|
},
|
||||||
@ -73,7 +73,7 @@ const useStore = defineStore({
|
|||||||
// setInterval(() => {
|
// setInterval(() => {
|
||||||
// this.hostList.forEach((item) => {
|
// this.hostList.forEach((item) => {
|
||||||
// const { host } = item
|
// const { host } = item
|
||||||
// ping(`http://${ host }:${ this.$clientPort }`)
|
// ping(`http://${ host }:${ 22022 }`)
|
||||||
// .then((res) => {
|
// .then((res) => {
|
||||||
// item.ping = res
|
// item.ping = res
|
||||||
// })
|
// })
|
||||||
@ -121,7 +121,7 @@ const useStore = defineStore({
|
|||||||
localStorage.setItem('isDark', isDark)
|
localStorage.setItem('isDark', isDark)
|
||||||
this.$patch({ isDark })
|
this.$patch({ isDark })
|
||||||
}
|
}
|
||||||
if(animate) {
|
if (animate) {
|
||||||
let transition = document.startViewTransition(() => {
|
let transition = document.startViewTransition(() => {
|
||||||
document.documentElement.classList.toggle('dark')
|
document.documentElement.classList.toggle('dark')
|
||||||
})
|
})
|
||||||
|
@ -301,17 +301,17 @@ const handleColor = (num) => {
|
|||||||
if (num <= 100) return '#ff4949'
|
if (num <= 100) return '#ff4949'
|
||||||
}
|
}
|
||||||
|
|
||||||
const getHostPing = () => {
|
// const getHostPing = () => {
|
||||||
pingTimer.value = setInterval(() => {
|
// pingTimer.value = setInterval(() => {
|
||||||
$tools.ping(`http://${ props.host }:22022`)
|
// $tools.ping(`http://${ props.host }:22022`)
|
||||||
.then(res => {
|
// .then(res => {
|
||||||
ping.value = res
|
// ping.value = res
|
||||||
if (!import.meta.env.DEV) {
|
// if (!import.meta.env.DEV) {
|
||||||
console.warn('Please tick \'Preserve Log\'')
|
// console.warn('Please tick \'Preserve Log\'')
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}, 3000)
|
// }, 3000)
|
||||||
}
|
// }
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
socket.value && socket.value.close()
|
socket.value && socket.value.close()
|
||||||
|
@ -37,8 +37,7 @@ export default defineConfig({
|
|||||||
define: {
|
define: {
|
||||||
'process.env': {
|
'process.env': {
|
||||||
serviceURI,
|
serviceURI,
|
||||||
serviceApiPrefix,
|
serviceApiPrefix
|
||||||
clientPort: 22022
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user