mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: enable debug with localhost (#4058)
This commit is contained in:
parent
066bba95f5
commit
afab3d5374
4
frontend/.vscode/tasks.json
vendored
4
frontend/.vscode/tasks.json
vendored
@ -14,7 +14,6 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"AF: Dart Clean",
|
|
||||||
"AF: Flutter Clean",
|
"AF: Flutter Clean",
|
||||||
"AF: Build Appflowy Core",
|
"AF: Build Appflowy Core",
|
||||||
"AF: Flutter Pub Get",
|
"AF: Flutter Pub Get",
|
||||||
@ -33,7 +32,6 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"AF: Dart Clean",
|
|
||||||
"AF: Flutter Clean",
|
"AF: Flutter Clean",
|
||||||
"AF: Build Appflowy Core For iOS",
|
"AF: Build Appflowy Core For iOS",
|
||||||
"AF: Flutter Pub Get",
|
"AF: Flutter Pub Get",
|
||||||
@ -52,7 +50,6 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"AF: Dart Clean",
|
|
||||||
"AF: Flutter Clean",
|
"AF: Flutter Clean",
|
||||||
"AF: Build Appflowy Core For iOS Simulator",
|
"AF: Build Appflowy Core For iOS Simulator",
|
||||||
"AF: Flutter Pub Get",
|
"AF: Flutter Pub Get",
|
||||||
@ -89,7 +86,6 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"AF: Dart Clean",
|
|
||||||
"AF: Flutter Clean",
|
"AF: Flutter Clean",
|
||||||
"AF: Build Appflowy Core For Android",
|
"AF: Build Appflowy Core For Android",
|
||||||
"AF: Flutter Pub Get",
|
"AF: Flutter Pub Get",
|
||||||
|
35
frontend/appflowy_flutter/lib/env/cloud_env.dart
vendored
35
frontend/appflowy_flutter/lib/env/cloud_env.dart
vendored
@ -186,6 +186,7 @@ class AppFlowyCloudSharedEnv {
|
|||||||
AuthenticatorType get authenticatorType => _authenticatorType;
|
AuthenticatorType get authenticatorType => _authenticatorType;
|
||||||
|
|
||||||
static Future<AppFlowyCloudSharedEnv> fromEnv() async {
|
static Future<AppFlowyCloudSharedEnv> fromEnv() async {
|
||||||
|
// If [Env.enableCustomCloud] is true, then use the custom cloud configuration.
|
||||||
if (Env.enableCustomCloud) {
|
if (Env.enableCustomCloud) {
|
||||||
// Use the custom cloud configuration.
|
// Use the custom cloud configuration.
|
||||||
final cloudType = await getAuthenticatorType();
|
final cloudType = await getAuthenticatorType();
|
||||||
@ -198,6 +199,7 @@ class AppFlowyCloudSharedEnv {
|
|||||||
supabaseConfig: supabaseCloudConfig,
|
supabaseConfig: supabaseCloudConfig,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// Using the cloud settings from the .env file.
|
||||||
final appflowyCloudConfig = AppFlowyCloudConfiguration(
|
final appflowyCloudConfig = AppFlowyCloudConfiguration(
|
||||||
base_url: Env.afCloudUrl,
|
base_url: Env.afCloudUrl,
|
||||||
ws_base_url: await _getAppFlowyCloudWSUrl(Env.afCloudUrl),
|
ws_base_url: await _getAppFlowyCloudWSUrl(Env.afCloudUrl),
|
||||||
@ -213,13 +215,36 @@ class AppFlowyCloudSharedEnv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<AppFlowyCloudConfiguration> configurationFromUri(
|
||||||
|
Uri baseUri,
|
||||||
|
String baseUrl,
|
||||||
|
) async {
|
||||||
|
// When the host is set to 'localhost', the application will utilize the local configuration. This setup assumes that 'localhost' does not employ a reverse proxy, therefore default port settings are used.
|
||||||
|
if (baseUri.host == "localhost") {
|
||||||
|
return AppFlowyCloudConfiguration(
|
||||||
|
base_url: "$baseUrl:8000",
|
||||||
|
ws_base_url: "ws://${baseUri.host}:8000/ws",
|
||||||
|
gotrue_url: "$baseUrl:9998",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return AppFlowyCloudConfiguration(
|
||||||
|
base_url: baseUrl,
|
||||||
|
ws_base_url: await _getAppFlowyCloudWSUrl(Env.afCloudUrl),
|
||||||
|
gotrue_url: await _getAppFlowyCloudGotrueUrl(Env.afCloudUrl),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<AppFlowyCloudConfiguration> getAppFlowyCloudConfig() async {
|
Future<AppFlowyCloudConfiguration> getAppFlowyCloudConfig() async {
|
||||||
final baseURL = await getAppFlowyCloudUrl();
|
final baseURL = await getAppFlowyCloudUrl();
|
||||||
return AppFlowyCloudConfiguration(
|
|
||||||
base_url: baseURL,
|
try {
|
||||||
ws_base_url: await _getAppFlowyCloudWSUrl(baseURL),
|
final uri = Uri.parse(baseURL);
|
||||||
gotrue_url: await _getAppFlowyCloudGotrueUrl(baseURL),
|
return await configurationFromUri(uri, baseURL);
|
||||||
);
|
} catch (e) {
|
||||||
|
Log.error("Failed to parse AppFlowy Cloud URL: $e");
|
||||||
|
return AppFlowyCloudConfiguration.defaultConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getAppFlowyCloudUrl() async {
|
Future<String> getAppFlowyCloudUrl() async {
|
||||||
|
1
frontend/appflowy_flutter/lib/env/env.dart
vendored
1
frontend/appflowy_flutter/lib/env/env.dart
vendored
@ -6,6 +6,7 @@ part 'env.g.dart';
|
|||||||
|
|
||||||
@Envied(path: '.env')
|
@Envied(path: '.env')
|
||||||
abstract class Env {
|
abstract class Env {
|
||||||
|
// This flag is used to decide if users can dynamically configure cloud settings. It turns true when a .env file exists containing the APPFLOWY_CLOUD_URL variable. By default, this is set to false.
|
||||||
static bool get enableCustomCloud {
|
static bool get enableCustomCloud {
|
||||||
return Env.authenticatorType == AuthenticatorType.appflowyCloud.value &&
|
return Env.authenticatorType == AuthenticatorType.appflowyCloud.value &&
|
||||||
_Env.afCloudUrl.isEmpty;
|
_Env.afCloudUrl.isEmpty;
|
||||||
|
@ -44,24 +44,33 @@ class SettingAppFlowyCloudView extends StatelessWidget {
|
|||||||
BlocProvider<AppFlowyCloudSettingBloc> _renderContent(
|
BlocProvider<AppFlowyCloudSettingBloc> _renderContent(
|
||||||
CloudSettingPB setting,
|
CloudSettingPB setting,
|
||||||
) {
|
) {
|
||||||
|
final List<Widget> children = [];
|
||||||
|
children.addAll([
|
||||||
|
const AppFlowyCloudEnableSync(),
|
||||||
|
const VSpace(40),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// If the enableCustomCloud flag is true, then the user can dynamically configure cloud settings. Otherwise, the user cannot dynamically configure cloud settings.
|
||||||
|
if (Env.enableCustomCloud) {
|
||||||
|
children.add(
|
||||||
|
AppFlowyCloudURLs(didUpdateUrls: () => didResetServerUrl()),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
children.add(
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
FlowyText(LocaleKeys.settings_menu_cloudServerType.tr()),
|
||||||
|
const Spacer(),
|
||||||
|
const FlowyText(Env.afCloudUrl),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => AppFlowyCloudSettingBloc(setting)
|
create: (context) => AppFlowyCloudSettingBloc(setting)
|
||||||
..add(const AppFlowyCloudSettingEvent.initial()),
|
..add(const AppFlowyCloudSettingEvent.initial()),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: children,
|
||||||
const AppFlowyCloudEnableSync(),
|
|
||||||
const VSpace(40),
|
|
||||||
if (Env.enableCustomCloud)
|
|
||||||
AppFlowyCloudURLs(didUpdateUrls: () => didResetServerUrl()),
|
|
||||||
if (!Env.enableCustomCloud)
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
FlowyText(LocaleKeys.settings_menu_cloudServerType.tr()),
|
|
||||||
const Spacer(),
|
|
||||||
const FlowyText(Env.afCloudUrl),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user