mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-03 06:20:06 +00:00

* feat: custom share url, publish url and copy link to share * chore: update translation * feat: support base share domain * feat: customize web url in login page * feat: support customizing web url on mobile * test: change web url test * fix: cloud integration test * fix: integration test * fix: integration test
57 lines
1.6 KiB
Dart
57 lines
1.6 KiB
Dart
import 'package:appflowy/env/cloud_env.dart';
|
|
import 'package:appflowy/startup/startup.dart';
|
|
|
|
class ShareConstants {
|
|
static const String baseWebDomain = 'appflowy.com';
|
|
static const String testBaseWebDomain = 'test.appflowy.com';
|
|
static const String defaultBaseWebDomain = 'https://www.appflowy.com';
|
|
|
|
static String buildPublishUrl({
|
|
required String nameSpace,
|
|
required String publishName,
|
|
}) {
|
|
final baseShareDomain =
|
|
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_web_domain;
|
|
final url = '$baseShareDomain/$nameSpace/$publishName'.addSchemaIfNeeded();
|
|
return url;
|
|
}
|
|
|
|
static String buildNamespaceUrl({
|
|
required String nameSpace,
|
|
bool withHttps = false,
|
|
}) {
|
|
final baseShareDomain =
|
|
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_web_domain;
|
|
String url = baseShareDomain.addSchemaIfNeeded();
|
|
if (!withHttps) {
|
|
url = url.replaceFirst('https://', '');
|
|
}
|
|
return '$url/app/$nameSpace';
|
|
}
|
|
|
|
static String buildShareUrl({
|
|
required String workspaceId,
|
|
required String viewId,
|
|
String? blockId,
|
|
}) {
|
|
final baseShareDomain =
|
|
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_web_domain;
|
|
final url = '$baseShareDomain/app/$workspaceId/$viewId'.addSchemaIfNeeded();
|
|
if (blockId == null || blockId.isEmpty) {
|
|
return url;
|
|
}
|
|
return '$url?blockId=$blockId';
|
|
}
|
|
}
|
|
|
|
extension on String {
|
|
String addSchemaIfNeeded() {
|
|
final schema = Uri.parse(this).scheme;
|
|
// if the schema is empty, add https schema by default
|
|
if (schema.isEmpty) {
|
|
return 'https://$this';
|
|
}
|
|
return this;
|
|
}
|
|
}
|