diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c1e2e42..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# 使用官方的 Node.js 运行时镜像作为基础镜像 -FROM node:lts-alpine - -# 设置工作目录 -WORKDIR /app -# 复制项目文件到工作目录 -COPY hubcmdui/ . -# 安装项目依赖 -RUN npm install - -# 暴露应用程序的端口 -EXPOSE 3000 - -# 运行应用程序 -CMD ["node", "server.js"] \ No newline at end of file diff --git a/hubcmdui/config.json b/hubcmdui/config.json deleted file mode 100644 index e69de29..0000000 diff --git a/hubcmdui/web/index.html b/hubcmdui/docker-proxy.html similarity index 74% rename from hubcmdui/web/index.html rename to hubcmdui/docker-proxy.html index e51e7d6..d6e15ef 100644 --- a/hubcmdui/web/index.html +++ b/hubcmdui/docker-proxy.html @@ -53,10 +53,11 @@ } .container { max-width: 800px; - width: 90%; + min-width: 800px; /* 固定容器宽度 */ + width: 100%; margin: 20px auto; background: white; - padding: 20px; + padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); flex-grow: 1; @@ -96,15 +97,20 @@ button:hover { background-color: #2c974b; } + /* 广告容器样式 */ .ad-container { display: flex; justify-content: center; align-items: center; - margin-top: 30px; + margin-top: 90px; /* 与获取命令按钮之间的间距 */ margin-bottom: 30px; + max-width: 800px; + min-width: 800px; } .ad-container img { max-width: 100%; + width: 750; /* 广告图片宽度 */ + height: 300px; /* 广告图片高度 */ border-radius: 8px; } pre { @@ -114,27 +120,20 @@ overflow: auto; font-size: 14px; border: 1px solid #e1e4e8; - position: relative; } .copy-btn { - position: absolute; - top: 8px; - right: 8px; + float: right; padding: 6px 12px; font-size: 12px; - background-color: #f0f0f0; - color: #333; + margin-top: -5px; + background-color: #0366d6; + color: white; border: none; border-radius: 4px; cursor: pointer; - transition: background-color 0.3s, color 0.3s; - font-family: 'Arial', sans-serif; - font-weight: 500; - border-radius: 12px; } .copy-btn:hover { - background-color: #e0e0e0; - color: #000; + background-color: #0256b9; } .step { margin-bottom: 25px; @@ -179,6 +178,10 @@ #backToTopBtn:hover { background-color: #0256b9; } + #backToTopBtn:before { + display: inline-block; + font-size: 20px; + } #backToTopBtn::after { content: '返回顶部'; display: none; @@ -194,33 +197,6 @@ #backToTopBtn:hover::after { display: block; } - @media (max-width: 768px) { - .nav-menu { - display: none; - } - .header-content { - flex-direction: column; - } - .logo { - margin-bottom: 10px; - } - .input-group { - flex-direction: column; - } - .container { - width: 100%; - padding: 10px; - } - .ad-container img { - width: 100%; - height: auto; - } - } - @media (min-width: 769px) { - .nav-menu { - display: flex; - } - } @@ -247,7 +223,7 @@
- 广告图片 + 广告图片
@@ -268,8 +244,6 @@ // 设置当前年份 document.getElementById('currentYear').textContent = new Date().getFullYear(); - let proxyDomain = 'your_domain'; // 默认代理加速地址 - // 生成加速命令 function generateCommands() { const imageInput = document.getElementById('imageInput').value.trim(); @@ -277,6 +251,8 @@ alert('请输入 Docker 镜像'); return; } + // docker镜像加速地址,请把下面your_domain改为你实际的加速地址 + const proxyDomain = 'your_domain'; //例如:hub.baidu.com let [imageName, tag] = imageInput.split(':'); tag = tag || 'latest'; @@ -306,7 +282,8 @@ cmdDiv.className = 'step'; cmdDiv.innerHTML = `

${index + 1}. ${command.title}

