Skip to content

Commit 6ac1bb4

Browse files
author
V2RaySSR综合网
committed
修复横幅显示顺序:确保所有打印都在横幅之后显示
- 将横幅显示移到main.go中,程序启动时首先显示 - 数据文件下载信息显示在横幅下面,带时间戳 - 移除子命令中的横幅显示,避免重复 - 修复热门网站检测逻辑,支持www.前缀匹配 - 确保所有错误信息和输出都在横幅之后显示
1 parent 1014c8c commit 6ac1bb4

File tree

8 files changed

+70
-8
lines changed

8 files changed

+70
-8
lines changed

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# 编译后的可执行文件
2+
reality-checker
3+
reality-checker.exe
4+
reality-checker-linux-amd64
5+
reality-checker-windows-amd64.exe
6+
reality-checker-darwin-amd64
7+
reality-checker-linux-arm64
8+
9+
# 项目状态文档(本地开发用)
10+
PROJECT_STATUS.md
11+
12+
# 子项目目录
13+
reality-checker-go/
14+
15+
# Cursor IDE配置
16+
.cursor/
17+
18+
# 系统文件
19+
.DS_Store
20+
Thumbs.db
21+
22+
# 临时文件
23+
*.tmp
24+
*.log
25+
*.swp
26+
*.swo
27+
*~
28+
29+
# IDE配置
30+
.vscode/
31+
.idea/
32+
*.iml
33+
34+
# Go相关
35+
vendor/
36+
*.test
37+
*.prof
38+
39+
# 配置文件(可选)
40+
config.yaml

internal/cmd/batch.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ func (r *RootCmd) executeBatch(domainsStr string) {
2020
return
2121
}
2222

23-
ui.PrintBanner()
24-
25-
// 显示重复域名警告(在横幅下面)
23+
// 显示重复域名警告
2624
if len(duplicateDomains) > 0 {
2725
ui.PrintTimestampedMessage("警告:发现 %d 个重复域名,已去重:", len(duplicateDomains))
2826

internal/cmd/check.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func (r *RootCmd) executeCheck(domain string) {
2828
return
2929
}
3030

31-
ui.PrintBanner()
3231
ui.PrintTimestampedMessage("开始检测域名: %s", domain)
3332

3433
result, err := r.engine.CheckDomain(r.ctx, domain)

internal/cmd/csv.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func (r *RootCmd) executeCSV(csvFile string) {
7777
fmt.Printf(" ... 还有 %d 个域名\n", len(domains)-previewCount)
7878
}
7979
fmt.Println("")
80-
ui.PrintBanner()
8180
ui.PrintTimestampedMessage("开始批量检测...")
8281

8382
_, err = r.batchManager.CheckDomains(r.ctx, domains)

internal/cmd/root.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ func (r *RootCmd) Execute() {
110110
fmt.Printf("错误:未知命令 '%s'\n", os.Args[1])
111111
fmt.Println("可用命令: check, batch, csv, version")
112112
fmt.Println()
113-
ui.PrintUsage()
114-
fmt.Println()
115113
os.Exit(1)
116114
}
117115
}

internal/data/downloader.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,17 @@ func NewDownloader() *Downloader {
3131
}
3232
}
3333

34+
// printTimestampedMessage 打印带时间戳的消息
35+
func printTimestampedMessage(format string, args ...interface{}) {
36+
timestamp := time.Now().Format("15:04:05")
37+
message := fmt.Sprintf(format, args...)
38+
fmt.Printf("[%s] %s\n", timestamp, message)
39+
}
40+
3441
// EnsureDataFiles 确保所有数据文件存在且最新
3542
func (d *Downloader) EnsureDataFiles() error {
43+
printTimestampedMessage("检查数据文件...")
44+
3645
// 定义需要下载的文件
3746
files := []DataFile{
3847
{
@@ -69,6 +78,7 @@ func (d *Downloader) EnsureDataFiles() error {
6978
}
7079
}
7180

81+
printTimestampedMessage("数据文件检查完成。")
7282
return nil
7383
}
7484

@@ -82,6 +92,7 @@ func (d *Downloader) ensureFile(file DataFile) error {
8292

8393
// 如果文件不存在,直接下载
8494
if !exists {
95+
printTimestampedMessage("下载 %s...", file.Name)
8596
return d.downloadWithRetry(file)
8697
}
8798

@@ -93,6 +104,7 @@ func (d *Downloader) ensureFile(file DataFile) error {
93104

94105
// 如果需要更新,下载新文件
95106
if needsUpdate {
107+
printTimestampedMessage("更新 %s...", file.Name)
96108
return d.downloadWithRetry(file)
97109
}
98110

internal/detectors/hot_website.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,19 @@ func (hws *HotWebsiteStage) detectHotWebsite(domain string) bool {
4747
domain = strings.ToLower(domain)
4848

4949
// 检查是否为热门网站
50-
return hws.hotWebsites[domain]
50+
if hws.hotWebsites[domain] {
51+
return true
52+
}
53+
54+
// 如果域名以www.开头,也检查去掉www.的版本
55+
if strings.HasPrefix(domain, "www.") {
56+
domainWithoutWWW := domain[4:]
57+
return hws.hotWebsites[domainWithoutWWW]
58+
}
59+
60+
// 如果域名不以www.开头,也检查加上www.的版本
61+
domainWithWWW := "www." + domain
62+
return hws.hotWebsites[domainWithWWW]
5163
}
5264

5365
// loadHotWebsites 加载热门网站列表

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ import (
66

77
"RealityChecker/internal/cmd"
88
"RealityChecker/internal/data"
9+
"RealityChecker/internal/ui"
910
)
1011

1112
func main() {
13+
// 首先显示横幅
14+
ui.PrintBanner()
15+
1216
// 检查并下载必要的数据文件
1317
downloader := data.NewDownloader()
1418
if err := downloader.EnsureDataFiles(); err != nil {

0 commit comments

Comments
 (0)