feat(web,server): external domain setting (#6146)

* feat: external domain setting

* chore: open api

* mobile: handle serverconfig-externalDomain

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
Jason Rasmussen
2024-01-03 21:54:48 -05:00
committed by GitHub
parent 1e503c3212
commit 317adc5c28
35 changed files with 433 additions and 23 deletions

View File

@@ -2,35 +2,40 @@ import 'package:openapi/api.dart';
class ServerConfig {
final int trashDays;
final String externalDomain;
const ServerConfig({
required this.trashDays,
required this.externalDomain,
});
ServerConfig copyWith({
int? trashDays,
String? externalDomain,
}) {
return ServerConfig(
trashDays: trashDays ?? this.trashDays,
externalDomain: externalDomain ?? this.externalDomain,
);
}
@override
String toString() {
return 'ServerConfig(trashDays: $trashDays)';
}
String toString() =>
'ServerConfig(trashDays: $trashDays, externalDomain: $externalDomain)';
ServerConfig.fromDto(ServerConfigDto dto) : trashDays = dto.trashDays;
ServerConfig.fromDto(ServerConfigDto dto)
: trashDays = dto.trashDays,
externalDomain = dto.externalDomain;
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ServerConfig && other.trashDays == trashDays;
return other is ServerConfig &&
other.trashDays == trashDays &&
other.externalDomain == externalDomain;
}
@override
int get hashCode {
return trashDays.hashCode;
}
int get hashCode => trashDays.hashCode ^ externalDomain.hashCode;
}

View File

@@ -29,6 +29,7 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
),
serverConfig: const ServerConfig(
trashDays: 30,
externalDomain: '',
),
serverDiskInfo: const ServerDiskInfo(
diskAvailable: "0",
@@ -74,7 +75,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
if (appVersion["major"]! > serverVersion.major) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_server_out_of_date_major".tr(),
versionMismatchErrorMessage:
"profile_drawer_server_out_of_date_major".tr(),
);
return;
}
@@ -82,7 +84,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
if (appVersion["major"]! < serverVersion.major) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_client_out_of_date_major".tr(),
versionMismatchErrorMessage:
"profile_drawer_client_out_of_date_major".tr(),
);
return;
}
@@ -90,7 +93,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
if (appVersion["minor"]! > serverVersion.minor) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_server_out_of_date_minor".tr(),
versionMismatchErrorMessage:
"profile_drawer_server_out_of_date_minor".tr(),
);
return;
}
@@ -98,7 +102,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
if (appVersion["minor"]! < serverVersion.minor) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_client_out_of_date_minor".tr(),
versionMismatchErrorMessage:
"profile_drawer_client_out_of_date_minor".tr(),
);
return;
}