diff --git a/CHANGELOG.md b/CHANGELOG.md
index aef0599..18ba301 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# 更新日志
+24w15d
+---
+- PRE-RELEASE: 此版本是v1.5.0的预发布版本,请勿在生产环境中使用
+- CHANGE: 优化代码结构,提升性能
+- ADD: 新增API模块,新增配置开关状态接口,以在前端指示功能状态
+- CHANGE: 由于API变动,对前端进行相应调整
+
24w15c
---
- PRE-RELEASE: 此版本是v1.5.0的预发布版本,请勿在生产环境中使用
diff --git a/api/api.go b/api/api.go
index 11a2f3d..b30d80b 100644
--- a/api/api.go
+++ b/api/api.go
@@ -42,10 +42,12 @@ func InitHandleRouter(cfg *config.Config, router *gin.Engine) {
}
func SizeLimitHandler(cfg *config.Config, c *gin.Context) {
+ // 转换为MB
+ sizeLimit := cfg.Server.SizeLimit / 1024 / 1024
// 设置响应头
c.Writer.Header().Set("Content-Type", "application/json")
json.NewEncoder(c.Writer).Encode(map[string]interface{}{
- "MaxResponseBodySize": cfg.Server.SizeLimit,
+ "MaxResponseBodySize": sizeLimit,
})
}
diff --git a/pages/index.html b/pages/index.html
index 4987c93..ac42dd9 100644
--- a/pages/index.html
+++ b/pages/index.html
@@ -91,6 +91,18 @@
}
+ .status-container {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin-bottom: 5px;
+ }
+
+ .status-container p {
+ margin: 0px 5px;
+ }
+
+
.code {
position: relative;
padding-right: 0px;
@@ -136,7 +148,11 @@
GitHub链接带不带协议头均可,支持release、archive以及文件,转换后链接均可使用。
-
文件大小限制: ...
+
+
文件大小限制: ...
+
白名单状态: ...
+
黑名单状态: ...
+
@@ -173,19 +189,57 @@
alert('链接已复制到剪贴板');
});
- function fetchAPI() {
- fetch(window.location.origin + '/api')
+ function fetchSizeLimit() {
+ fetch(window.location.origin + '/api/size_limit')
.then(response => response.json())
.then(data => {
const sizeLimitDisplay = document.getElementById('sizeLimitDisplay');
- const sizeInMB = (data.MaxResponseBodySize / (1024 * 1024)).toFixed(0);
- sizeLimitDisplay.textContent = `文件大小限制: ${sizeInMB} MB`;
+ sizeLimitDisplay.textContent = `文件大小限制: ${data.MaxResponseBodySize} MB`;
})
.catch(error => {
console.error('Error fetching API:', error);
});
}
+ function fetchWhiteList() {
+ fetch(window.location.origin + '/api/whitelist/status')
+ .then(response => response.json())
+ .then(data => {
+ const whiteListStatus = document.getElementById('whiteListStatus');
+ if (data.Whitelist) {
+ whiteListStatus.textContent = `白名单状态: 已开启`;
+ } else if (!data.Whitelist) {
+ whiteListStatus.textContent = `白名单状态: 已关闭`;
+ } else {
+ whiteListStatus.textContent = `白名单状态: 未知`;
+ }
+ })
+ .catch(error => {
+ console.error('Error fetching API:', error);
+ });
+ }
+ function fetchBlackList() {
+ fetch(window.location.origin + '/api/blacklist/status')
+ .then(response => response.json())
+ .then(data => {
+ const blackListStatus = document.getElementById('blackListStatus');
+ if (data.Blacklist) {
+ blackListStatus.textContent = `黑名单状态: 已开启`;
+ } else if (!data.Blacklist) {
+ blackListStatus.textContent = `黑名单状态: 已关闭`;
+ } else {
+ blackListStatus.textContent = `黑名单状态: 未知`;
+ }
+ })
+ .catch(error => {
+ console.error('Error fetching API:', error);
+ });
+ }
+ function fetchAPI() {
+ fetchSizeLimit();
+ fetchWhiteList();
+ fetchBlackList();
+ }
document.addEventListener('DOMContentLoaded', fetchAPI);