准备服务器部署
This commit is contained in:
parent
f0b91409b6
commit
c14c3d210a
3
.gitignore
vendored
3
.gitignore
vendored
@ -36,6 +36,9 @@ src-tauri/target/
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Config
|
||||
config.json
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
@ -107,12 +107,10 @@ io.on('connection', (socket) => {
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
const HOST = process.env.HOST || '127.0.0.1';
|
||||
|
||||
httpServer.listen(PORT, HOST, () => {
|
||||
console.log(`P2P Transfer Server running on http://${HOST}:${PORT}`);
|
||||
console.log(`Local access: http://localhost:${PORT}`);
|
||||
console.log(`LAN access: http://${getLocalIP()}:${PORT}`);
|
||||
});
|
||||
|
||||
function getLocalIP() {
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
import { ref, onMounted, onUnmounted } from 'vue';
|
||||
import { io } from 'socket.io-client';
|
||||
import { generateUserId } from '../utils';
|
||||
import config from '../../config.json';
|
||||
|
||||
function isTauri() {
|
||||
return window.__TAURI__ !== undefined;
|
||||
}
|
||||
|
||||
function getDefaultServerUrl() {
|
||||
return config.defaultServerUrl || 'http://localhost:3000';
|
||||
}
|
||||
|
||||
export function useSocket() {
|
||||
const socket = ref(null);
|
||||
const userId = ref('');
|
||||
@ -13,7 +18,7 @@ export function useSocket() {
|
||||
const connected = ref(false);
|
||||
const roomUsers = ref([]);
|
||||
const roomId = ref('');
|
||||
const serverUrl = ref(localStorage.getItem('p2p-server-url') || 'http://localhost:3000');
|
||||
const serverUrl = ref(localStorage.getItem('p2p-server-url') || getDefaultServerUrl());
|
||||
|
||||
onMounted(() => {
|
||||
userId.value = generateUserId();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user