fix: serval bugs

This commit is contained in:
Simon Ding
2024-07-12 13:35:37 +08:00
parent 76bf358de7
commit cfa6d2d54c
7 changed files with 79 additions and 40 deletions

View File

@@ -1,31 +1,9 @@
FROM ubuntu:20.04 as flutter_build
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback python3
RUN apt-get clean
# download Flutter SDK from Flutter Github repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# Set flutter environment path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Run flutter doctor
RUN flutter doctor
# Enable flutter web
RUN flutter channel stable
RUN flutter upgrade
RUN flutter config --enable-web
# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
RUN flutter build web
FROM instrumentisto/flutter:3 AS flutter
WORKDIR /app
COPY ./ui/pubspec.yaml ./ui/pubspec.lock ./
RUN flutter pub get
COPY ./ui/ ./
RUN flutter build web
# 打包依赖阶段使用golang作为基础镜像
@@ -37,14 +15,15 @@ ENV GO111MODULE=on \
WORKDIR /app
COPY --from=flutter_build go.mod .
COPY --from=flutter_build go.sum .
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY --from=flutter_build . .
COPY . .
COPY --from=flutter /app/build/web ./ui/build/web/
# 指定OS等并go build
RUN GOOS=linux GOARCH=amd64 go build -o polaris ./cmd/
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o polaris ./cmd/
FROM debian:12

View File

@@ -245,12 +245,19 @@ func (c *Client) AddStorage(s StorageInfo) error {
SetImplementation(s.Implementation).
SetPath(s.Path).
SetUser(s.User).
SetDefault(s.Default).
SetPassword(s.Password).Exec(context.TODO())
}
countAll := c.ent.Storage.Query().CountX(context.TODO())
if countAll == 0 {
log.Infof("first storage, make it default: %s", s.Name)
s.Default = true
}
_, err := c.ent.Storage.Create().SetName(s.Name).
SetImplementation(s.Implementation).
SetPath(s.Path).
SetUser(s.User).
SetDefault(s.Default).
SetPassword(s.Password).Save(context.TODO())
if err != nil {
return err

11
ui/lib/activity.dart Normal file
View File

@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class ActivityPage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
// TODO: implement build
throw UnimplementedError();
}
}

View File

@@ -63,6 +63,9 @@ class IndexerSetting extends AsyncNotifier<List<Indexer>> {
throw sp.message;
}
List<Indexer> indexers = List.empty(growable: true);
if (sp.data == null) {
return indexers;
}
for (final item in sp.data as List) {
indexers.add(Indexer.fromJson(item));
}
@@ -128,6 +131,9 @@ class DownloadClientSetting extends AsyncNotifier<List<DownloadClient>> {
throw sp.message;
}
List<DownloadClient> indexers = List.empty(growable: true);
if (sp.data == null) {
return indexers;
}
for (final item in sp.data as List) {
indexers.add(DownloadClient.fromJson(item));
}
@@ -203,7 +209,6 @@ class DownloadClient {
}
class StorageSettingData extends AsyncNotifier<List<Storage>> {
@override
FutureOr<List<Storage>> build() async {
final dio = await APIs.getDio();
@@ -237,6 +242,7 @@ class StorageSettingData extends AsyncNotifier<List<Storage>> {
if (sp.code != 0) {
throw sp.message;
}
ref.invalidateSelf();
}
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:ui/providers/APIs.dart';
import 'package:ui/providers/settings.dart';
import 'package:ui/providers/welcome_data.dart';
class SearchPage extends ConsumerStatefulWidget {
@@ -89,12 +90,42 @@ class _SearchPageState extends ConsumerState<SearchPage> {
}
Future<void> _showSubmitDialog(BuildContext context, SearchResult item) {
TextEditingController resolutionController =
TextEditingController(text: "1080p");
TextEditingController storageController = TextEditingController();
var storage = ref.watch(storageSettingProvider);
return showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('添加剧集'),
content: Text("是否添加剧集: ${item.name}"),
title: Text('添加剧集: ${item.name}'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
DropdownMenu(
label: const Text("清晰度"),
controller: resolutionController,
dropdownMenuEntries: const [
DropdownMenuEntry(value: "720p", label: "720p"),
DropdownMenuEntry(value: "1080p", label: "1080p"),
DropdownMenuEntry(value: "4k", label: "4k"),
],
),
storage.when(
data: (v) {
return DropdownMenu(
label: const Text("存储位置"),
controller: storageController,
dropdownMenuEntries: v
.map((s) =>
DropdownMenuEntry(label: s.name!, value: s.id))
.toList(),
);
},
error: (err, trace) => Text("$err"),
loading: () => const CircularProgressIndicator()),
],
),
actions: <Widget>[
TextButton(
style: TextButton.styleFrom(

View File

@@ -72,8 +72,7 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
});
if (!Utils.showError(context, snapshot)) {
var name = await f;
Utils.showSnakeBar(
context, "开始下载: $name");
Utils.showSnakeBar(context, "开始下载: $name");
}
},
icon: const Icon(Icons.search))
@@ -140,7 +139,11 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
error: (err, trace) {
return Text("$err");
},
loading: () => const CircularProgressIndicator());
loading: () => const Center(
child: SizedBox(
width: 30,
height: 30,
child: CircularProgressIndicator())));
});
}
}

View File

@@ -16,7 +16,7 @@ class WelcomePage extends ConsumerWidget {
return switch (data) {
AsyncData(:final value) => GridView.builder(
padding: const EdgeInsets.all(30),
padding: const EdgeInsets.all(30),
itemCount: value.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 6),
@@ -48,7 +48,9 @@ class WelcomePage extends ConsumerWidget {
),
));
}),
_ => const CircularProgressIndicator(),
_ => const Center(
child: SizedBox(
width: 30, height: 30, child: CircularProgressIndicator())),
};
}
}