liuq 4 місяців тому
батько
коміт
b32f1f55b0

+ 1 - 1
README.md

@@ -424,7 +424,7 @@ VIDEO_ANALYSIS_PASSWORD=your_password
 npm run server
 ```
 
-后端服务器默认运行在 `http://localhost:3001`
+后端服务器默认运行在 `http://0.0.0.0:8888`(可通过环境变量 `PORT` 修改端口)
 
 #### 5. 工作原理
 

+ 4 - 4
server.js

@@ -11,7 +11,7 @@ const __filename = fileURLToPath(import.meta.url);
 const __dirname = dirname(__filename);
 
 const app = express();
-const PORT = 3001;
+const PORT = process.env.PORT || 8888;
 
 // 中间件
 app.use(cors({
@@ -403,8 +403,8 @@ app.get('/api/health', (req, res) => {
   res.json({ status: 'ok' });
 });
 
-app.listen(PORT, () => {
-  console.log(`后端服务器运行在 http://localhost:${PORT}`);
+app.listen(PORT, '0.0.0.0', () => {
+  console.log(`后端服务器运行在 http://0.0.0.0:${PORT}`);
   console.log(`已配置的自动登录网站: ${Object.keys(autoLoginConfig).join(', ') || '无'}`);
-  console.log(`自动登录端点格式: http://localhost:${PORT}/api/auto-login/:siteId`);
+  console.log(`自动登录端点格式: http://0.0.0.0:${PORT}/api/auto-login/:siteId`);
 });

+ 2 - 1
src/components/NavigationCard.vue

@@ -15,7 +15,7 @@
         <a
           v-for="(link, linkIndex) in sortedLinks(group.links)"
           :key="link.name"
-          :href="link.autoLogin ? `http://localhost:3001${link.autoLoginEndpoint}` : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
+          :href="link.autoLogin ? getAutoLoginUrl(link.autoLoginEndpoint) : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
           target="_blank"
           rel="noopener noreferrer"
           class="link-card"
@@ -47,6 +47,7 @@
 <script setup>
 import { ref, computed, onMounted } from 'vue'
 import navigationData from '../data/navigation.json'
+import { getAutoLoginUrl } from '../config/backend.js'
 
 const groups = ref([])
 

+ 2 - 1
src/components/NavigationList.vue

@@ -26,7 +26,7 @@
         <a
           v-for="(link, linkIndex) in sortedLinks(group.links)"
           :key="link.name"
-          :href="link.autoLogin ? `http://localhost:3001${link.autoLoginEndpoint}` : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
+          :href="link.autoLogin ? getAutoLoginUrl(link.autoLoginEndpoint) : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
           target="_blank"
           rel="noopener noreferrer"
           class="link-item"
@@ -56,6 +56,7 @@
 <script setup>
 import { ref, computed, onMounted } from 'vue'
 import navigationData from '../data/navigation.json'
+import { getAutoLoginUrl } from '../config/backend.js'
 
 const groups = ref([])
 

+ 2 - 1
src/components/NavigationMinimal.vue

@@ -13,7 +13,7 @@
         <a
           v-for="(link, linkIndex) in sortedLinks(group.links)"
           :key="link.name"
-          :href="link.autoLogin ? `http://localhost:3001${link.autoLoginEndpoint}` : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
+          :href="link.autoLogin ? getAutoLoginUrl(link.autoLoginEndpoint) : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
           target="_blank"
           rel="noopener noreferrer"
           class="link-card"
@@ -39,6 +39,7 @@
 <script setup>
 import { ref, computed, onMounted } from 'vue'
 import navigationData from '../data/navigation.json'
+import { getAutoLoginUrl } from '../config/backend.js'
 
 const groups = ref([])
 

+ 2 - 1
src/components/NavigationModern.vue

@@ -26,7 +26,7 @@
         <a
           v-for="(link, linkIndex) in sortedLinks(group.links)"
           :key="link.name"
-          :href="link.autoLogin ? `http://localhost:3001${link.autoLoginEndpoint}` : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
+          :href="link.autoLogin ? getAutoLoginUrl(link.autoLoginEndpoint) : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
           target="_blank"
           rel="noopener noreferrer"
           class="link-card"
@@ -60,6 +60,7 @@
 <script setup>
 import { ref, computed, onMounted } from 'vue'
 import navigationData from '../data/navigation.json'
+import { getAutoLoginUrl } from '../config/backend.js'
 
 const groups = ref([])
 

+ 2 - 1
src/components/NavigationTV.vue

@@ -5,7 +5,7 @@
       <a
         v-for="(link, linkIndex) in sortedLinks(currentGroup.links)"
         :key="link.name"
-        :href="link.autoLogin ? `http://localhost:3001${link.autoLoginEndpoint}` : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
+        :href="link.autoLogin ? getAutoLoginUrl(link.autoLoginEndpoint) : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
         target="_blank"
         rel="noopener noreferrer"
         class="app-tile"
@@ -54,6 +54,7 @@
 <script setup>
 import { ref, computed, onMounted, onUnmounted } from 'vue'
 import navigationData from '../data/navigation.json'
+import { getAutoLoginUrl } from '../config/backend.js'
 
 const groups = ref([])
 const activeTabIndex = ref(0)

+ 13 - 0
src/config/backend.js

@@ -0,0 +1,13 @@
+// 后端服务器配置
+export const BACKEND_CONFIG = {
+  // 后端服务器地址
+  baseURL: 'http://222.243.138.146:8888',
+  // 自动登录端点前缀
+  autoLoginPrefix: '/api/auto-login'
+}
+
+// 获取完整的自动登录端点URL
+export function getAutoLoginUrl(endpoint) {
+  return `${BACKEND_CONFIG.baseURL}${endpoint}`
+}
+