feat: add loading check

This commit is contained in:
putyy
2025-09-14 21:40:28 +08:00
committed by putyy
parent f61199bed6
commit 8d55a86c06
7 changed files with 95 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/vrischmann/userdir" "github.com/vrischmann/userdir"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"regexp" "regexp"
"res-downloader/core/shared" "res-downloader/core/shared"
@@ -25,6 +26,7 @@ type App struct {
PublicCrt []byte `json:"-"` PublicCrt []byte `json:"-"`
PrivateKey []byte `json:"-"` PrivateKey []byte `json:"-"`
IsProxy bool `json:"IsProxy"` IsProxy bool `json:"IsProxy"`
IsReset bool `json:"-"`
} }
var ( var (
@@ -51,6 +53,7 @@ func GetApp(assets embed.FS, wjs string) *App {
Version: version, Version: version,
Description: "res-downloader是一款集网络资源嗅探 + 高速下载功能于一体的软件,高颜值、高性能和多样化,提供个人用户下载自己上传到各大平台的网络资源功能!", Description: "res-downloader是一款集网络资源嗅探 + 高速下载功能于一体的软件,高颜值、高性能和多样化,提供个人用户下载自己上传到各大平台的网络资源功能!",
Copyright: "Copyright © 2023~" + strconv.Itoa(time.Now().Year()), Copyright: "Copyright © 2023~" + strconv.Itoa(time.Now().Year()),
IsReset: false,
PublicCrt: []byte(`-----BEGIN CERTIFICATE----- PublicCrt: []byte(`-----BEGIN CERTIFICATE-----
MIIDwzCCAqugAwIBAgIUFAnC6268dp/z1DR9E1UepiWgWzkwDQYJKoZIhvcNAQEL MIIDwzCCAqugAwIBAgIUFAnC6268dp/z1DR9E1UepiWgWzkwDQYJKoZIhvcNAQEL
BQAwcDELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCUNob25ncWluZzESMBAGA1UEBwwJ BQAwcDELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCUNob25ncWluZzESMBAGA1UEBwwJ
@@ -129,6 +132,10 @@ func (a *App) Startup(ctx context.Context) {
func (a *App) OnExit() { func (a *App) OnExit() {
a.UnsetSystemProxy() a.UnsetSystemProxy()
globalLogger.Close() globalLogger.Close()
if appOnce.IsReset {
err := a.ResetApp()
fmt.Println("err:", err)
}
} }
func (a *App) installCert() (string, error) { func (a *App) installCert() (string, error) {
@@ -179,3 +186,24 @@ func (a *App) lock() error {
} }
return nil return nil
} }
func (a *App) ResetApp() error {
exePath, err := os.Executable()
if err != nil {
return err
}
exePath, err = filepath.Abs(exePath)
if err != nil {
return err
}
_ = os.Remove(filepath.Join(appOnce.UserDir, "install.lock"))
_ = os.Remove(filepath.Join(appOnce.UserDir, "pass.cache"))
_ = os.Remove(filepath.Join(appOnce.UserDir, "config.json"))
_ = os.Remove(filepath.Join(appOnce.UserDir, "cert.crt"))
cmd := exec.Command(exePath)
cmd.Start()
return nil
}

View File

@@ -1,5 +1,9 @@
package core package core
import (
"github.com/wailsapp/wails/v2/pkg/runtime"
)
type Bind struct { type Bind struct {
} }
@@ -14,3 +18,8 @@ func (b *Bind) Config() *ResponseData {
func (b *Bind) AppInfo() *ResponseData { func (b *Bind) AppInfo() *ResponseData {
return httpServerOnce.buildResp(1, "ok", appOnce) return httpServerOnce.buildResp(1, "ok", appOnce)
} }
func (b *Bind) ResetApp() {
appOnce.IsReset = true
runtime.Quit(appOnce.ctx)
}

View File

@@ -84,7 +84,11 @@
"win_install_tip": "For the first time using this software, please right-click and select 'Run as administrator'", "win_install_tip": "For the first time using this software, please right-click and select 'Run as administrator'",
"download_queued": "Download has been added to the queue, current queue length{count}", "download_queued": "Download has been added to the queue, current queue length{count}",
"search": "Search", "search": "Search",
"search_description": "Keyword Search..." "search_description": "Keyword Search...",
"start_err_tip": "Error Message",
"start_err_content": "The current startup process has encountered an issue. Do you want to reset the application?",
"start_err_positiveText": "Clear cache and restart",
"start_err_negativeText": "Close the software"
}, },
"setting": { "setting": {
"restart_tip": "Keep default if unsure, please restart software after modification", "restart_tip": "Keep default if unsure, please restart software after modification",

View File

@@ -84,7 +84,11 @@
"win_install_tip": "首次启用本软件,请使用鼠标右键选择以管理员身份运行", "win_install_tip": "首次启用本软件,请使用鼠标右键选择以管理员身份运行",
"download_queued": "下载已加入队列,当前队列长度:{count}", "download_queued": "下载已加入队列,当前队列长度:{count}",
"search": "搜索", "search": "搜索",
"search_description": "关键字搜索..." "search_description": "关键字搜索...",
"start_err_tip": "错误提示",
"start_err_content": "当前启动过程遇到了问题,是否重置应用?",
"start_err_positiveText": "清理缓存并重启",
"start_err_negativeText": "关闭软件"
}, },
"setting": { "setting": {
"restart_tip": "如果不清楚保持默认就行,修改后请重启软件", "restart_tip": "如果不清楚保持默认就行,修改后请重启软件",

View File

@@ -51,7 +51,7 @@
</template> </template>
{{ t('index.cancel_down') }} {{ t('index.cancel_down') }}
</NButton> </NButton>
<NButton tertiary type="warning" @click.stop="batchExport" class="my-1"> <NButton tertiary type="warning" @click.stop="batchExport()" class="my-1">
<template #icon> <template #icon>
<n-icon> <n-icon>
<ArrowRedoCircleOutline/> <ArrowRedoCircleOutline/>
@@ -136,9 +136,14 @@ import {
Apps, Apps,
TrashOutline, CloseOutline TrashOutline, CloseOutline
} from "@vicons/ionicons5" } from "@vicons/ionicons5"
import { useDialog } from 'naive-ui'
import * as bind from "../../wailsjs/go/core/Bind"
import {Quit} from "../../wailsjs/runtime"
import {DialogOptions} from "naive-ui/es/dialog/src/DialogProvider"
const {t} = useI18n() const {t} = useI18n()
const eventStore = useEventStore() const eventStore = useEventStore()
const dialog = useDialog()
const isProxy = computed(() => { const isProxy = computed(() => {
return store.isProxy return store.isProxy
}) })
@@ -382,6 +387,7 @@ const showPassword = ref(false)
const downloadQueue = ref<appType.MediaInfo[]>([]) const downloadQueue = ref<appType.MediaInfo[]>([])
let activeDownloads = 0 let activeDownloads = 0
let isOpenProxy = false let isOpenProxy = false
let isInstall = false
onMounted(() => { onMounted(() => {
try { try {
@@ -390,8 +396,16 @@ onMounted(() => {
}) })
loading.value = true loading.value = true
handleInstall().then((is: boolean) => { handleInstall().then((is: boolean) => {
isInstall = true
loading.value = false loading.value = false
}) })
checkLoading()
watch(showPassword, ()=>{
if (!showPassword.value){
checkLoading()
}
})
} catch (e) { } catch (e) {
window.$message?.error(JSON.stringify(e), {duration: 5000}) window.$message?.error(JSON.stringify(e), {duration: 5000})
} }
@@ -607,12 +621,11 @@ const batchCancel = () =>{
return return
} }
data.value.forEach((item, index) => { data.value.forEach(async (item, index) => {
if (checkedRowKeysValue.value.includes(item.Id) && item.Status === "running") { if (checkedRowKeysValue.value.includes(item.Id) && item.Status === "running") {
appApi.cancel({id: item.Id}).then((res)=>{ appApi.cancel({id: item.Id})
item.Status = 'ready' data.value[index].Status = 'ready'
item.SavePath = '' data.value[index].SavePath = ''
})
} }
}) })
checkedRowKeysValue.value = [] checkedRowKeysValue.value = []
@@ -847,6 +860,29 @@ const handleInstall = async () => {
} }
return false return false
} }
const checkLoading = ()=>{
setTimeout(()=>{
if (loading.value && !isInstall && !showPassword.value) {
dialog.warning({
title: t("index.start_err_tip"),
content: t("index.start_err_content"),
positiveText: t("index.start_err_positiveText"),
negativeText: t("index.start_err_negativeText"),
draggable: false,
closeOnEsc: false,
closable: false,
maskClosable: false,
onPositiveClick: () => {
bind.ResetApp()
},
onNegativeClick: () => {
Quit()
}
} as DialogOptions)
}
}, 6000)
}
</script> </script>
<style> <style>
.ellipsis-2 { .ellipsis-2 {

View File

@@ -5,3 +5,5 @@ import {core} from '../models';
export function AppInfo():Promise<core.ResponseData>; export function AppInfo():Promise<core.ResponseData>;
export function Config():Promise<core.ResponseData>; export function Config():Promise<core.ResponseData>;
export function ResetApp():Promise<void>;

View File

@@ -9,3 +9,7 @@ export function AppInfo() {
export function Config() { export function Config() {
return window['go']['core']['Bind']['Config'](); return window['go']['core']['Bind']['Config']();
} }
export function ResetApp() {
return window['go']['core']['Bind']['ResetApp']();
}