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