Skip to content

Commit 0f1b6fd

Browse files
committed
ci: add windows build, fix err when setting not exists
1 parent c90c9a0 commit 0f1b6fd

File tree

8 files changed

+71
-18
lines changed

8 files changed

+71
-18
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,46 @@ jobs:
133133
name: macos-result
134134
path: app/build/macos/Build/Products/Release/dist/*.dmg
135135

136+
build-windows:
137+
needs:
138+
- get-version
139+
runs-on: windows-latest
140+
141+
steps:
142+
- name: Checkout
143+
uses: actions/checkout@v4
144+
145+
- name: Setup Go
146+
uses: actions/setup-go@v4
147+
with:
148+
go-version: ${{ env.GO_VERSION }}
149+
150+
- name: Setup Flutter
151+
uses: subosito/flutter-action@v2
152+
with:
153+
flutter-version: ${{ env.FLUTTER_VERSION }}
154+
155+
- name: Build dll
156+
run: |
157+
cd server
158+
go build -ldflags="-w -s -X github.com/honmaple/maple-file/server/internal/app.VERSION=${{ needs.get-version.outputs.version }}" -buildmode=c-shared -o ../app/windows/libserver.dll github.com/honmaple/maple-file/server/cmd/desktop
159+
160+
- name: Build exe
161+
run: |
162+
cd app
163+
flutter pub get
164+
dart run build_runner build
165+
flutter build windows
166+
167+
mkdir dist
168+
Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath dist/maple-file-${{ needs.get-version.outputs.version }}-windows-x86_64.zip
169+
170+
- name: Upload exe file
171+
uses: actions/upload-artifact@v4
172+
with:
173+
name: windows-result
174+
path: app/dist/maple-file-*.zip
175+
136176
build-android:
137177
needs:
138178
- get-version
@@ -200,6 +240,7 @@ jobs:
200240
release:
201241
needs:
202242
- build-macos
243+
- build-windows
203244
- build-android
204245
runs-on: ubuntu-22.04
205246

@@ -216,6 +257,12 @@ jobs:
216257
name: macos-result
217258
path: macos-result
218259

260+
- name: Download exe file
261+
uses: actions/download-artifact@v4
262+
with:
263+
name: windows-result
264+
path: windows-result
265+
219266
- name: Download apk file
220267
uses: actions/download-artifact@v4
221268
with:
@@ -228,5 +275,6 @@ jobs:
228275
with:
229276
files: |
230277
macos-result/*.dmg
278+
windows-result/*.zip
231279
android-result/*.apk
232280
token: ${{ secrets.GITHUB_TOKEN }}

app/lib/app/app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class App {
4949
WindowOptions windowOptions = WindowOptions(
5050
size: const Size(800, 600),
5151
center: true,
52-
backgroundColor: Colors.transparent,
52+
backgroundColor: Util.isWindows ? null : Colors.transparent,
5353
titleBarStyle:
5454
Util.isWindows ? TitleBarStyle.normal : TitleBarStyle.hidden,
5555
);

app/lib/app/grpc_io.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import 'dart:ffi' as ffi;
22
import 'dart:io';
3-
import 'package:path_provider/path_provider.dart';
43
import 'package:grpc/grpc.dart';
54
import 'package:grpc/service_api.dart' as grpcapi;
65
import 'package:ffi/ffi.dart';
76

87
import 'package:flutter/services.dart';
98

109
import '../common/utils/util.dart';
10+
import '../common/utils/path.dart';
1111
import '../generated/ffi/libserver.dart';
1212

1313
class GrpcService {
@@ -34,9 +34,9 @@ class GrpcService {
3434
}
3535

3636
Future<String> _initMobile() async {
37-
final directory = await getApplicationDocumentsDirectory();
37+
final path = await PathUtil.getApplicationPath();
3838
final Map<String, dynamic> args = {
39-
'path': directory.path,
39+
'path': path,
4040
};
4141

4242
return await platform.invokeMethod("Start", args).catchError((err) {
@@ -55,8 +55,7 @@ class GrpcService {
5555
libname += ".so";
5656
}
5757

58-
final directory = await getApplicationDocumentsDirectory();
59-
final path = directory.path;
58+
final path = await PathUtil.getApplicationPath();
6059

6160
// ffi.Char
6261
final lib = LibserverBind(ffi.DynamicLibrary.open(libname));

app/lib/common/utils/path.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,19 @@ class PathUtil {
3939
}
4040

4141
static Future<String> getApplicationPath() async {
42-
final dir = await getApplicationDocumentsDirectory();
43-
return dir.path;
42+
switch (defaultTargetPlatform) {
43+
case TargetPlatform.windows:
44+
final executablePath = Platform.resolvedExecutable;
45+
final executableParentPath = File(executablePath).parent.path;
46+
return executableParentPath;
47+
default:
48+
return (await getApplicationDocumentsDirectory()).path;
49+
}
4450
}
4551

4652
static Future<String> getDatabasePath() async {
47-
final dir = await getApplicationDocumentsDirectory();
48-
return filepath.join(dir.path, "server.db");
53+
final path = await getApplicationPath();
54+
return filepath.join(path, "server.db");
4955
}
5056

5157
static RegExp exp = RegExp(r'(.*?)\.(\d+)$');

server/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ toolchain go1.23.4
77
require (
88
github.com/PuerkitoBio/goquery v1.10.0
99
github.com/aws/aws-sdk-go v1.51.21
10-
github.com/elliotchance/orderedmap/v3 v3.0.0
1110
github.com/go-playground/locales v0.14.1
1211
github.com/go-playground/universal-translator v0.18.1
1312
github.com/go-playground/validator/v10 v10.23.0
@@ -97,3 +96,5 @@ require (
9796
gopkg.in/yaml.v3 v3.0.1 // indirect
9897
nhooyr.io/websocket v1.8.6 // indirect
9998
)
99+
100+
replace nhooyr.io/websocket => github.com/coder/websocket v1.8.7

server/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
7878
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
7979
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
8080
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
81+
github.com/coder/websocket v1.8.7 h1:jiep6gmlfP/yq2w1gBoubJEXL9gf8x3bp6lzzX8nJxE=
82+
github.com/coder/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
8183
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
8284
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
8385
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
@@ -97,8 +99,6 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
9799
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
98100
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
99101
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
100-
github.com/elliotchance/orderedmap/v3 v3.0.0 h1:Yay/tDjX+vzza+Drcoo8VEbuBnOYGpgenCXWcpQSFDg=
101-
github.com/elliotchance/orderedmap/v3 v3.0.0/go.mod h1:G+Hc2RwaZvJMcS4JpGCOyViCnGeKf0bTYCGTO4uhjSo=
102102
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
103103
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
104104
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -933,8 +933,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
933933
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
934934
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
935935
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
936-
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
937-
nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
938936
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
939937
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
940938
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

server/internal/api/file/service/file.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ func (srv *Service) upload(ctx context.Context, req *pb.FileRequest, reader io.R
142142
filename := req.GetFilename()
143143

144144
cf, err := srv.getSetting(ctx, "app.file")
145+
// 不要返回错误
145146
if err != nil {
146-
return nil, err
147+
cf = viper.New()
147148
}
148149

149150
if limitSize := cf.GetInt32("upload.limit_size"); limitSize > 0 && req.GetSize() > limitSize*1024*1024 {

server/pkg/driver/local/local.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ func (d *Local) getActualPath(path string) string {
3333
if runtime.GOOS != "windows" {
3434
return filepath.Join(d.opt.Path, path)
3535
}
36-
return filepath.Join(d.opt.Path, filepath.ToSlash(path))
36+
return filepath.Join(d.opt.Path, filepath.FromSlash(path))
3737
}
3838

3939
func (d *Local) getActualFile(file driver.File) driver.File {
4040
if runtime.GOOS != "windows" {
4141
return file
4242
}
43-
return driver.NewFile(filepath.FromSlash(file.Path()), file)
43+
return driver.NewFile(filepath.ToSlash(file.Path()), file)
4444
}
4545

4646
func (d *Local) List(ctx context.Context, path string, metas ...driver.Meta) ([]driver.File, error) {

0 commit comments

Comments
 (0)