-
${command.cmd}
+
${command.cmd}
+ `; container.appendChild(cmdDiv); }); @@ -333,46 +310,6 @@ behavior: 'smooth' }); } - - // 获取并加载配置 - async function loadConfig() { - try { - const response = await fetch('/api/config'); - const config = await response.json(); - if (config.logo) { - document.querySelector('.logo').src = config.logo; - } - if (config.menuItems && Array.isArray(config.menuItems)) { - const navMenu = document.querySelector('.nav-menu'); - navMenu.innerHTML = ''; // 清空菜单 - config.menuItems.forEach(item => { - const a = document.createElement('a'); - a.href = item.link; - a.textContent = item.text; - if (item.newTab) { - a.target = '_blank'; - } - navMenu.appendChild(a); - }); - } - if (config.adImage && config.adImage.url) { - const adContainer = document.getElementById('adContainer'); - const adLink = adContainer.querySelector('a'); - const adImage = adContainer.querySelector('img'); - adLink.href = config.adImage.link; - adImage.src = config.adImage.url; - adImage.alt = config.adImage.alt || '广告图片'; - adContainer.style.display = 'flex'; - } - if (config.proxyDomain) { - proxyDomain = config.proxyDomain; - } - } catch (error) { - console.error('加载配置失败:', error); - } - } - - loadConfig(); \ No newline at end of file diff --git a/hubcmdui/package.json b/hubcmdui/package.json deleted file mode 100644 index fe22126..0000000 --- a/hubcmdui/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "dependencies": { - "express": "^4.19.2", - "express-session": "^1.18.0" - } -} diff --git a/hubcmdui/server.js b/hubcmdui/server.js deleted file mode 100644 index 2756a54..0000000 --- a/hubcmdui/server.js +++ /dev/null @@ -1,140 +0,0 @@ -// server.js -const express = require('express'); -const fs = require('fs').promises; -const path = require('path'); -const bodyParser = require('body-parser'); -const session = require('express-session'); - -const app = express(); -app.use(express.json()); -app.use(express.static('web')); -app.use(bodyParser.urlencoded({ extended: true })); -app.use(session({ - secret: 'OhTq3faqSKoxbV%NJV', - resave: false, - saveUninitialized: true, - cookie: { secure: false } // 设置为true如果使用HTTPS -})); - -app.get('/admin', (req, res) => { - res.sendFile(path.join(__dirname, 'web', 'admin.html')); -}); - -const CONFIG_FILE = path.join(__dirname, 'config.json'); -const USERS_FILE = path.join(__dirname, 'users.json'); - -// 读取配置 -async function readConfig() { - try { - const data = await fs.readFile(CONFIG_FILE, 'utf8'); - return JSON.parse(data); - } catch (error) { - if (error.code === 'ENOENT') { - return { - logo: '', - menuItems: [], - adImage: { url: '', link: '' } - }; - } - throw error; - } -} - -// 写入配置 -async function writeConfig(config) { - await fs.writeFile(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8'); -} - -// 读取用户 -async function readUsers() { - try { - const data = await fs.readFile(USERS_FILE, 'utf8'); - return JSON.parse(data); - } catch (error) { - if (error.code === 'ENOENT') { - return { - users: [{ username: 'root', password: 'admin' }] - }; - } - throw error; - } -} - -// 写入用户 -async function writeUsers(users) { - await fs.writeFile(USERS_FILE, JSON.stringify(users, null, 2), 'utf8'); -} - -// 登录验证 -app.post('/api/login', async (req, res) => { - const { username, password } = req.body; - const users = await readUsers(); - const user = users.users.find(u => u.username === username && u.password === password); - if (user) { - req.session.user = user; - res.json({ success: true }); - } else { - res.status(401).json({ error: 'Invalid credentials' }); - } -}); - -// 修改密码 -app.post('/api/change-password', async (req, res) => { - if (!req.session.user) { - return res.status(401).json({ error: 'Not logged in' }); - } - const { currentPassword, newPassword } = req.body; - const users = await readUsers(); - const user = users.users.find(u => u.username === req.session.user.username); - if (user && user.password === currentPassword) { - user.password = newPassword; - await writeUsers(users); - res.json({ success: true }); - } else { - res.status(401).json({ error: 'Invalid current password' }); - } -}); - -// 需要登录验证的中间件 -function requireLogin(req, res, next) { - if (req.session.user) { - next(); - } else { - res.status(401).json({ error: 'Not logged in' }); - } -} - -// API 端点:获取配置 -app.get('/api/config', requireLogin, async (req, res) => { - try { - const config = await readConfig(); - res.json(config); - } catch (error) { - res.status(500).json({ error: 'Failed to read config' }); - } -}); - -// API 端点:保存配置 -app.post('/api/config', requireLogin, async (req, res) => { - try { - await writeConfig(req.body); - res.json({ success: true }); - } catch (error) { - res.status(500).json({ error: 'Failed to save config' }); - } -}); - -// API 端点:检查会话状态 -app.get('/api/check-session', (req, res) => { - if (req.session.user) { - res.json({ success: true }); - } else { - res.status(401).json({ error: 'Not logged in' }); - } -}); - -// 启动服务器 -const PORT = process.env.PORT || 3000; -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); \ No newline at end of file diff --git a/hubcmdui/users.json b/hubcmdui/users.json deleted file mode 100644 index 8759e56..0000000 --- a/hubcmdui/users.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "users": [ - { - "username": "root", - "password": "admin" - } - ] -} \ No newline at end of file diff --git a/hubcmdui/web/admin.html b/hubcmdui/web/admin.html deleted file mode 100644 index d666541..0000000 --- a/hubcmdui/web/admin.html +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - Docker 镜像代理加速 - 管理面板 - - - - - - -
-
-

登录

- - - - - -
-
- - - - \ No newline at end of file