update
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# 优化设置界面实现计划
|
||||
|
||||
## 问题分析
|
||||
当前设置界面存在配置项重复问题,需要进行优化,具体包括:
|
||||
1. "远程规则URL"配置项在多个界面重复出现
|
||||
2. "启用API"和"主机"选项不需要在当前界面显示
|
||||
3. 需要确保保存功能正常工作,写入config.json并触发服务器重新加载配置
|
||||
|
||||
## 优化方案
|
||||
|
||||
### 1. 修改HTML结构
|
||||
- 移除"远程规则URL"配置项
|
||||
- 移除"启用API"选项
|
||||
- 移除"主机"选项
|
||||
- 调整布局,确保界面美观合理
|
||||
|
||||
### 2. 更新JavaScript代码
|
||||
- 修改`populateConfigForm`函数,移除对已删除配置项的处理
|
||||
- 修改`collectFormData`函数,移除对已删除配置项的收集
|
||||
- 确保保存功能能正确写入config.json文件
|
||||
- 实现服务器重新加载配置的触发机制
|
||||
- 提供明确的成功/失败反馈
|
||||
|
||||
### 3. 测试和验证
|
||||
- 测试所有保留配置项的加载和保存功能
|
||||
- 验证保存操作能正确写入config.json文件
|
||||
- 验证服务器能重新加载配置
|
||||
- 测试成功/失败反馈是否明确
|
||||
|
||||
## 具体实现步骤
|
||||
|
||||
1. **修改HTML结构**
|
||||
- 编辑`index.html`文件,移除不需要的配置项
|
||||
- 调整布局,确保界面美观合理
|
||||
|
||||
2. **更新JavaScript代码**
|
||||
- 编辑`config.js`文件,修改`populateConfigForm`函数
|
||||
- 修改`collectFormData`函数,移除对已删除配置项的处理
|
||||
- 确保`handleSaveConfig`函数能正确保存配置
|
||||
- 实现服务器重新加载配置的触发机制
|
||||
|
||||
3. **测试和验证**
|
||||
- 测试配置项的加载功能
|
||||
- 测试配置项的保存功能
|
||||
- 验证config.json文件是否正确更新
|
||||
- 验证服务器是否重新加载配置
|
||||
- 测试成功/失败反馈是否明确
|
||||
|
||||
## 预期效果
|
||||
- 设置界面布局合理,无重复配置项
|
||||
- 所有保留配置项均可正常配置
|
||||
- 保存功能能正确写入config.json文件
|
||||
- 服务器能重新加载配置,使更改立即生效
|
||||
- 保存操作有明确的成功/失败反馈
|
||||
|
||||
## 技术要点
|
||||
- 使用HTML和JavaScript修改界面结构和功能
|
||||
- 确保与服务器API的正确交互
|
||||
- 实现良好的用户反馈机制
|
||||
- 确保配置的正确保存和加载
|
||||
|
||||
## 实现时间
|
||||
- 预计1-2小时完成所有修改和测试
|
||||
|
||||
## 风险评估
|
||||
- 低风险:修改范围明确,不涉及核心功能
|
||||
- 可回滚:所有修改均为前端修改,可通过恢复文件轻松回滚
|
||||
|
||||
## 依赖关系
|
||||
- 依赖服务器API的正常工作
|
||||
- 依赖config.json文件的读写权限
|
||||
|
||||
## 测试策略
|
||||
- 手动测试所有配置项的加载和保存功能
|
||||
- 验证config.json文件的更新
|
||||
- 测试服务器配置的重新加载
|
||||
- 测试成功/失败反馈
|
||||
|
||||
## 验收标准
|
||||
- 设置界面布局合理,无重复配置项
|
||||
- 所有保留配置项均可正常配置
|
||||
- 保存功能能正确写入config.json文件
|
||||
- 服务器能重新加载配置,使更改立即生效
|
||||
- 保存操作有明确的成功/失败反馈
|
||||
+22
-4
@@ -16,11 +16,29 @@
|
||||
},
|
||||
"shield": {
|
||||
"localRulesFile": "data/rules.txt",
|
||||
"remoteRules": [
|
||||
"https://example.com/rules.txt",
|
||||
"https://gitea.amazehome.xyz/AMAZEHOME/hosts-and-filters/raw/branch/main/rules/costomize.txt"
|
||||
"blacklists": [
|
||||
{
|
||||
"name": "AdGuard DNS filter",
|
||||
"url": "https://gitea.amazehome.xyz/AMAZEHOME/hosts-and-filters/raw/branch/main/filter.txt",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "Adaway Default Blocklist",
|
||||
"url": "https://gitea.amazehome.xyz/AMAZEHOME/hosts-and-Filters/raw/branch/main/hosts/adaway.txt",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "CHN-anti-AD",
|
||||
"url": "https://gitea.amazehome.xyz/AMAZEHOME/hosts-and-Filters/raw/branch/main/list/easylist.txt",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "My GitHub Rules",
|
||||
"url": "https://gitea.amazehome.xyz/AMAZEHOME/hosts-and-filters/raw/branch/main/rules/costomize.txt",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"updateInterval": 60,
|
||||
"updateInterval": 3600,
|
||||
"hostsFile": "data/hosts.txt",
|
||||
"blockMethod": "NXDOMAIN",
|
||||
"customBlockIP": "",
|
||||
|
||||
-10607
File diff suppressed because it is too large
Load Diff
-82585
File diff suppressed because it is too large
Load Diff
-53291
File diff suppressed because it is too large
Load Diff
-1176
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"blockedDomainsCount": {},
|
||||
"resolvedDomainsCount": {},
|
||||
"lastSaved": "2025-11-27T01:36:58.774730083+08:00"
|
||||
}
|
||||
-2857
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
-2085
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -713,14 +713,6 @@
|
||||
<label for="http-port" class="block text-sm font-medium text-gray-700 mb-1">端口</label>
|
||||
<input type="number" id="http-port" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="8080">
|
||||
</div>
|
||||
<div>
|
||||
<label for="http-host" class="block text-sm font-medium text-gray-700 mb-1">主机</label>
|
||||
<input type="text" id="http-host" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="0.0.0.0">
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" id="http-api-enabled" class="h-4 w-4 text-primary border-gray-300 rounded focus:ring-primary">
|
||||
<label for="http-api-enabled" class="ml-2 block text-sm font-medium text-gray-700">启用API</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -750,10 +742,6 @@
|
||||
<option value="customIP">返回自定义IP</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label for="shield-remote-rules-urls" class="block text-sm font-medium text-gray-700 mb-1">远程规则URL (每行一个)</label>
|
||||
<textarea id="shield-remote-rules-urls" rows="4" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="https://example.com/rules.txt"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+4
-10
@@ -27,12 +27,9 @@ function populateConfigForm(config) {
|
||||
|
||||
// HTTP配置
|
||||
document.getElementById('http-port')?.value = config.HTTPServer.Port || 8080;
|
||||
document.getElementById('http-host')?.value = config.HTTPServer.Host || '0.0.0.0';
|
||||
document.getElementById('http-api-enabled')?.checked = config.HTTPServer.APIEnabled !== false;
|
||||
|
||||
// 屏蔽配置
|
||||
document.getElementById('shield-local-rules-file')?.value = config.Shield.LocalRulesFile || './rules.txt';
|
||||
document.getElementById('shield-remote-rules-urls')?.value = (config.Shield.RemoteRulesURLs || []).join('\n');
|
||||
document.getElementById('shield-update-interval')?.value = config.Shield.UpdateInterval || 3600;
|
||||
document.getElementById('shield-hosts-file')?.value = config.Shield.HostsFile || '/etc/hosts';
|
||||
document.getElementById('shield-block-method')?.value = config.Shield.BlockMethod || '0.0.0.0';
|
||||
@@ -69,19 +66,16 @@ function collectFormData() {
|
||||
Port: parseInt(document.getElementById('dns-port')?.value) || 53,
|
||||
UpstreamServers: document.getElementById('dns-upstream-servers')?.value.split(',').map(s => s.trim()).filter(Boolean) || [],
|
||||
Timeout: parseInt(document.getElementById('dns-timeout')?.value) || 5,
|
||||
StatsFile: document.getElementById('dns-stats-file')?.value || './stats.json',
|
||||
StatsFile: document.getElementById('dns-stats-file')?.value || './data/stats.json',
|
||||
SaveInterval: parseInt(document.getElementById('dns-save-interval')?.value) || 300
|
||||
},
|
||||
HTTPServer: {
|
||||
Port: parseInt(document.getElementById('http-port')?.value) || 8080,
|
||||
Host: document.getElementById('http-host')?.value || '0.0.0.0',
|
||||
APIEnabled: document.getElementById('http-api-enabled')?.checked !== false
|
||||
Port: parseInt(document.getElementById('http-port')?.value) || 8080
|
||||
},
|
||||
Shield: {
|
||||
LocalRulesFile: document.getElementById('shield-local-rules-file')?.value || './rules.txt',
|
||||
RemoteRulesURLs: document.getElementById('shield-remote-rules-urls')?.value.split('\n').map(s => s.trim()).filter(Boolean) || [],
|
||||
LocalRulesFile: document.getElementById('shield-local-rules-file')?.value || './data/rules.txt',
|
||||
UpdateInterval: parseInt(document.getElementById('shield-update-interval')?.value) || 3600,
|
||||
HostsFile: document.getElementById('shield-hosts-file')?.value || '/etc/hosts',
|
||||
HostsFile: document.getElementById('shield-hosts-file')?.value || './data/hosts.txt',
|
||||
BlockMethod: document.getElementById('shield-block-method')?.value || '0.0.0.0'
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user