mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-10 02:20:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
576f0d2e24 | ||
|
|
95eb3a427c | ||
|
|
e9442edd94 | ||
|
|
77e59f7376 | ||
|
|
135fba1b54 | ||
|
|
ff813e3bc9 | ||
|
|
babfe79023 | ||
|
|
89ac52bebd | ||
|
|
15e1c2f2d5 | ||
|
|
203f0ccc82 | ||
|
|
2422bd2c66 | ||
|
|
0306a1ed6b | ||
|
|
8a94650370 | ||
|
|
837a193e96 | ||
|
|
fcf0746f9a | ||
|
|
9eb466ccd3 | ||
|
|
c54f22613e |
No files matched your search
@@ -0,0 +1,8 @@
|
||||
<!--
|
||||
请根据以下模版提issue
|
||||
-->
|
||||
### 问题描述(必要)
|
||||
### 版本号(必要)
|
||||
### 操作系统(必要)
|
||||
### 相关截图
|
||||
### 相关日志
|
||||
@@ -1,5 +1,5 @@
|
||||
name-template: 'v1.0.0 🌈'
|
||||
tag-template: 'v1.0.0'
|
||||
name-template: 'v$NEXT_PATCH_VERSION 🌈'
|
||||
tag-template: 'v$NEXT_PATCH_VERSION'
|
||||
categories:
|
||||
- title: '🆕 Features'
|
||||
labels:
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
get-release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tag_name: ${{ steps.get_release.outputs.tag_name }}
|
||||
upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: thebritican/fetch-latest-release@v2
|
||||
id: get_release
|
||||
with:
|
||||
github_token: ${{ github.token }}
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
needs: [get_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.get_release.outputs.tag_name }}
|
||||
run: |
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build windows
|
||||
$mingw = "C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin"
|
||||
$system = "C:\Windows\System32"
|
||||
$release = "build\windows\runner\Release\"
|
||||
cp $mingw\libstdc++-6.dll $release
|
||||
cp $mingw\libgcc_s_seh-1.dll $release
|
||||
cp $mingw\libwinpthread-1.dll $release
|
||||
cp $system\msvcp140.dll $release
|
||||
cp $system\vcruntime140.dll $release
|
||||
cp $system\vcruntime140_1.dll $release
|
||||
|
||||
Compress-Archive -Path $release -DestinationPath build\windows\Output\Gopeed-$env:VERSION-windows-amd64.zip
|
||||
|
||||
cd build/windows
|
||||
echo @"
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "Gopeed"
|
||||
#define MyAppVersion "$($env:VERSION.substring(1))"
|
||||
#define MyAppPublisher "monkeyWie"
|
||||
#define MyAppURL "https://gopeed.com"
|
||||
#define MyAppExeName "gopeed.exe"
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{5960F34D-1E42-402C-8C85-DE2FF24CBAE4}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={autopf}\gopeed
|
||||
DisableProgramGroupPage=yes
|
||||
LicenseFile=..\..\..\..\LICENSE
|
||||
; Remove the following line to run in administrative install mode (install for all users.)
|
||||
PrivilegesRequired=lowest
|
||||
OutputBaseFilename=gopeed
|
||||
SetupIconFile=..\..\assets\icon\icon.ico
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
WizardStyle=modern
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: ".\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||
"@ > setup.iss
|
||||
iscc.exe setup.iss
|
||||
mv "Output\gopeed.exe" "Output\Gopeed-$env:VERSION-windows-amd64-install.exe"
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/build/windows/Output/*
|
||||
overwrite: true
|
||||
build-macos-arm64-lib:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- run: mkdir -p ~/image-cache
|
||||
- id: image-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/image-cache
|
||||
key: image-cache-xgo-v1.19
|
||||
- if: steps.image-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
docker pull techknowlogick/xgo:go-1.19.x
|
||||
docker save -o ~/image-cache/xgo.tar techknowlogick/xgo:go-1.19.x
|
||||
- if: steps.image-cache.outputs.cache-hit == 'true'
|
||||
run: docker load -i ~/image-cache/xgo.tar
|
||||
- name: Build
|
||||
run: |
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
xgo --targets=darwin/arm64 -tags="nosqlite" -ldflags="-w -s" -buildmode=c-shared -pkg=bind/desktop -out=libgopeed .
|
||||
mv libgopeed-*.dylib libgopeed.dylib
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: macos-arm64-lib
|
||||
path: libgopeed.dylib
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
needs: [release, build-macos-arm64-lib]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Install appdmg
|
||||
run: npm install -g appdmg
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: macos-arm64-lib
|
||||
path: ui/flutter/macos/Frameworks
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.get_release.outputs.tag_name }}
|
||||
run: |
|
||||
PROJECT_DIR=$(pwd)
|
||||
|
||||
cd ui/flutter
|
||||
flutter build macos
|
||||
cd build/macos/Build/Products/Release
|
||||
cat>appdmg.json<<EOF
|
||||
{
|
||||
"title": "Gopeed",
|
||||
"icon": "Gopeed.app/Contents/Resources/AppIcon.icns",
|
||||
"contents": [
|
||||
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
|
||||
{ "x": 192, "y": 344, "type": "file", "path": "Gopeed.app" }
|
||||
]
|
||||
}
|
||||
EOF
|
||||
mkdir dist
|
||||
appdmg appdmg.json dist/Gopeed-$VERSION-macos-arm64.dmg
|
||||
|
||||
# amd64
|
||||
cd $PROJECT_DIR
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o bin/libgopeed.dylib github.com/monkeyWie/gopeed/bind/desktop
|
||||
cp bin/libgopeed.dylib ui/flutter/build/macos/Build/Products/Release/Gopeed.app/Contents/Frameworks/
|
||||
cd ui/flutter/build/macos/Build/Products/Release
|
||||
appdmg appdmg.json dist/Gopeed-$VERSION-macos-amd64.dmg
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/build/macos/Build/Products/Release/dist/*
|
||||
overwrite: true
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- uses: subosito/flutter-action@v2
|
||||
- run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y ninja-build libgtk-3-dev
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.get_release.outputs.tag_name }}
|
||||
run: |
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build linux
|
||||
mkdir -p debian/gui
|
||||
cp assets/icon/icon_1024.png debian/gui/gopeed.png
|
||||
cat>debian/debian.yaml<<EOF
|
||||
flutter_app:
|
||||
command: gopeed
|
||||
arch: x64
|
||||
parent: /usr/local/lib
|
||||
control:
|
||||
Package: gopeed
|
||||
Version: ${VERSION:1}
|
||||
Architecture: amd64
|
||||
Essential: no
|
||||
Priority: optional
|
||||
Depends:
|
||||
Maintainer: monkeyWie
|
||||
Description: High speed downloader that supports all platforms.
|
||||
EOF
|
||||
|
||||
cat>debian/gui/gopeed.desktop<<EOF
|
||||
[Desktop Entry]
|
||||
Version=${VERSION:1}
|
||||
Name=Gopeed
|
||||
GenericName=Gopeed
|
||||
Comment=High speed downloader that supports all platforms.
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Utility
|
||||
Keywords=Flutter;Downloader;
|
||||
EOF
|
||||
|
||||
dart pub global activate flutter_to_debian
|
||||
flutter_to_debian
|
||||
mv debian/packages/gopeed*.deb debian/packages/Gopeed-$VERSION-linux-amd64.deb
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/debian/packages/*
|
||||
overwrite: true
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "zulu"
|
||||
java-version: "11"
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.get_release.outputs.tag_name }}
|
||||
run: |
|
||||
mkdir ui/flutter/android/app/libs
|
||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||
gomobile init
|
||||
gomobile bind -tags nosqlite -ldflags="-w -s" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 19 -javapkg=com.gopeed github.com/monkeyWie/gopeed/bind/mobile
|
||||
cd ui/flutter
|
||||
flutter build apk
|
||||
mkdir dist
|
||||
cp build/app/outputs/flutter-apk/app-release.apk dist/Gopeed-$VERSION-android.apk
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/dist/*
|
||||
overwrite: true
|
||||
build-web:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.get_release.outputs.tag_name }}
|
||||
run: |
|
||||
cd ui/flutter
|
||||
flutter build web
|
||||
cd ../../
|
||||
cp -r ui/flutter/build/web cmd/web/dist
|
||||
mkdir -p dist/zip
|
||||
goos_arr=(windows darwin linux)
|
||||
goarch_arr=(386 amd64 arm64)
|
||||
export CGO_ENABLED=0
|
||||
for goos in "${goos_arr[@]}"; do
|
||||
for goarch in "${goarch_arr[@]}"; do
|
||||
name=gopeed-web-$VERSION-$goos-$goarch
|
||||
dir="dist/$name/"
|
||||
(GOOS=$goos GOARCH=$goarch go build -tags nosqlite,web -ldflags="-s -w" -o $dir github.com/monkeyWie/gopeed/cmd/web \
|
||||
&& cd $dir \
|
||||
&& file=$(ls -AU | head -1) \
|
||||
&& mkdir $name \
|
||||
&& mv $file $name/$(echo $file | sed -e "s/web/gopeed/g") \
|
||||
&& zip -r ../zip/$name.zip * \
|
||||
&& cd ../..) \
|
||||
|| true
|
||||
done
|
||||
done
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: dist/zip/*
|
||||
overwrite: true
|
||||
build-docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get_release]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.get_release.outputs.tag_name }}
|
||||
run: |
|
||||
tag=liwei2633/gopeed:${VERSION:1}
|
||||
docker build -t $tag .
|
||||
docker login -u liwei2633 -p ${{ secrets.DOCKER_PASSWORD }}
|
||||
docker push $tag
|
||||
docker tag $tag liwei2633/gopeed:latest
|
||||
docker push liwei2633/gopeed:latest
|
||||
@@ -5,9 +5,14 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '_docs/**'
|
||||
- '_examples/**'
|
||||
- 'README*.md'
|
||||
- ".github/**"
|
||||
- "!.github/workflows/release.yml"
|
||||
- "!.github/release-drafter.yml"
|
||||
- "_docs/**"
|
||||
- "_examples/**"
|
||||
- "README*.md"
|
||||
- ".gitignore"
|
||||
- "ui/flutter/.gitignore"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
@@ -20,309 +25,8 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
go-version: "^1.19"
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
id: create_release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
needs: [ release ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
cache: true
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.release.outputs.tag_name }}
|
||||
run: |
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build windows
|
||||
$mingw = "C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin"
|
||||
$system = "C:\Windows\System32"
|
||||
$release = "build\windows\runner\Release\"
|
||||
cp $mingw\libstdc++-6.dll $release
|
||||
cp $mingw\libgcc_s_seh-1.dll $release
|
||||
cp $mingw\libwinpthread-1.dll $release
|
||||
cp $system\msvcp140.dll $release
|
||||
cp $system\vcruntime140.dll $release
|
||||
cp $system\vcruntime140_1.dll $release
|
||||
|
||||
cd build/windows
|
||||
echo @"
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "Gopeed"
|
||||
#define MyAppVersion "$($env:VERSION.substring(1))"
|
||||
#define MyAppPublisher "monkeyWie"
|
||||
#define MyAppURL "https://gopeed.com"
|
||||
#define MyAppExeName "gopeed.exe"
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{5960F34D-1E42-402C-8C85-DE2FF24CBAE4}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={autopf}\gopeed
|
||||
DisableProgramGroupPage=yes
|
||||
LicenseFile=..\..\..\..\LICENSE
|
||||
; Remove the following line to run in administrative install mode (install for all users.)
|
||||
PrivilegesRequired=lowest
|
||||
OutputBaseFilename=gopeed
|
||||
SetupIconFile=..\..\assets\icon\icon.ico
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
WizardStyle=modern
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: ".\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||
"@ > setup.iss
|
||||
iscc.exe setup.iss
|
||||
mv "Output\gopeed.exe" "Output\Gopeed-$env:VERSION-windows-amd64.exe"
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/build/windows/Output/*
|
||||
overwrite: true
|
||||
build-macos-arm64-lib:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ release ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
cache: true
|
||||
- run: mkdir -p ~/image-cache
|
||||
- id: image-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/image-cache
|
||||
key: image-cache-xgo-v1.19
|
||||
- if: steps.image-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
docker pull techknowlogick/xgo:go-1.19.x
|
||||
docker save -o ~/image-cache/xgo.tar techknowlogick/xgo:go-1.19.x
|
||||
- if: steps.image-cache.outputs.cache-hit == 'true'
|
||||
run: docker load -i ~/image-cache/xgo.tar
|
||||
- name: Build
|
||||
run: |
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
xgo --targets=darwin/arm64 -tags="nosqlite" -ldflags="-w -s" -buildmode=c-shared -pkg=bind/desktop -out=libgopeed .
|
||||
mv libgopeed-*.dylib libgopeed.dylib
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: macos-arm64-lib
|
||||
path: libgopeed.dylib
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
needs: [ release, build-macos-arm64-lib ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
cache: true
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Install appdmg
|
||||
run: npm install -g appdmg
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: macos-arm64-lib
|
||||
path: ui/flutter/macos/Frameworks
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.release.outputs.tag_name }}
|
||||
run: |
|
||||
PROJECT_DIR=$(pwd)
|
||||
|
||||
cd ui/flutter
|
||||
flutter build macos
|
||||
cd build/macos/Build/Products/Release
|
||||
cat>appdmg.json<<EOF
|
||||
{
|
||||
"title": "Gopeed",
|
||||
"icon": "Gopeed.app/Contents/Resources/AppIcon.icns",
|
||||
"contents": [
|
||||
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
|
||||
{ "x": 192, "y": 344, "type": "file", "path": "Gopeed.app" }
|
||||
]
|
||||
}
|
||||
EOF
|
||||
mkdir dist
|
||||
appdmg appdmg.json dist/Gopeed-$VERSION-macos-arm64.dmg
|
||||
|
||||
# amd64
|
||||
cd $PROJECT_DIR
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o bin/libgopeed.dylib github.com/monkeyWie/gopeed/bind/desktop
|
||||
cp bin/libgopeed.dylib ui/flutter/build/macos/Build/Products/Release/Gopeed.app/Contents/Frameworks/
|
||||
cd ui/flutter/build/macos/Build/Products/Release
|
||||
appdmg appdmg.json dist/Gopeed-$VERSION-macos-amd64.dmg
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/build/macos/Build/Products/Release/dist/*
|
||||
overwrite: true
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ release ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
cache: true
|
||||
- uses: subosito/flutter-action@v2
|
||||
- run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y ninja-build libgtk-3-dev
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.release.outputs.tag_name }}
|
||||
run: |
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build linux
|
||||
mkdir -p debian/gui
|
||||
cp assets/icon/icon_1024.png debian/gui/gopeed.png
|
||||
cat>debian/debian.yaml<<EOF
|
||||
flutter_app:
|
||||
command: gopeed
|
||||
arch: x64
|
||||
parent: /usr/local/lib
|
||||
control:
|
||||
Package: gopeed
|
||||
Version: ${VERSION:1}
|
||||
Architecture: amd64
|
||||
Essential: no
|
||||
Priority: optional
|
||||
Depends:
|
||||
Maintainer: monkeyWie
|
||||
Description: High speed downloader that supports all platforms.
|
||||
EOF
|
||||
|
||||
cat>debian/gui/gopeed.desktop<<EOF
|
||||
[Desktop Entry]
|
||||
Version=${VERSION:1}
|
||||
Name=Gopeed
|
||||
GenericName=Gopeed
|
||||
Comment=High speed downloader that supports all platforms.
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Utility
|
||||
Keywords=Flutter;Downloader;
|
||||
EOF
|
||||
|
||||
dart pub global activate flutter_to_debian
|
||||
flutter_to_debian
|
||||
mv debian/packages/gopeed*.deb debian/packages/Gopeed-$VERSION-linux-amd64.deb
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/debian/packages/*
|
||||
overwrite: true
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ release ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
cache: true
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.release.outputs.tag_name }}
|
||||
run: |
|
||||
mkdir ui/flutter/android/app/libs
|
||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||
gomobile init
|
||||
gomobile bind -tags nosqlite -ldflags="-w -s" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 19 -javapkg=com.gopeed github.com/monkeyWie/gopeed/bind/mobile
|
||||
cd ui/flutter
|
||||
flutter build apk
|
||||
mkdir dist
|
||||
cp build/app/outputs/flutter-apk/app-release.apk dist/Gopeed-$VERSION-android.apk
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: ui/flutter/dist/*
|
||||
overwrite: true
|
||||
build-web:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ release ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
cache: true
|
||||
- uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ needs.release.outputs.tag_name }}
|
||||
run: |
|
||||
cd ui/flutter
|
||||
flutter build web
|
||||
cd ../../
|
||||
cp -r ui/flutter/build/web cmd/web/dist
|
||||
mkdir -p dist/zip
|
||||
goos_arr=(windows darwin linux)
|
||||
goarch_arr=(386 amd64 arm64)
|
||||
export CGO_ENABLED=0
|
||||
for goos in "${goos_arr[@]}"; do
|
||||
for goarch in "${goarch_arr[@]}"; do
|
||||
name=gopeed-web-$VERSION-$goos-$goarch
|
||||
dir="dist/$name/"
|
||||
(GOOS=$goos GOARCH=$goarch go build -tags nosqlite,web -ldflags="-s -w" -o $dir github.com/monkeyWie/gopeed/cmd/web \
|
||||
&& cd $dir \
|
||||
&& file=$(ls -AU | head -1) \
|
||||
&& mkdir $name \
|
||||
&& mv $file $name/$(echo $file | sed -e "s/web/gopeed/g") \
|
||||
&& zip -r ../zip/$name.zip * \
|
||||
&& cd ../..) \
|
||||
|| true
|
||||
done
|
||||
done
|
||||
- name: Upload
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: dist/zip/*
|
||||
overwrite: true
|
||||
+31
-27
@@ -5,35 +5,39 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '.github/workflows/release.yml'
|
||||
- '.github/release-drafter.yml'
|
||||
- '_docs/**'
|
||||
- '_examples/**'
|
||||
- 'README*.md'
|
||||
- ".github/**"
|
||||
- "!.github/workflows/test.yml"
|
||||
- "_docs/**"
|
||||
- "_examples/**"
|
||||
- "README*.md"
|
||||
- ".gitignore"
|
||||
- "ui/flutter/.gitignore"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '.github/workflows/release.yml'
|
||||
- '.github/release-drafter.yml'
|
||||
- '_docs/**'
|
||||
- '_examples/**'
|
||||
- 'README*.md'
|
||||
- ".github/**"
|
||||
- "!.github/workflows/test.yml"
|
||||
- "_docs/**"
|
||||
- "_examples/**"
|
||||
- "README*.md"
|
||||
- ".gitignore"
|
||||
- "ui/flutter/.gitignore"
|
||||
|
||||
jobs:
|
||||
# lint:
|
||||
# name: Lint
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/setup-go@v2
|
||||
# with:
|
||||
# go-version: '^1.19'
|
||||
# - uses: actions/checkout@v2
|
||||
# - name: Lint Go Code
|
||||
# run: |
|
||||
# export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
|
||||
# go get -u golang.org/x/lint/golint
|
||||
# golint -set_exit_status ./...
|
||||
# lint:
|
||||
# name: Lint
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/setup-go@v2
|
||||
# with:
|
||||
# go-version: '^1.19'
|
||||
# - uses: actions/checkout@v2
|
||||
# - name: Lint Go Code
|
||||
# run: |
|
||||
# export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
|
||||
# go get -u golang.org/x/lint/golint
|
||||
# golint -set_exit_status ./...
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
@@ -41,7 +45,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- name: Run Unit tests.
|
||||
run: go test $(go list ./... | grep -v /cmd/ | grep -v /bind/ ) -v -covermode=count -coverprofile=coverage.txt
|
||||
@@ -52,13 +56,13 @@ jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
# needs: [lint, test]
|
||||
# needs: [lint, test]
|
||||
needs: [test]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
go-version: "^1.19"
|
||||
cache: true
|
||||
- name: Build
|
||||
run: go build github.com/monkeyWie/gopeed/cmd/gopeed
|
||||
run: go build github.com/monkeyWie/gopeed/cmd/gopeed
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
FROM cirrusci/flutter:3.3.7 AS flutter
|
||||
WORKDIR /app
|
||||
COPY ./ui/flutter/pubspec.yaml ./ui/flutter/pubspec.lock ./
|
||||
RUN flutter pub get
|
||||
COPY ./ui/flutter ./
|
||||
RUN flutter build web
|
||||
|
||||
FROM golang:1.19.3 AS go
|
||||
WORKDIR /app
|
||||
COPY ./go.mod ./go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=flutter /app/build/web/* ./cmd/web/dist
|
||||
RUN go build -tags nosqlite,web -ldflags="-s -w" -o dist/gopeed github.com/monkeyWie/gopeed/cmd/web
|
||||
|
||||
FROM alpine:3.14.2
|
||||
LABEL maintainer="monkeyWie"
|
||||
WORKDIR /app
|
||||
COPY --from=go /app/dist/gopeed ./
|
||||
EXPOSE 9999
|
||||
ENTRYPOINT ["./gopeed"]
|
||||
@@ -1,16 +1,19 @@
|
||||
[](https://github.com/monkeyWie/gopeed/actions?query=workflow%3Atest)
|
||||
[](https://codecov.io/gh/monkeyWie/gopeed)
|
||||
[](https://github.com/monkeyWie/gopeed/releases)
|
||||
[](https://discord.gg/ZUJqJrwCGB)
|
||||
|
||||

|
||||
|
||||
## 介绍
|
||||
[English](/README.md) | [中文](/README_zh-CN.md)
|
||||
|
||||
Gopeed 是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、BitTorrent、Magnet)协议下载,并且支持全平台使用。
|
||||
## Introduction
|
||||
|
||||
## 下载
|
||||
Gopeed is a high-speed downloader developed by `Golang`+`Flutter`, which supports (HTTP, BitTorrent, Magnet) protocol downloads and supports all platforms.
|
||||
|
||||
**已支持平台**
|
||||
## Installation
|
||||
|
||||
**Supported platforms**
|
||||
|
||||
- [x] windows
|
||||
- [x] macos
|
||||
@@ -18,45 +21,55 @@ Gopeed 是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、
|
||||
- [x] android
|
||||
- [ ] ios
|
||||
- [x] web
|
||||
- [x] docker
|
||||
|
||||
[点击前往](https://github.com/monkeyWie/gopeed/releases/latest)
|
||||
[To Release](https://github.com/monkeyWie/gopeed/releases/latest)
|
||||
|
||||
### 命令行工具
|
||||
### Command tool
|
||||
|
||||
使用`go install`安装:
|
||||
use `go install`:
|
||||
|
||||
```bash
|
||||
go install github.com/monkeyWie/gopeed/cmd/gopeed
|
||||
```
|
||||
|
||||
## 界面展示
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker run liwei2633/gopeed:latest -v /path/to/download:/download -p 9999:9999
|
||||
```
|
||||
|
||||
When the docker container is running, you can access the web page through `http://localhost:9999`.
|
||||
> Tip: Modify the download path to `/download` on the setting page to access the downloaded files on the host.
|
||||
|
||||
## Showcase
|
||||
|
||||

|
||||
|
||||
## 开发
|
||||
## Development
|
||||
|
||||
本项目分为前端和后端两个部分,前端使用`flutter`,后端使用`Golang`,两边通过`http`协议进行通讯,在 unix 系统下,使用的是`unix socket`,在 windows 系统下,使用的是`tcp`协议。
|
||||
This project is divided into two parts, the front end uses `flutter`, the back end uses `Golang`, and the two sides communicate through the `http` protocol. On the unix system, `unix socket` is used, and on the windows system, `tcp` protocol is used.
|
||||
|
||||
> 前端代码位于`ui/flutter`目录下。
|
||||
> The front code is located in the `ui/flutter` directory.
|
||||
|
||||
### 环境要求
|
||||
### Environment
|
||||
|
||||
1. Golang 1.9+
|
||||
1. Golang 1.19+
|
||||
2. Flutter 3.0+
|
||||
|
||||
### 克隆项目
|
||||
### Clone
|
||||
|
||||
```bash
|
||||
git clone [email protected]:monkeyWie/gopeed.git
|
||||
```
|
||||
|
||||
### 编译
|
||||
### Build
|
||||
|
||||
#### 桌面端
|
||||
#### Desktop
|
||||
|
||||
首先需要按照[flutter desktop 官网文档](https://docs.flutter.dev/development/platform-integration/desktop)进行环境配置,然后需要准备好`cgo`环境,具体可以自行搜索。
|
||||
First, you need to configure the environment according to the [flutter desktop official website document](https://docs.flutter.dev/development/platform-integration/desktop), and then you need to prepare the `cgo` environment, which can be searched for yourself.
|
||||
|
||||
构建命令:
|
||||
command:
|
||||
|
||||
- windows
|
||||
|
||||
@@ -82,16 +95,16 @@ cd ui/flutter
|
||||
flutter build linux
|
||||
```
|
||||
|
||||
#### 移动端
|
||||
#### Mobile
|
||||
|
||||
同样的也是需要准备好`cgo`环境,接着安装`gomobile`:
|
||||
Same as before, you also need to prepare the `cgo` environment, and then install `gomobile`:
|
||||
|
||||
```bash
|
||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||
gomobile init
|
||||
```
|
||||
|
||||
构建命令:
|
||||
command:
|
||||
|
||||
- android
|
||||
|
||||
@@ -101,11 +114,11 @@ cd ui/flutter
|
||||
flutter build apk
|
||||
```
|
||||
|
||||
#### Web 端(推荐本地调试使用)
|
||||
#### Web
|
||||
|
||||
Web 端直接与后端 http 服务通讯,不需要额外准备环境。
|
||||
Web platform communicates directly with the backend http server, no additional environment is required.
|
||||
|
||||
构建命令:
|
||||
command:
|
||||
|
||||
```bash
|
||||
cd ui/flutter
|
||||
@@ -113,8 +126,8 @@ flutter build web
|
||||
cd ../../
|
||||
cp -r ui/flutter/build/web cmd/web/dist
|
||||
go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/monkeyWie/gopeed/cmd/web
|
||||
```
|
||||
````
|
||||
|
||||
## 开源许可
|
||||
## License
|
||||
|
||||
基于 [GPLv3](LICENSE) 协议开源。
|
||||
[GPLv3](LICENSE)
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
[](https://github.com/monkeyWie/gopeed/actions?query=workflow%3Atest)
|
||||
[](https://codecov.io/gh/monkeyWie/gopeed)
|
||||
[](https://github.com/monkeyWie/gopeed/releases)
|
||||
[](https://discord.gg/ZUJqJrwCGB)
|
||||
|
||||

|
||||
|
||||
[English](/README.md) | [中文](/README_zh-CN.md)
|
||||
|
||||
## 介绍
|
||||
|
||||
Gopeed 是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、BitTorrent、Magnet)协议下载,并且支持全平台使用。
|
||||
|
||||
## 下载
|
||||
|
||||
**已支持平台**
|
||||
|
||||
- [x] windows
|
||||
- [x] macos
|
||||
- [x] linux
|
||||
- [x] android
|
||||
- [ ] ios
|
||||
- [x] web
|
||||
- [x] docker
|
||||
|
||||
[点击前往](https://github.com/monkeyWie/gopeed/releases/latest)
|
||||
|
||||
### 命令行工具
|
||||
|
||||
使用`go install`安装:
|
||||
|
||||
```bash
|
||||
go install github.com/monkeyWie/gopeed/cmd/gopeed
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker run liwei2633/gopeed:latest -v /path/to/download:/download -p 9999:9999
|
||||
```
|
||||
|
||||
当 docker 容器运行时,可以通过 `http://localhost:9999` 访问 web 页面。
|
||||
> 提示:在设置页面把下载路径修改为 `/download` 以便在宿主机访问下载完的文件。
|
||||
|
||||
## 界面展示
|
||||
|
||||

|
||||
|
||||
## 开发
|
||||
|
||||
本项目分为前端和后端两个部分,前端使用`flutter`,后端使用`Golang`,两边通过`http`协议进行通讯,在 unix 系统下,使用的是`unix socket`,在 windows 系统下,使用的是`tcp`协议。
|
||||
|
||||
> 前端代码位于`ui/flutter`目录下。
|
||||
|
||||
### 环境要求
|
||||
|
||||
1. Golang 1.19+
|
||||
2. Flutter 3.0+
|
||||
|
||||
### 克隆项目
|
||||
|
||||
```bash
|
||||
git clone [email protected]:monkeyWie/gopeed.git
|
||||
```
|
||||
|
||||
### 编译
|
||||
|
||||
#### 桌面端
|
||||
|
||||
首先需要按照[flutter desktop 官网文档](https://docs.flutter.dev/development/platform-integration/desktop)进行环境配置,然后需要准备好`cgo`环境,具体可以自行搜索。
|
||||
|
||||
构建命令:
|
||||
|
||||
- windows
|
||||
|
||||
```bash
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build windows
|
||||
```
|
||||
|
||||
- macos
|
||||
|
||||
```bash
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build macos
|
||||
```
|
||||
|
||||
- linux
|
||||
|
||||
```bash
|
||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/monkeyWie/gopeed/bind/desktop
|
||||
cd ui/flutter
|
||||
flutter build linux
|
||||
```
|
||||
|
||||
#### 移动端
|
||||
|
||||
同样的也是需要准备好`cgo`环境,接着安装`gomobile`:
|
||||
|
||||
```bash
|
||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||
gomobile init
|
||||
```
|
||||
|
||||
构建命令:
|
||||
|
||||
- android
|
||||
|
||||
```bash
|
||||
gomobile bind -tags nosqlite -ldflags="-w -s" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 19 -javapkg=com.gopeed github.com/monkeyWie/gopeed/bind/mobile
|
||||
cd ui/flutter
|
||||
flutter build apk
|
||||
```
|
||||
|
||||
#### Web 端(推荐本地调试使用)
|
||||
|
||||
Web 端直接与后端 http 服务通讯,不需要额外准备环境。
|
||||
|
||||
构建命令:
|
||||
|
||||
```bash
|
||||
cd ui/flutter
|
||||
flutter build web
|
||||
cd ../../
|
||||
cp -r ui/flutter/build/web cmd/web/dist
|
||||
go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/monkeyWie/gopeed/cmd/web
|
||||
```
|
||||
|
||||
## 开源许可
|
||||
|
||||
基于 [GPLv3](LICENSE) 协议开源。
|
||||
+1
-2
@@ -4,7 +4,6 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type args struct {
|
||||
@@ -14,7 +13,7 @@ type args struct {
|
||||
}
|
||||
|
||||
func parse() *args {
|
||||
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ func main() {
|
||||
cfg := &model.StartConfig{
|
||||
Network: "tcp",
|
||||
Address: "127.0.0.1:9999",
|
||||
Storage: model.StorageMem,
|
||||
Storage: model.StorageBolt,
|
||||
WebEnable: true,
|
||||
WebFS: sub,
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ android/app/libs/libgopeed-sources.jar
|
||||
|
||||
debian/packages
|
||||
|
||||
generated_plugin_registrant.cc
|
||||
generated_plugin_registrant.h
|
||||
generated_plugins.cmake
|
||||
linux/flutter/generated_plugin_registrant.cc
|
||||
linux/flutter/generated_plugin_registrant.h
|
||||
linux/flutter/generated_plugins.cmake
|
||||
macos/Flutter/GeneratedPluginRegistrant.swift
|
||||
windows/flutter/generated_plugin_registrant.cc
|
||||
windows/flutter/generated_plugin_registrant.h
|
||||
windows/flutter/generated_plugins.cmake
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:dio/adapter.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:gopeed/util/util.dart';
|
||||
import 'model/create_task.dart';
|
||||
import 'model/request.dart';
|
||||
import 'model/resource.dart';
|
||||
@@ -26,7 +27,9 @@ class _Client {
|
||||
final isUnixSocket = LibgopeedBoot.instance.config.network == 'unix';
|
||||
dio.options.baseUrl = isUnixSocket
|
||||
? 'http://127.0.0.1'
|
||||
: 'http://${LibgopeedBoot.instance.config.address}';
|
||||
: (Util.isWeb()
|
||||
? ""
|
||||
: 'http://${LibgopeedBoot.instance.config.address}');
|
||||
_instance!.dio = dio;
|
||||
if (isUnixSocket) {
|
||||
(_instance!.dio.httpClientAdapter as DefaultHttpClientAdapter)
|
||||
|
||||
@@ -9,7 +9,7 @@ class LibgopeedConfig {
|
||||
|
||||
LibgopeedConfig({
|
||||
this.network = "tcp",
|
||||
this.address = "127.0.0.1:9999",
|
||||
this.address = "127.0.0.1:0",
|
||||
this.refreshInterval = 500,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
Locale toLocale(String key) {
|
||||
final arr = key.split('_');
|
||||
return Locale(arr[0], arr[1]);
|
||||
}
|
||||
|
||||
String getLocaleKey(Locale locale) {
|
||||
return '${locale.languageCode}_${locale.countryCode}';
|
||||
}
|
||||
|
||||
final messages = _Messages();
|
||||
const fallbackLocale = Locale('en', 'US');
|
||||
|
||||
class _Messages extends Translations {
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
'zh_CN': {
|
||||
'error': '错误',
|
||||
'confirm': '确认',
|
||||
'cancel': '取消',
|
||||
'home.task': '任务',
|
||||
'home.setting': '设置',
|
||||
'create.title': '创建任务',
|
||||
'create.downloadLink': '下载链接',
|
||||
'create.downloadLinkValid': '请输入下载链接',
|
||||
'create.downloadLinkHit': '请输入下载链接,支持 HTTP/HTTPS/MAGNET@append',
|
||||
'create.downloadLinkHitDesktop': ',也可以直接拖拽种子文件到此处',
|
||||
'create.download': '下载',
|
||||
'create.error.noStoragePermission': '需要开启存储权限',
|
||||
'create.selectDir': '选择目录',
|
||||
'setting.title': '设置',
|
||||
'setting.basic': '基础设置',
|
||||
'setting.theme': '主题',
|
||||
'setting.themeSystem': '跟随系统',
|
||||
'setting.themeLight': '明亮主题',
|
||||
'setting.themeDark': '暗黑主题',
|
||||
'setting.downloadDir': '下载目录',
|
||||
'setting.downloadDirValid': '请选择下载目录',
|
||||
'setting.connections': '连接数',
|
||||
'setting.locale': '语言',
|
||||
'setting.locale.zh_CN': '中文(简体)',
|
||||
'setting.locale.en_US': '英文(美国)',
|
||||
'task.deleteTask': '删除任务',
|
||||
'task.deleteTaskTip': '保留已下载的文件',
|
||||
'task.delete': '删除',
|
||||
},
|
||||
'en_US': {
|
||||
'error': 'Error',
|
||||
'confirm': 'Confirm',
|
||||
'cancel': 'Cancel',
|
||||
'home.task': 'Task',
|
||||
'home.setting': 'Setting',
|
||||
'create.title': 'Create Task',
|
||||
'create.downloadLink': 'Download Link',
|
||||
'create.downloadLinkValid': 'Please enter the download link',
|
||||
'create.downloadLinkHit':
|
||||
'Please enter the download link, HTTP/HTTPS/MAGNET supported@append',
|
||||
'create.downloadLinkHitDesktop':
|
||||
', or drag the torrent file here directly',
|
||||
'create.download': 'Download',
|
||||
'create.error.noStoragePermission': 'Storage permission required',
|
||||
'create.selectDir': 'Select Directory',
|
||||
'setting.title': 'Setting',
|
||||
'setting.basic': 'Basic',
|
||||
'setting.theme': 'Theme',
|
||||
'setting.themeSystem': 'System',
|
||||
'setting.themeLight': 'Light',
|
||||
'setting.themeDark': 'Dark',
|
||||
'setting.downloadDir': 'Download Directory',
|
||||
'setting.downloadDirValid': 'Please select the download directory',
|
||||
'setting.connections': 'Connections',
|
||||
'setting.locale': 'Language',
|
||||
'setting.locale.zh_CN': 'Chinese(Simplified)',
|
||||
'setting.locale.en_US': 'English(US)',
|
||||
'task.deleteTask': 'Delete Task',
|
||||
'task.deleteTaskTip': 'Keep downloaded files',
|
||||
'task.delete': 'Delete',
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'core/libgopeed_boot.dart';
|
||||
import 'i18n/messages.dart';
|
||||
import 'routes/router.dart';
|
||||
import 'setting/setting.dart';
|
||||
import 'theme/theme.dart';
|
||||
@@ -24,6 +25,9 @@ void main() async {
|
||||
theme: GopeedTheme.light,
|
||||
darkTheme: GopeedTheme.dark,
|
||||
themeMode: Setting.instance.themeMode,
|
||||
translations: messages,
|
||||
locale: toLocale(Setting.instance.locale),
|
||||
fallbackLocale: fallbackLocale,
|
||||
getPages: Routes.routes,
|
||||
));
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class CreateController extends GetxController {
|
||||
var currentIndex = 0.obs;
|
||||
}
|
||||
class CreateController extends GetxController {}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:desktop_drop/desktop_drop.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../api/api.dart';
|
||||
@@ -30,65 +31,77 @@ class CreateView extends GetView<CreateController> {
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Get.rootDelegate.offNamed(Routes.task)),
|
||||
actions: [Container()],
|
||||
title: const Text("创建任务"),
|
||||
title: Text('create.title'.tr),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
|
||||
child: Form(
|
||||
key: _resolveFormKey,
|
||||
autovalidateMode: AutovalidateMode.always, //开启自动校验
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
controller: _urlController,
|
||||
minLines: 1,
|
||||
maxLines: 15,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "请输入下载链接,支持 HTTP/HTTPS/MAGNET",
|
||||
labelText: "下载链接",
|
||||
icon: Icon(Icons.link)),
|
||||
validator: (v) {
|
||||
return v!.trim().isNotEmpty ? null : "请输入下载链接";
|
||||
}),
|
||||
// 登录按钮
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
width: 150,
|
||||
height: 40,
|
||||
),
|
||||
child: RoundedLoadingButton(
|
||||
color: Get.theme.colorScheme.secondary,
|
||||
onPressed: () async {
|
||||
if (_resolveFormKey.currentState!.validate()) {
|
||||
_confirmController.start();
|
||||
try {
|
||||
final res = await resolve(Request(
|
||||
url: _urlController.text,
|
||||
));
|
||||
await _showResolveDialog(res);
|
||||
} catch (e) {
|
||||
Get.snackbar("错误", e.toString());
|
||||
} finally {
|
||||
_confirmController.reset();
|
||||
body: DropTarget(
|
||||
onDragDone: (details) {
|
||||
_urlController.text = details.files[0].path;
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
|
||||
child: Form(
|
||||
key: _resolveFormKey,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
controller: _urlController,
|
||||
minLines: 1,
|
||||
maxLines: 15,
|
||||
decoration: InputDecoration(
|
||||
hintText: _hitText(),
|
||||
labelText: 'create.downloadLink'.tr,
|
||||
icon: const Icon(Icons.link)),
|
||||
validator: (v) {
|
||||
return v!.trim().isNotEmpty
|
||||
? null
|
||||
: 'create.downloadLinkValid'.tr;
|
||||
}),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints.tightFor(
|
||||
width: 150,
|
||||
height: 40,
|
||||
),
|
||||
child: RoundedLoadingButton(
|
||||
color: Get.theme.colorScheme.secondary,
|
||||
onPressed: () async {
|
||||
if (_resolveFormKey.currentState!.validate()) {
|
||||
_confirmController.start();
|
||||
try {
|
||||
final res = await resolve(Request(
|
||||
url: _urlController.text,
|
||||
));
|
||||
await _showResolveDialog(res);
|
||||
} catch (e) {
|
||||
Get.snackbar('error'.tr, e.toString());
|
||||
} finally {
|
||||
_confirmController.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
controller: _confirmController,
|
||||
child: const Text("确认"),
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
},
|
||||
controller: _confirmController,
|
||||
child: Text('confirm'.tr),
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _hitText() {
|
||||
return 'create.downloadLinkHit'.trParams({
|
||||
'append': Util.isDesktop() ? 'create.downloadLinkHitDesktop'.tr : '',
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _showResolveDialog(Resource res) async {
|
||||
final createFormKey = GlobalKey<FormState>();
|
||||
final pathController =
|
||||
@@ -142,7 +155,7 @@ class CreateView extends GetView<CreateController> {
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: const Text("取消"),
|
||||
child: Text('cancel'.tr),
|
||||
),
|
||||
),
|
||||
ConstrainedBox(
|
||||
@@ -158,7 +171,8 @@ class CreateView extends GetView<CreateController> {
|
||||
downloadController.start();
|
||||
if (Util.isAndroid()) {
|
||||
if (!await Permission.storage.request().isGranted) {
|
||||
Get.snackbar("错误", "需要开启存储权限");
|
||||
Get.snackbar('error'.tr,
|
||||
'create.error.noStoragePermission'.tr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -179,14 +193,14 @@ class CreateView extends GetView<CreateController> {
|
||||
Get.rootDelegate.offNamed(Routes.task);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar("错误", e.toString());
|
||||
Get.snackbar('error'.tr, e.toString());
|
||||
rethrow;
|
||||
} finally {
|
||||
downloadController.reset();
|
||||
}
|
||||
},
|
||||
controller: downloadController,
|
||||
child: const Text("下载"),
|
||||
child: Text('create.download'.tr),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -37,11 +37,11 @@ class HomeView extends GetView<HomeController> {
|
||||
AnimatedBarItems(
|
||||
icon: const Icon(Icons.list),
|
||||
selectedColor: Get.theme.primaryColor,
|
||||
title: const Text('任务')),
|
||||
title: Text('home.task'.tr)),
|
||||
AnimatedBarItems(
|
||||
icon: const Icon(Icons.settings),
|
||||
selectedColor: Get.theme.primaryColor,
|
||||
title: const Text('设置')),
|
||||
title: Text('home.setting'.tr)),
|
||||
],
|
||||
iconSize: 32,
|
||||
barAnimation: BarAnimation.fade,
|
||||
|
||||
@@ -5,4 +5,8 @@ import '../../setting/setting.dart';
|
||||
class SettingController extends GetxController {
|
||||
final setting = Setting.instance.obs;
|
||||
final tapStatues = <int, bool>{}.obs;
|
||||
|
||||
void clearTapStatus() {
|
||||
tapStatues.clear();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gopeed/i18n/messages.dart';
|
||||
import 'package:gopeed/util/util.dart';
|
||||
import '../../setting/setting.dart';
|
||||
import '../../widget/directory_selector.dart';
|
||||
|
||||
@@ -15,35 +17,42 @@ class SettingView extends GetView<SettingController> {
|
||||
Widget build(BuildContext context) {
|
||||
Timer? timer;
|
||||
debounceSave() {
|
||||
var completer = Completer<void>();
|
||||
timer?.cancel();
|
||||
timer = Timer(const Duration(milliseconds: 500), Setting.instance.save);
|
||||
timer = Timer(const Duration(milliseconds: 500), () {
|
||||
Setting.instance
|
||||
.save()
|
||||
.then(completer.complete)
|
||||
.onError(completer.completeError);
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('设置'),
|
||||
title: Text('setting.title'.tr),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Column(
|
||||
// 左对齐
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("基本设置", style: Get.textTheme.titleLarge),
|
||||
Text('setting.basic'.tr, style: Get.textTheme.titleLarge),
|
||||
const SizedBox(height: 10),
|
||||
Obx(() => Card(
|
||||
child: Column(
|
||||
children: _buildConfigItems([
|
||||
_ConfigItem(
|
||||
"主题",
|
||||
'setting.theme'.tr,
|
||||
() => _getThemeName(controller.setting.value.themeMode),
|
||||
() => DropdownButton<ThemeMode>(
|
||||
value: controller.setting.value.themeMode,
|
||||
isDense: true,
|
||||
onChanged: (value) {
|
||||
onChanged: (value) async {
|
||||
controller.setting.value.themeMode = value!;
|
||||
controller.clearTapStatus();
|
||||
Get.changeThemeMode(value);
|
||||
|
||||
debounceSave();
|
||||
await debounceSave();
|
||||
},
|
||||
items: ThemeMode.values
|
||||
.map((e) => DropdownMenuItem<ThemeMode>(
|
||||
@@ -52,17 +61,20 @@ class SettingView extends GetView<SettingController> {
|
||||
))
|
||||
.toList(),
|
||||
)),
|
||||
_ConfigItem(
|
||||
"下载目录", () => controller.setting.value.downloadDir, () {
|
||||
_ConfigItem('setting.downloadDir'.tr,
|
||||
() => controller.setting.value.downloadDir, () {
|
||||
final downloadDirController = TextEditingController(
|
||||
text: controller.setting.value.downloadDir);
|
||||
downloadDirController.addListener(() {
|
||||
downloadDirController.addListener(() async {
|
||||
if (downloadDirController.text !=
|
||||
controller.setting.value.downloadDir) {
|
||||
controller.setting.value.downloadDir =
|
||||
downloadDirController.text;
|
||||
if (Util.isDesktop()) {
|
||||
controller.clearTapStatus();
|
||||
}
|
||||
|
||||
debounceSave();
|
||||
await debounceSave();
|
||||
}
|
||||
});
|
||||
return DirectorySelector(
|
||||
@@ -70,19 +82,19 @@ class SettingView extends GetView<SettingController> {
|
||||
showLabel: false,
|
||||
);
|
||||
}),
|
||||
_ConfigItem("连接数",
|
||||
_ConfigItem('setting.connections'.tr,
|
||||
() => controller.setting.value.connections.toString(),
|
||||
() {
|
||||
final connectionsController = TextEditingController(
|
||||
text: controller.setting.value.connections.toString());
|
||||
connectionsController.addListener(() {
|
||||
connectionsController.addListener(() async {
|
||||
if (connectionsController.text.isNotEmpty &&
|
||||
connectionsController.text !=
|
||||
controller.setting.value.connections.toString()) {
|
||||
controller.setting.value.connections =
|
||||
int.parse(connectionsController.text);
|
||||
|
||||
debounceSave();
|
||||
await debounceSave();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -95,6 +107,27 @@ class SettingView extends GetView<SettingController> {
|
||||
],
|
||||
);
|
||||
}),
|
||||
_ConfigItem(
|
||||
'setting.locale'.tr,
|
||||
() => _getLocaleName(controller.setting.value.locale),
|
||||
() => DropdownButton<String>(
|
||||
value: controller.setting.value.locale,
|
||||
isDense: true,
|
||||
onChanged: (value) async {
|
||||
controller.setting.value.locale = value!;
|
||||
controller.clearTapStatus();
|
||||
Get.updateLocale(toLocale(value));
|
||||
|
||||
await debounceSave();
|
||||
},
|
||||
items: _getLocales()
|
||||
.map((e) => DropdownMenuItem<String>(
|
||||
value:
|
||||
e.substring(_settingLocaleKey.length),
|
||||
child: Text(e.tr),
|
||||
))
|
||||
.toList(),
|
||||
)),
|
||||
]),
|
||||
))),
|
||||
],
|
||||
@@ -130,13 +163,30 @@ class SettingView extends GetView<SettingController> {
|
||||
String _getThemeName(ThemeMode themeMode) {
|
||||
switch (themeMode) {
|
||||
case ThemeMode.system:
|
||||
return "跟随系统";
|
||||
return 'setting.themeSystem'.tr;
|
||||
case ThemeMode.light:
|
||||
return "明亮主题";
|
||||
return 'setting.themeLight'.tr;
|
||||
case ThemeMode.dark:
|
||||
return "暗黑主题";
|
||||
return 'setting.themeDark'.tr;
|
||||
}
|
||||
}
|
||||
|
||||
final _settingLocaleKey = 'setting.locale.';
|
||||
|
||||
List<String> _getLocales() {
|
||||
return messages.keys[getLocaleKey(fallbackLocale)]!.entries
|
||||
.where((e) => e.key.startsWith(_settingLocaleKey))
|
||||
.map((e) => e.key)
|
||||
.toList();
|
||||
}
|
||||
|
||||
String _getLocaleName(String locale) {
|
||||
final localeKey = '$_settingLocaleKey${locale.toString()}';
|
||||
if (messages.keys[locale]?.containsKey(localeKey) ?? false) {
|
||||
return localeKey.tr;
|
||||
}
|
||||
return '$_settingLocaleKey$locale'.tr;
|
||||
}
|
||||
}
|
||||
|
||||
class _ConfigItem {
|
||||
|
||||
@@ -65,8 +65,6 @@ class Item extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var controller = Get.find<TaskController>();
|
||||
|
||||
return Card(
|
||||
elevation: 4.0,
|
||||
child: InkWell(
|
||||
@@ -153,22 +151,23 @@ class Item extends StatelessWidget {
|
||||
context: Get.context!,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text("删除任务"),
|
||||
title: Text('task.deleteTask'.tr),
|
||||
content: Obx(() => CheckboxListTile(
|
||||
value: keep.value,
|
||||
title: Text("保留已下载的文件", style: Get.textTheme.bodyText1),
|
||||
title: Text('task.deleteTaskTip'.tr,
|
||||
style: Get.textTheme.bodyText1),
|
||||
onChanged: (v) {
|
||||
keep.value = v!;
|
||||
})),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("取消"),
|
||||
onPressed: () => Get.back(), //关闭对话框
|
||||
child: Text('cancel'.tr),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text(
|
||||
"删除",
|
||||
style: TextStyle(color: Colors.redAccent),
|
||||
child: Text(
|
||||
'task.delete'.tr,
|
||||
style: const TextStyle(color: Colors.redAccent),
|
||||
),
|
||||
onPressed: () async {
|
||||
try {
|
||||
@@ -176,7 +175,7 @@ class Item extends StatelessWidget {
|
||||
Get.find<TaskController>().loadTab();
|
||||
Get.back();
|
||||
} catch (e) {
|
||||
Get.snackbar("错误", e.toString());
|
||||
Get.snackbar('error'.tr, e.toString());
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import 'package:external_path/external_path.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gopeed/i18n/messages.dart';
|
||||
import '../api/api.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import '../api/model/server_config.dart';
|
||||
import '../util/util.dart';
|
||||
|
||||
@@ -11,21 +14,16 @@ class Setting {
|
||||
int port = 0;
|
||||
int connections = 0;
|
||||
String downloadDir = "";
|
||||
ThemeMode themeMode = ThemeMode.system;
|
||||
|
||||
Setting({
|
||||
required this.host,
|
||||
required this.port,
|
||||
required this.connections,
|
||||
required this.downloadDir,
|
||||
required this.themeMode,
|
||||
});
|
||||
late ThemeMode themeMode;
|
||||
late String locale;
|
||||
|
||||
// singleton pattern
|
||||
static Setting? _instance;
|
||||
|
||||
static Setting get instance {
|
||||
_instance ??= Setting._internal();
|
||||
_instance!.themeMode = ThemeMode.system;
|
||||
_instance!.locale = getLocaleKey(ui.window.locale);
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
@@ -38,11 +36,13 @@ class Setting {
|
||||
connections = config.connections;
|
||||
downloadDir = config.downloadDir;
|
||||
final themeMode = config.extra?['themeMode'];
|
||||
if (themeMode == null) {
|
||||
this.themeMode = ThemeMode.system;
|
||||
} else {
|
||||
if (themeMode != null) {
|
||||
this.themeMode = ThemeMode.values.byName(themeMode);
|
||||
}
|
||||
final locale = config.extra?['locale'];
|
||||
if (locale != null) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
if (Util.isWeb()) {
|
||||
downloadDir = "./";
|
||||
@@ -69,6 +69,7 @@ class Setting {
|
||||
downloadDir: downloadDir,
|
||||
extra: {
|
||||
'themeMode': themeMode.name,
|
||||
'locale': locale,
|
||||
},
|
||||
);
|
||||
await putConfig(config);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gopeed/util/util.dart';
|
||||
|
||||
import '../util/mac_secure_util.dart';
|
||||
|
||||
@@ -23,29 +24,31 @@ class _DirectorySelectorState extends State<DirectorySelector> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
readOnly: true,
|
||||
readOnly: Util.isWeb() ? false : true,
|
||||
controller: widget.controller,
|
||||
decoration: widget.showLabel
|
||||
? const InputDecoration(
|
||||
labelText: "下载目录",
|
||||
? InputDecoration(
|
||||
labelText: 'setting.downloadDir'.tr,
|
||||
)
|
||||
: null,
|
||||
validator: (v) {
|
||||
return v!.trim().isNotEmpty ? null : "请选择下载目录";
|
||||
return v!.trim().isNotEmpty ? null : 'setting.downloadDirValid'.tr;
|
||||
},
|
||||
)),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.folder_open),
|
||||
onPressed: () async {
|
||||
if (GetPlatform.isDesktop) {
|
||||
var dir = await getDirectoryPath();
|
||||
if (dir != null) {
|
||||
widget.controller.text = dir;
|
||||
MacSecureUtil.saveBookmark(dir);
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
!Util.isDesktop()
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.folder_open),
|
||||
onPressed: () async {
|
||||
if (GetPlatform.isDesktop) {
|
||||
var dir = await getDirectoryPath();
|
||||
if (dir != null) {
|
||||
widget.controller.text = dir;
|
||||
MacSecureUtil.saveBookmark(dir);
|
||||
}
|
||||
}
|
||||
})
|
||||
].where((e) => e != null).map((e) => e!).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../util/util.dart';
|
||||
|
||||
import '../api/model/resource.dart';
|
||||
@@ -29,7 +30,8 @@ class _FileListViewState extends State<FileListView> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(padding: EdgeInsets.only(top: 10)),
|
||||
Text("选择文件", style: TextStyle(color: themeData.hintColor)),
|
||||
Text('create.selectDir'.tr,
|
||||
style: TextStyle(color: themeData.hintColor)),
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void fl_register_plugins(FlPluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
@@ -1,25 +0,0 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_linux
|
||||
url_launcher_linux
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import file_selector_macos
|
||||
import macos_secure_bookmarks
|
||||
import path_provider_macos
|
||||
import shared_preferences_macos
|
||||
import url_launcher_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
SecureBookmarksPlugin.register(with: registry.registrar(forPlugin: "SecureBookmarksPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
PODS:
|
||||
- desktop_drop (0.0.1):
|
||||
- FlutterMacOS
|
||||
- file_selector_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- FlutterMacOS (1.0.0)
|
||||
@@ -12,6 +14,7 @@ PODS:
|
||||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`)
|
||||
- file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`)
|
||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||
- macos_secure_bookmarks (from `Flutter/ephemeral/.symlinks/plugins/macos_secure_bookmarks/macos`)
|
||||
@@ -20,6 +23,8 @@ DEPENDENCIES:
|
||||
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
desktop_drop:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos
|
||||
file_selector_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos
|
||||
FlutterMacOS:
|
||||
@@ -34,6 +39,7 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
|
||||
file_selector_macos: f1b08a781e66103e3ba279fd5d4024a2478b3af6
|
||||
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
|
||||
macos_secure_bookmarks: cff041c4b377fa00941bb901aaec4d27fac5edf2
|
||||
|
||||
@@ -183,6 +183,13 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.2.4"
|
||||
desktop_drop:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: desktop_drop
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.3.3"
|
||||
dio:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -49,6 +49,7 @@ dependencies:
|
||||
permission_handler: ^10.1.0
|
||||
external_path: ^1.0.3
|
||||
logger: ^1.1.0
|
||||
desktop_drop: ^0.3.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_windows/file_selector_windows.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FileSelectorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter/plugin_registry.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
@@ -1,26 +0,0 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_windows
|
||||
permission_handler_windows
|
||||
url_launcher_windows
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
||||
Reference in new issue
Block a user