新增打开目录方法

This commit is contained in:
zyj
2025-10-27 18:31:53 +08:00
parent 82390887c0
commit 0526cf4aa4
4 changed files with 42 additions and 1 deletions

17
app.go
View File

@@ -1,9 +1,13 @@
package main package main
import ( import (
"fmt"
"go-site-clone/config"
"go-site-clone/services" "go-site-clone/services"
"go-site-clone/utils" "go-site-clone/utils"
"net/url" "net/url"
"os/exec"
"path/filepath"
"github.com/go-rod/rod/lib/proto" "github.com/go-rod/rod/lib/proto"
"github.com/wailsapp/wails/v3/pkg/application" "github.com/wailsapp/wails/v3/pkg/application"
@@ -107,3 +111,16 @@ func (a *App) DownloadSite(uri string, obj services.ResourcesList) bool {
func (a *App) GetDownloadList() []utils.FileDir { func (a *App) GetDownloadList() []utils.FileDir {
return siteService.GetLocalSiteList() return siteService.GetLocalSiteList()
} }
// 打开网站文件夹
func (a *App) OpenSiteFileDir(pathDir string) bool {
appConfig, _ := config.LoadConfig()
newPath := filepath.Join(appConfig.SiteFileDir, pathDir)
cmd := exec.Command("explorer", newPath)
err := cmd.Start()
if err != nil {
fmt.Println("打开文件夹失败:", err)
return false
}
return true
}

View File

@@ -5,7 +5,15 @@
</a-breadcrumb> </a-breadcrumb>
<div> <div>
<a-card :bordered="false" class="table-list"> <a-card :bordered="false" class="table-list">
<a-table :dataSource="dataSource" :columns="columns" /> <a-table :dataSource="dataSource" :columns="columns" >
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<span>
<a @click="openFileDir(record.name)">查看文件</a>
</span>
</template>
</template>
</a-table>
</a-card> </a-card>
</div> </div>
</template> </template>
@@ -40,11 +48,16 @@
const dataSource = ref([]); const dataSource = ref([]);
const siteList = ref([]) const siteList = ref([])
// 获取网站列表
const getList = async ()=> { const getList = async ()=> {
App.GetDownloadList().then((res)=>{ App.GetDownloadList().then((res)=>{
dataSource.value = JSON.parse(JSON.stringify(res)) dataSource.value = JSON.parse(JSON.stringify(res))
}) })
} }
// 打开文件夹
const openFileDir = async (name) => {
App.OpenSiteFileDir(name)
}
onMounted(()=> { onMounted(()=> {
getList() getList()
}) })

View File

@@ -41,6 +41,15 @@ export function GetResources(rawURL) {
})); }));
} }
/**
* 打开网站文件夹
* @param {string} pathDir
* @returns {$CancellablePromise<boolean>}
*/
export function OpenSiteFileDir(pathDir) {
return $Call.ByID(4158138211, pathDir);
}
// Private type creation functions // Private type creation functions
const $$createType0 = utils$0.FileDir.createFrom; const $$createType0 = utils$0.FileDir.createFrom;
const $$createType1 = $Create.Array($$createType0); const $$createType1 = $Create.Array($$createType0);

View File

@@ -4,6 +4,7 @@ import (
"os/exec" "os/exec"
) )
// 检测当前电脑是否有GO环境
func CheckGoEnv() bool { func CheckGoEnv() bool {
cmd := exec.Command("go", "version") cmd := exec.Command("go", "version")
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
@@ -12,6 +13,7 @@ func CheckGoEnv() bool {
return true return true
} }
// 检测当前电脑是否有Wails3 环境
func CheckWailsEnv() bool { func CheckWailsEnv() bool {
cmd := exec.Command("wails3", "version") cmd := exec.Command("wails3", "version")
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {