diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/build/README.md b/build/README.md index cbf2fe5..2ebe293 100644 --- a/build/README.md +++ b/build/README.md @@ -1,15 +1,66 @@ -# Build Directory +## Mac +```bash +wails build -platform "darwin/universal" --dmg-name +create-dmg 'build/bin/res-downloader.app' \ + --overwrite --dmg-title="res-downloader" \ + --dmg-name "res-downloader_$(jq -r '.info.productVersion' wails.json).dmg" \ + ./build/bin +``` -The build directory is used to house all the build files and assets for your application. - -The structure is: - -* bin - Output directory -* darwin - macOS specific files -* windows - Windows specific files +## Windows +```bash +wails build -f -nsis -platform "windows/amd64" -webview2 Embed +wails build -f -nsis -platform "windows/arm64" -webview2 Embed +``` ## Linux +### docker方式 +> x86_64 +```bash +docker build --network host -f build/linux/dockerfile -t res-downloader-amd-linux . +docker run -it --name res-downloader-amd-build --network host --privileged -v ./:/www/res-downloader res-downloader-amd-linux /bin/bash +# 容器内 +cd /www/res-downloader +wails build + +# 打包debian +cp build/bin/res-downloader build/linux/Debian/usr/local/bin/ +echo "$(cat build/linux/Debian/DEBIAN/.control | sed -e "s/{{Version}}/$(jq -r '.info.productVersion' wails.json)/g")" > build/linux/Debian/DEBIAN/control +dpkg-deb --build ./build/linux/Debian build/bin/res-downloader_$(jq -r '.info.productVersion' wails.json)_x64.deb + +# 打包AppImage +cp build/bin/res-downloader build/linux/AppImage/usr/bin/ + +# 复制WebKit相关文件 +pushd build/linux/AppImage +find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true +find /usr/lib* -name WebKitWebProcess -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true +find /usr/lib* -name libwebkit2gtkinjectedbundle.so -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true +popd + +wget -O ./build/bin/appimagetool-x86_64.AppImage https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage +chmod +x ./build/bin/appimagetool-x86_64.AppImage +./build/bin/appimagetool-x86_64.AppImage build/linux/AppImage build/bin/res-downloader_$(jq -r '.info.productVersion' wails.json)_x64.AppImage +``` + +> arm64 +```bash +# arm +docker build --platform linux/arm64 --network host -f build/linux/dockerfile -t res-downloader-arm-linux . +docker run --platform linux/arm64 -it --name res-downloader-arm-build --network host --privileged -v ./:/www/res-downloader res-downloader-arm-linux /bin/bash +# 容器内 +cd /www/res-downloader +wails build + +# 打包debian +cp build/bin/res-downloader build/linux/Debian/usr/local/bin/ +echo "$(cat build/linux/Debian/DEBIAN/.control | sed -e "s/{{Version}}/$(jq -r '.info.productVersion' wails.json)/g")" > build/linux/Debian/DEBIAN/control +dpkg-deb --build ./build/linux/Debian build/bin/res-downloader_$(jq -r '.info.productVersion' wails.json)_arm.deb +``` + + +> ArchLinux环境 ```bash git clone https://github.com/putyy/res-downloader.git cd res-downloader @@ -18,30 +69,4 @@ cd build sudo install -Dvm755 bin/res-downloader -t /usr/bin sudo install -Dvm644 appicon.png /usr/share/icons/hicolor/512x512/apps/res-downloader.png sudo install -Dvm644 linux/res-downloader.desktop /usr/share/applications/res-downloader.desktop -``` - -## Mac - -The `darwin` directory holds files specific to Mac builds. -These may be customised and used as part of the build. To return these files to the default state, simply delete them -and -build with `wails build`. - -The directory contains the following files: - -- `Info.plist` - the main plist file used for Mac builds. It is used when building using `wails build`. -- `Info.dev.plist` - same as the main plist file but used when building using `wails dev`. - -## Windows - -The `windows` directory contains the manifest and rc files used when building with `wails build`. -These may be customised for your application. To return these files to the default state, simply delete them and -build with `wails build`. - -- `icon.ico` - The icon used for the application. This is used when building using `wails build`. If you wish to - use a different icon, simply replace this file with your own. If it is missing, a new `icon.ico` file - will be created using the `appicon.png` file in the build directory. -- `installer/*` - The files used to create the Windows installer. These are used when building using `wails build`. -- `info.json` - Application details used for Windows builds. The data here will be used by the Windows installer, - as well as the application itself (right click the exe -> properties -> details) -- `wails.exe.manifest` - The main application manifest file. +``` \ No newline at end of file diff --git a/build/linux/.gitignore b/build/linux/.gitignore new file mode 100644 index 0000000..8b4712d --- /dev/null +++ b/build/linux/.gitignore @@ -0,0 +1,5 @@ +!.gitkeep +debian/usr/local/bin/* +debian/DEBIAN/control +AppImage/usr/bin/* +AppImage/usr/lib/* diff --git a/build/linux/AppImage/.DirIcon b/build/linux/AppImage/.DirIcon new file mode 120000 index 0000000..d2605dd --- /dev/null +++ b/build/linux/AppImage/.DirIcon @@ -0,0 +1 @@ +res-downloader.png \ No newline at end of file diff --git a/build/linux/AppImage/res-downloader.desktop b/build/linux/AppImage/res-downloader.desktop new file mode 100644 index 0000000..2c79eb9 --- /dev/null +++ b/build/linux/AppImage/res-downloader.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=res-downloader +Comment=This is a high-value and high-performance and diverse resource downloader called res-downloader +Exec=/usr/bin/res-downloader +Icon=/usr/share/icons/hicolor/256x256/apps/res-downloader +Terminal=false +Categories=Utility; \ No newline at end of file diff --git a/build/linux/AppImage/usr/.DS_Store b/build/linux/AppImage/usr/.DS_Store new file mode 100644 index 0000000..2bf6673 Binary files /dev/null and b/build/linux/AppImage/usr/.DS_Store differ diff --git a/build/linux/AppImage/usr/bin/.gitkeep b/build/linux/AppImage/usr/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/build/linux/AppImage/usr/share/applications/res-downloader.desktop b/build/linux/AppImage/usr/share/applications/res-downloader.desktop new file mode 100644 index 0000000..2c79eb9 --- /dev/null +++ b/build/linux/AppImage/usr/share/applications/res-downloader.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=res-downloader +Comment=This is a high-value and high-performance and diverse resource downloader called res-downloader +Exec=/usr/bin/res-downloader +Icon=/usr/share/icons/hicolor/256x256/apps/res-downloader +Terminal=false +Categories=Utility; \ No newline at end of file diff --git a/build/linux/AppImage/usr/share/icons/hicolor/256x256/apps/res-downloader.png b/build/linux/AppImage/usr/share/icons/hicolor/256x256/apps/res-downloader.png new file mode 100644 index 0000000..cf244be Binary files /dev/null and b/build/linux/AppImage/usr/share/icons/hicolor/256x256/apps/res-downloader.png differ diff --git a/build/linux/Debian/.DS_Store b/build/linux/Debian/.DS_Store new file mode 100644 index 0000000..379d63a Binary files /dev/null and b/build/linux/Debian/.DS_Store differ diff --git a/build/linux/Debian/DEBIAN/.DS_Store b/build/linux/Debian/DEBIAN/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/build/linux/Debian/DEBIAN/.DS_Store differ diff --git a/build/linux/Debian/DEBIAN/.control b/build/linux/Debian/DEBIAN/.control new file mode 100644 index 0000000..78b0d40 --- /dev/null +++ b/build/linux/Debian/DEBIAN/.control @@ -0,0 +1,9 @@ +Package: res-downloader +Version: {{Version}} +Section: utils +Priority: optional +Architecture: amd64 +Depends: libwebkit2gtk-4.0-37 +Maintainer: putyy@qq.com +Homepage: https://github.com/putyy/res-downloader +Description: This is a high-value and high-performance and diverse resource downloader called res-downloader diff --git a/build/linux/Debian/usr/local/.DS_Store b/build/linux/Debian/usr/local/.DS_Store new file mode 100644 index 0000000..950ad6f Binary files /dev/null and b/build/linux/Debian/usr/local/.DS_Store differ diff --git a/build/linux/Debian/usr/local/bin/.gitkeep b/build/linux/Debian/usr/local/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/build/linux/Debian/usr/share/applications/res-downloader.desktop b/build/linux/Debian/usr/share/applications/res-downloader.desktop new file mode 100644 index 0000000..7f10df5 --- /dev/null +++ b/build/linux/Debian/usr/share/applications/res-downloader.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=res-downloader +Comment=This is a high-value and high-performance and diverse resource downloader called res-downloader +Exec=/usr/local/bin/res-downloader +Icon=/usr/share/icons/hicolor/256x256/apps/res-downloader.png +Terminal=false +Categories=Utility; \ No newline at end of file diff --git a/build/linux/Debian/usr/share/icons/hicolor/256x256/apps/res-downloader.png b/build/linux/Debian/usr/share/icons/hicolor/256x256/apps/res-downloader.png new file mode 100644 index 0000000..cf244be Binary files /dev/null and b/build/linux/Debian/usr/share/icons/hicolor/256x256/apps/res-downloader.png differ diff --git a/build/linux/dockerfile b/build/linux/dockerfile new file mode 100644 index 0000000..ddc5ec7 --- /dev/null +++ b/build/linux/dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.23.4-bookworm + +WORKDIR / + +RUN apt-get update && \ + apt-get install -y --fix-missing \ + build-essential \ + git \ + jq \ + kmod \ + fuse \ + libgtk-3-dev \ + libwebkit2gtk-4.0-dev \ + nsis \ + wget \ + curl \ + gnupg2 \ + lsb-release \ + libfuse-dev \ + libfuse2 \ + file \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y nodejs + +RUN go install github.com/wailsapp/wails/v2/cmd/wails@latest + +RUN wails doctor diff --git a/build/linux/res-downloader.desktop b/build/linux/res-downloader.desktop deleted file mode 100644 index f128268..0000000 --- a/build/linux/res-downloader.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Categories= -Comment=支持视频号、小程序、抖音、快手、小红书、直播流、酷狗、QQ音乐等常见网络资源! -Exec=res-downloader -Icon=res-downloader.png -Name=res-downloader -Terminal=false -Type=Application - diff --git a/build/windows/installer/wails_tools.nsh b/build/windows/installer/wails_tools.nsh index 2a2e0b8..e60a30f 100644 --- a/build/windows/installer/wails_tools.nsh +++ b/build/windows/installer/wails_tools.nsh @@ -14,7 +14,7 @@ !define INFO_PRODUCTNAME "res-downloader" !endif !ifndef INFO_PRODUCTVERSION - !define INFO_PRODUCTVERSION "3.0.1" + !define INFO_PRODUCTVERSION "3.0.2" !endif !ifndef INFO_COPYRIGHT !define INFO_COPYRIGHT "Copyright © 2023" diff --git a/core/app.go b/core/app.go index 4d13051..7e91b63 100644 --- a/core/app.go +++ b/core/app.go @@ -42,7 +42,7 @@ func GetApp(assets embed.FS) *App { appOnce = &App{ assets: assets, AppName: "res-downloader", - Version: "3.0.1", + Version: "3.0.2", Description: "res-downloader是一款集网络资源嗅探 + 高速下载功能于一体的软件,高颜值、高性能和多样化,提供个人用户下载自己上传到各大平台的网络资源功能!", Copyright: "Copyright © 2023~" + strconv.Itoa(time.Now().Year()), PublicCrt: []byte(` @@ -142,10 +142,12 @@ func (a *App) OnExit() { func (a *App) installCert() { if res, err := systemOnce.installCert(); err != nil { if sysRuntime.GOOS == "darwin" { - DialogErr("证书安装失败,请手动执行安装命令(已复制到剪切板),err:" + err.Error() + ", " + res) - _ = runtime.ClipboardSetText(appOnce.ctx, `echo "输入本地登录密码" && sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "`+systemOnce.CertFile+`" && touch `+a.LockFile+` && echo "安装完成"`) + _ = runtime.ClipboardSetText(appOnce.ctx, `echo "输入本地登录密码" && sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "`+systemOnce.CertFile+`" && touch `+a.LockFile+` && echo "安装完成"`) + DialogErr("证书安装失败,请打开终端执行安装(命令已复制到剪切板),err:" + err.Error() + ", " + res) } else if sysRuntime.GOOS == "windows" && strings.Contains(err.Error(), "Access is denied.") { DialogErr("首次启用本软件,请使用鼠标右键选择以管理员身份运行") + } else if sysRuntime.GOOS == "linux" && strings.Contains(err.Error(), "Access is denied.") { + DialogErr("证书路径: " + systemOnce.CertFile + ", 请手动安装,安装完成后请执行: touch" + a.LockFile + " err:" + err.Error() + ", " + res) } else { globalLogger.Esg(err, res) DialogErr("err:" + err.Error() + ", " + res) diff --git a/core/config.go b/core/config.go index 4aea8b5..f58d0c3 100644 --- a/core/config.go +++ b/core/config.go @@ -37,7 +37,7 @@ func initConfig() *Config { "OpenProxy": false, "DownloadProxy": false, "AutoProxy": false, - "WxAction": false, + "WxAction": true, "TaskNumber": __TaskNumber__, "UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" } @@ -59,6 +59,8 @@ func initConfig() *Config { func (c *Config) setConfig(config Config) { oldProxy := c.UpstreamProxy + c.Host = config.Host + c.Port = config.Port c.Theme = config.Theme c.Quality = config.Quality c.SaveDirectory = config.SaveDirectory diff --git a/core/system_darwin.go b/core/system_darwin.go index 313891f..7fd9f83 100644 --- a/core/system_darwin.go +++ b/core/system_darwin.go @@ -95,7 +95,7 @@ func (s *SystemSetup) installCert() (string, error) { return "", err } - getPasswordCmd := exec.Command("osascript", "-e", `tell app "System Events" to display dialog "请输入密码,用于安装证书:" default answer "" with hidden answer`, "-e", `text returned of result`) + getPasswordCmd := exec.Command("osascript", "-e", `tell app "System Events" to display dialog "请输入你的电脑密码,用于安装证书文件:" default answer "" with hidden answer`, "-e", `text returned of result`) passwordOutput, err := getPasswordCmd.Output() if err != nil { return string(passwordOutput), err diff --git a/core/system_linux.go b/core/system_linux.go index db4e534..c2a19e1 100644 --- a/core/system_linux.go +++ b/core/system_linux.go @@ -3,7 +3,7 @@ package core import ( - "os" + "fmt" "os/exec" ) @@ -15,13 +15,18 @@ func (s *SystemSetup) setProxy() error { {"gsettings", "set", "org.gnome.system.proxy.https", "host", "127.0.0.1"}, {"gsettings", "set", "org.gnome.system.proxy.https", "port", globalConfig.Port}, } - + is := false for _, cmd := range commands { if err := exec.Command(cmd[0], cmd[1:]...).Run(); err != nil { - return err + fmt.Println(err) + } else { + is = true } } - return nil + if is { + return nil + } + return fmt.Errorf("Failed to activate proxy") } func (s *SystemSetup) unsetProxy() error { @@ -30,21 +35,40 @@ func (s *SystemSetup) unsetProxy() error { } func (s *SystemSetup) installCert() (string, error) { - certData, err := s.initCert() - if err != nil { - return "", err - } - destFile := "/usr/share/ca-certificates/trust-source/" + appOnce.AppName + ".crt" - - err = os.WriteFile(destFile, certData, 0644) + _, err := s.initCert() if err != nil { return "", err } - cmd := exec.Command("sudo", "update-ca-trust") - output, err := cmd.CombinedOutput() - if err != nil { - return string(output), err + actions := [][]string{ + {"/usr/local/share/ca-certificates/", "update-ca-certificates"}, + {"/usr/share/ca-certificates/trust-source/anchors/", "update-ca-trust"}, + {"/usr/share/ca-certificates/trust-source/anchors/", "trust extract-compat"}, + {"/etc/pki/ca-trust/source/anchors/", "update-ca-trust"}, + {"/etc/ssl/ca-certificates/", "update-ca-certificates"}, } + + is := false + + for _, action := range actions { + dir := action[0] + if err := exec.Command("sudo", "cp", "-f", s.CertFile, dir+appOnce.AppName+".crt").Run(); err != nil { + fmt.Printf("Failed to copy to %s: %v\n", dir, err) + continue + } + + cmd := action[1] + if err := exec.Command("sudo", cmd).Run(); err != nil { + fmt.Printf("Failed to refresh certificates using %s: %v\n", cmd, err) + continue + } + + is = true + } + + if !is { + return "", fmt.Errorf("Certificate installation failed") + } + return "", nil } diff --git a/wails.json b/wails.json index 5b9fa52..d104dbc 100644 --- a/wails.json +++ b/wails.json @@ -13,7 +13,7 @@ "info": { "companyName": "res-downloader", "productName": "res-downloader", - "productVersion": "3.0.1", + "productVersion": "3.0.2", "copyright": "Copyright © 2023", "comments": "This is a high-value, high-performance, and diverse resource downloader called res-downloader." }