From 5d2fc5ca25b6a857284110ad7463eec9b7b31c6d Mon Sep 17 00:00:00 2001 From: dqzboy Date: Sat, 24 Aug 2024 21:42:06 +0800 Subject: [PATCH] feat: Add image search functionality. --- README.en.md | 4 +- README.md | 4 +- hubcmdui/README.md | 12 +- hubcmdui/package.json | 1 + hubcmdui/server.js | 17 +++ hubcmdui/web/index.html | 236 ++++++++++++++++++++++++++++++++++++++-- 6 files changed, 255 insertions(+), 19 deletions(-) diff --git a/README.en.md b/README.en.md index a8f5b47..c90202c 100644 --- a/README.en.md +++ b/README.en.md @@ -128,7 +128,7 @@ docker logs -f [Container ID or Name] - [x] Automatically checks for and installs required dependency software such as Docker, Nginx/Caddy, etc., and ensures the system environment meets the operational requirements. - [x] Automatically renders the corresponding Nginx or Caddy service configuration based on the service you choose to deploy. - [x] Automatically cleans up files in the registry upload directory that are no longer referenced by any image or manifest. -- [x] Support custom configuration of proxy cache time(PROXY_TTL) +- [x] Support custom configuration of proxy cache time(PROXY_TTL)、Support configuring IP whitelist and blacklist to prevent malicious attacks. - [x] Provides features for restarting services, updating services, updating configurations, and uninstalling services, making it convenient for users to perform daily management and maintenance. - [x] Supports user selection of whether to provide authentication during deployment. - [x] Supports configuration of proxy (HTTP_PROXY), only supports HTTP. @@ -212,7 +212,7 @@ docker pull gcr.your_domain_name/google-containers/pause:3.1 - + diff --git a/README.md b/README.md index 2a3ec1c..19686e0 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ docker pull gcr.your_domain_name/google-containers/pause:3.1 -## 💻 UI +## 💻 UI界面 > HubCMD-UI 手动安装教程:[点击查看教程](hubcmdui/README.md) @@ -222,7 +222,7 @@ docker pull gcr.your_domain_name/google-containers/pause:3.1 - + diff --git a/hubcmdui/README.md b/hubcmdui/README.md index 0b498e5..476ab29 100644 --- a/hubcmdui/README.md +++ b/hubcmdui/README.md @@ -6,7 +6,7 @@


- Docker-Proxy 镜像代理加速快速获取命令UI面板. + Docker镜像加速命令查询获取和镜像搜索UI面板.

@@ -91,13 +91,19 @@ docker logs -f [容器ID或名称] - +
- + + +
+ + + +
diff --git a/hubcmdui/package.json b/hubcmdui/package.json index 8175ae0..3359ce8 100644 --- a/hubcmdui/package.json +++ b/hubcmdui/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "axios": "^1.7.5", "bcrypt": "^5.1.1", "express": "^4.19.2", "express-session": "^1.18.0", diff --git a/hubcmdui/server.js b/hubcmdui/server.js index 436e0f5..d6df83b 100644 --- a/hubcmdui/server.js +++ b/hubcmdui/server.js @@ -6,6 +6,7 @@ const session = require('express-session'); const bcrypt = require('bcrypt'); const crypto = require('crypto'); const logger = require('morgan'); // 引入 morgan 作为日志工具 +const axios = require('axios'); // 用于发送 HTTP 请求 const app = express(); app.use(express.json()); @@ -23,6 +24,22 @@ app.get('/admin', (req, res) => { res.sendFile(path.join(__dirname, 'web', 'admin.html')); }); +// 新增:Docker Hub 搜索 API +app.get('/api/search', async (req, res) => { + const searchTerm = req.query.term; + if (!searchTerm) { + return res.status(400).json({ error: 'Search term is required' }); + } + + try { + const response = await axios.get(`https://hub.docker.com/v2/search/repositories/?query=${encodeURIComponent(searchTerm)}`); + res.json(response.data); + } catch (error) { + console.error('Error searching Docker Hub:', error); + res.status(500).json({ error: 'Failed to search Docker Hub' }); + } +}); + const CONFIG_FILE = path.join(__dirname, 'config.json'); const USERS_FILE = path.join(__dirname, 'users.json'); diff --git a/hubcmdui/web/index.html b/hubcmdui/web/index.html index f767ffb..be823f5 100644 --- a/hubcmdui/web/index.html +++ b/hubcmdui/web/index.html @@ -314,6 +314,88 @@ transition: opacity 0.5s ease-in-out; z-index: 1000; } + + /* 搜索样式 */ + .search-container { + margin-top: 20px; + } + #searchResults { + margin-top: 20px; + display: none; + } + .search-result-item { + border: 1px solid #e1e4e8; + border-radius: 6px; + padding: 10px; + margin-bottom: 10px; + } + .search-result-item h3 { + margin-top: 0; + } + .search-result-item p { + margin-bottom: 5px; + } + .use-image-btn { + background-color: #0366d6; + color: white; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + } + .use-image-btn:hover { + background-color: #0256b9; + } + .official-image { + background-color: #e6f3ff; + border-left: 5px solid #0366d6; + padding-left: 15px; + } + .search-result-item { + margin-bottom: 15px; + padding: 10px; + border: 1px solid #e1e4e8; + border-radius: 6px; + } + .search-result-item h3 { + margin-top: 0; + color: #0366d6; + } + .official-badge { + background-color: #28a745; + color: white; + padding: 2px 5px; + border-radius: 3px; + font-size: 12px; + margin-left: 10px; + } + .stars { + color: #586069; + font-size: 14px; + } + .tab-container { + display: flex; + justify-content: center; + margin-bottom: 20px; + } + .tab { + padding: 10px 20px; + cursor: pointer; + border: 1px solid #d1d5da; + background-color: #f6f8fa; + color: #24292e; + } + .tab.active { + background-color: #0366d6; + color: white; + border-color: #0366d6; + } + .content { + display: none; + } + .content.active { + display: block; + } @@ -329,13 +411,38 @@ +
-

Docker 镜像代理加速

-
- - +

Docker 镜像加速和镜像搜索

+ +
+
镜像加速
+
镜像搜索
+ + +
+
+ + +
+ + +
+ + +
+
+ + +
+
+
+