refactor(App): 移除服务器地址和自动启动配置功能

- 注释掉 serverUrl 相关的响应式变量定义
- 注释掉 autoStart 相关的响应式变量定义
- 移除进度列表中的测试数据注释
- 注释掉服务器地址验证逻辑
- 注释掉服务器地址和自动启动的写入配置函数
- 注释掉配置加载中的相关字段赋值
- 在模板中隐藏服务器地址输入框和自动启动复选框组件
This commit is contained in:
2026-04-30 20:37:05 +08:00
parent 6952c33f16
commit 6bd82024d9
3 changed files with 42 additions and 40 deletions
+7 -7
View File
@@ -45,12 +45,12 @@ func (a *App) startup(ctx context.Context) {
}() }()
//在程序启动时运行上传程序 //在程序启动时运行上传程序
if config.APPConfig.IsRunOnStart { //if config.APPConfig.IsRunOnStart {
time.Sleep(time.Second) // time.Sleep(time.Second)
a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx) // a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx)
go uploader.StartUpload(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir) // go uploader.StartUpload(a.uploaderCTX, &a.logChan)
a.isRun = true // a.isRun = true
} //}
} }
// SelectPath 打开选择路径弹框 // SelectPath 打开选择路径弹框
@@ -74,7 +74,7 @@ func (a *App) StartUpload() {
return return
} }
a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx) a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx)
go uploader.StartUpload(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir) go uploader.StartUpload(a.uploaderCTX, &a.logChan)
a.isRun = true a.isRun = true
} }
+22 -23
View File
@@ -7,12 +7,12 @@ import {config} from "../wailsjs/go/models.ts";
import Config = config.Config; import Config = config.Config;
import {EventsOn, LogPrint} from "../wailsjs/runtime"; import {EventsOn, LogPrint} from "../wailsjs/runtime";
const serverUrl = ref('') // const serverUrl = ref('')
const token = ref('') const token = ref('')
const checkDir = ref('') const checkDir = ref('')
const concurrentFiles = ref(1) const concurrentFiles = ref(1)
const uploadThreads = ref(1) const uploadThreads = ref(1)
const autoStart = ref(false) // const autoStart = ref(false)
const isRunning = ref(false) const isRunning = ref(false)
const logOutput = ref<string[]>([]) const logOutput = ref<string[]>([])
@@ -26,9 +26,8 @@ interface FileProgress {
percentage: number percentage: number
} }
const progressList = ref<FileProgress[]>([
// {name: '测试文件1.txt', uploaded: 100, total: 500, percentage: 20}, // {name: '测试文件1.txt', uploaded: 100, total: 500, percentage: 20},
]) const progressList = ref<FileProgress[]>([])
const sortedProgressList = computed(() => { const sortedProgressList = computed(() => {
return [...progressList.value].sort((a, b) => { return [...progressList.value].sort((a, b) => {
@@ -58,10 +57,10 @@ const selectDirectory = () => {
} }
const startRun = () => { const startRun = () => {
if (!serverUrl.value) { // if (!serverUrl.value) {
ElMessage.warning('请输入服务器地址') // ElMessage.warning('请输入服务器地址')
return // return
} // }
if (!token.value) { if (!token.value) {
ElMessage.warning('请输入Token') ElMessage.warning('请输入Token')
return return
@@ -93,9 +92,9 @@ const clearLog = () => {
}) })
} }
const writeServerUrl =() => { // const writeServerUrl =() => {
WriteConfig("url", serverUrl.value) // WriteConfig("url", serverUrl.value)
} // }
const writeToken =() => { const writeToken =() => {
WriteConfig("token", token.value) WriteConfig("token", token.value)
} }
@@ -108,19 +107,19 @@ const writeConcurrentFiles = () => {
const writeUploadThreads =() => { const writeUploadThreads =() => {
WriteConfig("thread-count", uploadThreads.value) WriteConfig("thread-count", uploadThreads.value)
} }
const writeAutoStart = () => { // const writeAutoStart = () => {
WriteConfig("is-run-on-start", autoStart.value) // WriteConfig("is-run-on-start", autoStart.value)
} // }
// 加载配置 // 加载配置
try { try {
GetConfig().then((config: Config) => { GetConfig().then((config: Config) => {
serverUrl.value = config.url // serverUrl.value = config.url
token.value = config.token token.value = config.token
checkDir.value = config.check_dir checkDir.value = config.check_dir
concurrentFiles.value = config.handle_file_count concurrentFiles.value = config.handle_file_count
uploadThreads.value = config.thread_count uploadThreads.value = config.thread_count
autoStart.value = config.is_run_on_start // autoStart.value = config.is_run_on_start
LogPrint(`[${new Date().toLocaleString()}] 配置已加载`) LogPrint(`[${new Date().toLocaleString()}] 配置已加载`)
}) })
@@ -142,10 +141,10 @@ EventsOn("log", (msg) => {
<template> <template>
<div class="container"> <div class="container">
<div class="left-panel"> <div class="left-panel">
<div class="form-item"> <!-- <div class="form-item">-->
<label>服务器地址</label> <!-- <label>服务器地址</label>-->
<el-input v-model="serverUrl" placeholder="请输入服务器地址" :disabled="isRunning" @change="writeServerUrl()"/> <!-- <el-input v-model="serverUrl" placeholder="请输入服务器地址" :disabled="isRunning" @change="writeServerUrl()"/>-->
</div> <!-- </div>-->
<div class="form-item"> <div class="form-item">
<label>Token</label> <label>Token</label>
@@ -170,9 +169,9 @@ EventsOn("log", (msg) => {
<el-input-number v-model="uploadThreads" :min="1" :max="100" :disabled="isRunning" @change="writeUploadThreads()"/> <el-input-number v-model="uploadThreads" :min="1" :max="100" :disabled="isRunning" @change="writeUploadThreads()"/>
</div> </div>
<div class="form-item"> <!-- <div class="form-item">-->
<el-checkbox v-model="autoStart" label="运行时自动启动上传" size="large" :disabled="isRunning" @change="writeAutoStart()"/> <!-- <el-checkbox v-model="autoStart" label="运行时自动启动上传" size="large" :disabled="isRunning" @change="writeAutoStart()"/>-->
</div> <!-- </div>-->
<div class="form-item"> <div class="form-item">
<label>上传进度</label> <label>上传进度</label>
+12 -9
View File
@@ -20,8 +20,6 @@ import (
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
) )
var progress sync.Map
type Task struct { type Task struct {
FilePath string FilePath string
FileLines int FileLines int
@@ -34,7 +32,9 @@ type Progress struct {
Percentage int `json:"percentage"` Percentage int `json:"percentage"`
} }
func StartUpload(ctx context.Context, logChan *chan string, lookingPath string) { var progress sync.Map
func StartUpload(ctx context.Context, logChan *chan string) {
AddLog(logChan, "===============================================") AddLog(logChan, "===============================================")
AddLog(logChan, `服务器: `+config.APPConfig.Url) AddLog(logChan, `服务器: `+config.APPConfig.Url)
AddLog(logChan, `Token: `+config.APPConfig.Token) AddLog(logChan, `Token: `+config.APPConfig.Token)
@@ -70,7 +70,7 @@ func StartUpload(ctx context.Context, logChan *chan string, lookingPath string)
//开启上传程序 //开启上传程序
for { for {
uploadData(ctx, logChan, lookingPath) uploadData(ctx, logChan)
select { select {
case <-time.After(time.Minute): case <-time.After(time.Minute):
case <-ctx.Done(): case <-ctx.Done():
@@ -79,11 +79,11 @@ func StartUpload(ctx context.Context, logChan *chan string, lookingPath string)
} }
} }
func uploadData(ctx context.Context, logChan *chan string, lookingPath string) { func uploadData(ctx context.Context, logChan *chan string) {
// 获取检测目录
var path = "./" var path = "./"
if lookingPath != "" { if config.APPConfig.CheckDir != "" {
path = lookingPath path = config.APPConfig.CheckDir
} }
//获取文件列表 //获取文件列表
@@ -97,6 +97,7 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
} }
start := time.Now() start := time.Now()
//检测到文件 //检测到文件
//统计文件行数 //统计文件行数
fileLines := make(map[string]int) fileLines := make(map[string]int)
@@ -111,6 +112,7 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
if err != nil { if err != nil {
AddLog(logChan, "打开文件失败:"+err.Error()) AddLog(logChan, "打开文件失败:"+err.Error())
} }
// 使用 bufio.Scanner 逐行读取 // 使用 bufio.Scanner 逐行读取
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
lineCount := 0 lineCount := 0
@@ -127,6 +129,7 @@ func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
AddLog(logChan, fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount)) AddLog(logChan, fmt.Sprintf("%s 文件行数:%v", filepath.Base(filePath), lineCount))
} }
} }
if isAllEmpty { if isAllEmpty {
AddLog(logChan, "所有文件都为空,不进行上传") AddLog(logChan, "所有文件都为空,不进行上传")
return return
@@ -196,7 +199,7 @@ func getTxtFiles(dir string) (txtFiles []string, err error) {
return err return err
} }
// 只处理普通文件,跳过目录 // 跳过目录,只处理普通文件
if !info.Mode().IsRegular() { if !info.Mode().IsRegular() {
return nil return nil
} }