Skip to content
Snippets Groups Projects
Commit 2d5a7254 authored by shipinbaoku's avatar shipinbaoku
Browse files

fix open config dir error

& other issues
parent 9aaa0911
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,18 @@ Please download .dmg setup directly. [https://github.com/shipinbaoku/ClashCross/
Please download .exe setup directly. [https://github.com/shipinbaoku/ClashCross/releases](https://github.com/shipinbaoku/ClashCross/releases)
# Url_scheme
Our application allows third parties to import Clash subscriptions using the url_scheme method, following the specifications below:
## Android: clashcross://import-config?url=subscription_link
## Windows & macOS: clashcross://?url=subscription_link
## Linux: Not supported at the moment, users need to manually copy and paste for importing.
## <a href="/docs/en/url_scheme.md">Specific protocol management system modification method, using v2board as an example</a>
# Screen
- Home
......
......@@ -43,6 +43,14 @@
请直接下载.exe安装文件。[https://github.com/shipinbaoku/ClashCross/releases](https://github.com/shipinbaoku/ClashCross/releases)
# Url_scheme
我们的应用程序允许第三方通过url_scheme方式导入clash订阅,规范如下:
## android:clashcross://import-config?url=订阅链接
## windows&macos:clashcross://?url=订阅链接
## linux:暂不支持,需要用户手动复制粘贴导入
## <a href="/docs/zh/url_scheme.md">具体协议管理系统修改方法,以v2board为例</a>
# 界面预览
- 主页
......
......@@ -61,6 +61,18 @@
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Add optional android:host to distinguish your app
from others in case of conflicting scheme name -->
<data
android:scheme="clashcross"
android:host="install-config" />
<!-- <data android:scheme="sample" /> -->
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Add optional android:host to distinguish your app
......
# Common examples of management system integration:
## v2board:
Modify the content of the file /public/theme/v2board/assets/umi.js as follows:
```javascript
...
return (Object(u["i"])() || Object(u["j"])()) && (t.push({
title: "Shadowrocket",
href: "shadowrocket://add/sub://" + window.btoa(e + "&flag=shadowrocket")
.replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "") + "?remark=" + window.settings.title
}), t.push({
title: "QuantumultX",
href: "quantumult-x:///update-configuration?remote-resource=" + encodeURI(JSON.stringify({
server_remote: [e + ", tag=" + window.settings.title]
}))
}), t.push({
title: "Surge",
href: "surge:///install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "Stash",
href: "stash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
})), Object(u["k"])() && (t.push({
title: "ClashCross",
href: "clashcross://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "ClashX",
href: "clash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
})), Object(u["n"])() && (t.push({
title: "ClashCross",
href: "clashcross://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "Clash For Windows",
href: "clash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
})), Object(u["g"])() && (t.push({
title: "ClashCross",
href: "clashcross://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "Clash For Android",
href: "clash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "Surfboard",
href: "surge:///install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}))
...
```
Then, upload the ClashCross.png icon file to /public/theme/v2board/assets/images/icon.
Alternatively, you can directly download the modified umi.js file to overwrite the existing one. [Download link](/docs/v2board)
\ No newline at end of file
docs/v2board/ClashCross.png

3.24 KiB

This diff is collapsed.
# 常见管理系统集成示例:
## v2board:
修改目录下/public/theme/v2board/assets/umi.js 文件内容如下:
`
...
return (Object(u["i"])() || Object(u["j"])()) && (t.push({
title: "Shadowrocket",
href: "shadowrocket://add/sub://" + window.btoa(e + "&flag=shadowrocket")
.replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "") + "?remark=" + window.settings.title
}), t.push({
title: "QuantumultX",
href: "quantumult-x:///update-configuration?remote-resource=" + encodeURI(JSON.stringify({
server_remote: [e + ", tag=" + window.settings.title]
}))
}), t.push({
title: "Surge",
href: "surge:///install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "Stash",
href: "stash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
})), Object(u["k"])() && (t.push({
title: "ClashCross",
href: "clashcross://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}),t.push({
title: "ClashX",
href: "clash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
})), Object(u["n"])() && (t.push({
title: "ClashCross",
href: "clashcross://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}),t.push({
title: "Clash For Windows",
href: "clash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
})), Object(u["g"])() && (t.push({
title: "ClashCross",
href: "clashcross://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}),t.push({
title: "Clash For Android",
href: "clash://install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}), t.push({
title: "Surfboard",
href: "surge:///install-config?url=" + encodeURIComponent(e) + "&name=" + window.settings.title
}))
...`
然后将ClashCross.png图标文件上传到public/theme/v2board/assets/images/icon 。
您也可以直接下载我们修改好的umi.js文件进行覆盖。[下载地址](/docs/v2board)
\ No newline at end of file
......@@ -256,9 +256,9 @@ class _MyHomePageState extends State<MyHomePage>
}
];
final cfg = AppcastConfiguration(
url:
"https://www.clashcross.xyz/appcast.xml",
supportedOS: ['android','windows',"macos","linux"]);
url: "https://www.clashcross.xyz/appcast.xml",
supportedOS: ['android', 'windows', "macos", "linux"]);
// final cfg = AppcastConfiguration(
// url:
// "https://raw.githubusercontent.com/larryaasen/upgrader/master/test/testappcast.xml",
......@@ -373,7 +373,6 @@ class _MyHomePageState extends State<MyHomePage>
items: List.generate(
_itemsList.length,
(index) => BottomNavigationBarItem(
icon: SvgPicture.asset(
_itemsList[index]['iconPath'] as String,
height: index != currentPage ? 20 : 24,
......@@ -491,24 +490,37 @@ Future<void> initDeepLinks() async {
importProfile(Uri uri) {
if (uri.queryParameters["url"] != null) {
Get.find<DialogService>().inputDialog(
title: "What is your config name".tr,
onText: (name) async {
if (name == "config") {
EasyLoading.showError("Cannot use this special name".tr);
// BrnToast.show("Cannot use this special name".tr, context);
}
Future.delayed(Duration.zero, () async {
try {
BrnLoadingDialog.show(Get.context!,
content: '', barrierDismissible: false);
await Get.find<ClashService>()
.addProfile(name, uri.queryParameters["url"]!);
} finally {
BrnLoadingDialog.dismiss(Get.context!);
if (uri.queryParameters["name"] != null) {
Future.delayed(Duration.zero, () async {
try {
BrnLoadingDialog.show(Get.context!,
content: '', barrierDismissible: false);
await Get.find<ClashService>().addProfile(
uri.queryParameters["name"]!, uri.queryParameters["url"]!);
} finally {
BrnLoadingDialog.dismiss(Get.context!);
}
});
} else {
Get.find<DialogService>().inputDialog(
title: "What is your config name".tr,
onText: (name) async {
if (name == "config") {
EasyLoading.showError("Cannot use this special name".tr);
// BrnToast.show("Cannot use this special name".tr, context);
}
Future.delayed(Duration.zero, () async {
try {
BrnLoadingDialog.show(Get.context!,
content: '', barrierDismissible: false);
await Get.find<ClashService>()
.addProfile(name, uri.queryParameters["url"]!);
} finally {
BrnLoadingDialog.dismiss(Get.context!);
}
});
});
});
}
} else {
EasyLoading.showError("请导入有效的clash订阅链接");
}
......
This diff is collapsed.
......@@ -52,10 +52,10 @@ class _ProfileState extends State<Profile> {
onTap: () async {
final dir = await getApplicationSupportDirectory();
if (Platform.isWindows) {
launchUrlString("file://${join(dir.path, "clash")}");
launchUrlString("file://${join(dir.path, "clashCross")}");
} else {
launchUrl(
Uri.parse("file://${join(dir.path, "clash")}"));
Uri.parse("file://${join(dir.path, "clashCross")}"));
}
},
child: Row(
......@@ -78,7 +78,7 @@ class _ProfileState extends State<Profile> {
Widget buildProfileList(context) {
final configs = Get.find<ClashService>().yamlConfigs;
final configsList = configs.toList(growable: false);
if (configs.length == 1) {
if (configs.isEmpty) {
return Container(
alignment: Alignment.center,
// color: Colors.white,
......
......@@ -146,7 +146,8 @@ class _ProxyState extends State<Proxy> {
// ),
// );
// }
print(selectors);
print("maps");
selectors = selectors
.where((sel) => maps[sel]['name'].toLowerCase() != 'global')
.toList();
......
......@@ -44,6 +44,7 @@ class ClashService extends GetxService with TrayListener {
// final currentYaml = isDesktop?'config.yaml'.obs:"".obs;
final currentYaml = 'config.yaml'.obs;
final proxyStatus = RxMap<String, int>();
late RxMap<String, int> sortedproxyStatus = RxMap<String, int>();
// action
static const ACTION_SET_SYSTEM_PROXY = "assr";
......@@ -102,7 +103,7 @@ class ClashService extends GetxService with TrayListener {
Request.setBaseUrl(clashBaseUrl);
// init clash
// kill all other clash clients
final clashConfigPath = p.join(_clashDirectory.path, "clash");
final clashConfigPath = p.join(_clashDirectory.path, "clashCross");
_clashDirectory = Directory(clashConfigPath);
print("fclash work directory: ${_clashDirectory.path}");
final clashConf = p.join(_clashDirectory.path, currentYaml.value);
......@@ -159,8 +160,6 @@ class ClashService extends GetxService with TrayListener {
String buildNumber = packageInfo.buildNumber;
app_version = version;
build_number = buildNumber;
print('App Version: $version');
print('Build Number: $buildNumber');
}
void getConfigs() {
......@@ -173,6 +172,8 @@ class ClashService extends GetxService with TrayListener {
Get.printInfo(info: 'detected: ${entity.path}');
}
}
yamlConfigs.removeWhere((element) => element.path.toLowerCase().endsWith("config.yaml"));
}
Map<String, dynamic> getConnections() {
......
......@@ -34,4 +34,8 @@ class NotificationService extends GetxService {
Future<void> cancelAllNotification() async {
await notification.cancelAll();
}
Future<void> cancelNotification(id) async {
await notification.cancel(id);
}
}
......@@ -87,9 +87,12 @@ class ClashTranslations extends Translations {
"How to import profie":
"You can import the configuration in the following ways:\n1. Manually copy and paste the Clash subscription address for import.\n2. Scan the Clash subscription QR code for import.\n3.After installing the software, you can click on the Clash subscription link to import it.\n4. Desktop version users can directly import the Clash configuration into the configuration folder.",
"Help": "How to use",
"Copy terminal proxy command":"Copy terminal proxy command",
"Copy the proxy command and run it in the terminal":"Copy the proxy command and run it in the terminal",
"afftips":" If you plan to build your own server, please purchase the servers through the following Aff. All the service providers listed below are reputable businesses with a certain operational history and technical expertise. They guarantee both stability and quality. Your data will be effectively protected."
"Copy terminal proxy command": "Copy terminal proxy command",
"Copy the proxy command and run it in the terminal":
"Copy the proxy command and run it in the terminal",
"afftips":
" If you plan to build your own server, please purchase the servers through the following Aff. All the service providers listed below are reputable businesses with a certain operational history and technical expertise. They guarantee both stability and quality. Your data will be effectively protected.",
"No Profile Please import": "No Profile Please import"
},
'zh_CN': {
"http_port": "HTTP端口",
......@@ -101,8 +104,7 @@ class ClashTranslations extends Translations {
"Settings": "设置",
"Test Delay": "测试延迟",
"Current using": "配置:@name",
"is running as system proxy now. Enjoy.":
"已经被设置为系统代理,好耶!",
"is running as system proxy now. Enjoy.": "已经被设置为系统代理,好耶!",
"No Logs currently / Connecting to clash log daemon...":
"现在没有日志 / 正在连接至Clash日志后台",
"Log is running. Any logs will show below.": "日志功能正在运行,所有日志将会显示在下方",
......@@ -137,8 +139,7 @@ class ClashTranslations extends Translations {
"You can't delete a profile which is in use!": "不能删除正在使用的文件",
"Please switch to another profile first": "请先切换为其他配置文件",
'No profile, please add profiles.': "暂无可用配置文件",
"a clash proxy fronted by Flutter":
"使用Flutter构建的Clash代理",
"a clash proxy fronted by Flutter": "使用Flutter构建的Clash代理",
'version:': "版本: @version",
"Author:": "作者: @name",
"View me at Github": "Github主页",
......@@ -216,9 +217,11 @@ class ClashTranslations extends Translations {
"How to import profie":
"可以通过如下方式导入Clash配置:\n1,将clash订阅地址手动复制粘贴导入\n2,扫描clash订阅二维码导入\n3,安装该软件后点击clash订阅链接导入\n4,桌面版用户直接导入clash配置到配置文件夹",
"Help": "帮助",
"Copy terminal proxy command":"复制终端代理命令",
"Copy the proxy command and run it in the terminal":"复制代理命令到终端运行",
"afftips":" 如果您打算自建服务请通过以下Aff购买服务器,以下服务商均为具有一定运营时常和技术能力的商家,稳定性方面和质量方面均有保障。数据可以得到有效保护。"
"Copy terminal proxy command": "复制终端代理命令",
"Copy the proxy command and run it in the terminal": "复制代理命令到终端运行",
"afftips":
" 如果您打算自建服务请通过以下Aff购买服务器,以下服务商均为具有一定运营时常和技术能力的商家,稳定性方面和质量方面均有保障。数据可以得到有效保护。",
"No Profile Please import": "暂无订阅,请导入"
}
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment