-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
230 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,83 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:nyalcf/dio/proxies/get.dart'; | ||
import 'package:nyalcf/model/ProxyInfo.dart'; | ||
|
||
import 'frpc.dart'; | ||
|
||
class ProxiesController extends GetxController { | ||
final FrpcController f_c = Get.find(); | ||
var proxiesListWidgets = <DataRow>[ | ||
DataRow(cells: <DataCell>[ | ||
DataCell(Text("加载中喵喵喵?")), | ||
DataCell(Text("加载中喵喵喵?")), | ||
DataCell(Text("加载中喵喵喵?")), | ||
DataCell(Text("加载中喵喵喵?")) | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
]) | ||
].obs; | ||
|
||
load() {} | ||
load(username, token) async { | ||
var proxies = await ProxiesGetDio().get(username, token); | ||
if (proxies is List<ProxyInfo>) { | ||
List<DataRow> widgets = <DataRow>[]; | ||
proxies.forEach((element) => widgets.add(DataRow(cells: <DataCell>[ | ||
DataCell( | ||
Container( | ||
width: 150.0, | ||
height: 30.0, | ||
child: SelectableText(element.proxy_name), | ||
), | ||
), | ||
DataCell(SelectableText(element.id.toString())), | ||
DataCell(SelectableText(element.node.toString())), | ||
DataCell(SelectableText(element.proxy_type)), | ||
DataCell(SelectableText(element.local_ip)), | ||
DataCell( | ||
SelectableText("${element.local_port} -> ${element.remote_port}"), | ||
), | ||
DataCell( | ||
Row( | ||
children: [ | ||
IconButton( | ||
icon: Icon(Icons.play_circle), | ||
onPressed: () { | ||
Process.run("cmd.exe", ["start", "cmd.exe"]); | ||
}, | ||
), | ||
IconButton( | ||
icon: Icon(Icons.edit), | ||
onPressed: () { | ||
Get.snackbar("谁让你点了?", "还没写,爬去面板编辑喵喵喵!"); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
]))); | ||
proxiesListWidgets.value = widgets; | ||
} else { | ||
proxiesListWidgets.value = <DataRow>[ | ||
DataRow(cells: <DataCell>[ | ||
DataCell(Text("获取失败,请尝试刷新一下~")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
DataCell(Text("-")), | ||
]) | ||
]; | ||
Get.snackbar( | ||
"发生错误", | ||
"无法获取隧道列表信息: ${proxies}", | ||
snackPosition: SnackPosition.BOTTOM, | ||
animationDuration: Duration(milliseconds: 300), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,54 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:nyalcf/dio/basicConfig.dart'; | ||
import 'package:nyalcf/model/ProxyInfo.dart'; | ||
|
||
class ProxiesGetDio { | ||
final dio = Dio(); | ||
|
||
Future<dynamic> get() async {} | ||
Future<dynamic> get(username, token) async { | ||
try { | ||
Map<String, dynamic> params_map = Map(); | ||
params_map['username'] = username; | ||
|
||
Options options = Options(); | ||
Map<String, dynamic> options_map = Map(); | ||
options_map['Content-Type'] = | ||
'application/x-www-form-urlencoded;charset=UTF-8'; | ||
options_map['Authorization'] = 'Bearer $token'; | ||
options = options.copyWith(headers: options_map); | ||
|
||
//print(options.headers?.keys); | ||
|
||
var response = await dio.get( | ||
"${basicConfig.api_v2_url}/proxies/getlist", | ||
queryParameters: params_map, | ||
options: options, | ||
); | ||
Map<String, dynamic> resJson = response.data; | ||
Map<String, dynamic> resData = resJson['data']; | ||
print(resData['proxies']); | ||
List<Map<String, dynamic>> proxies = List.from(resData['proxies']); | ||
List<ProxyInfo> list = <ProxyInfo>[]; | ||
proxies.forEach((element) { | ||
list.add(ProxyInfo( | ||
proxy_name: element['proxy_name'], | ||
use_compression: bool.parse(element['use_compression']), | ||
local_ip: element['local_ip'], | ||
node: element['node'], | ||
local_port: element['local_port'], | ||
remote_port: int.parse(element['remote_port']), | ||
domain: element['domain'], | ||
icp: element['icp'], | ||
sk: element['sk'], | ||
id: element['id'], | ||
proxy_type: element['proxy_type'], | ||
use_encryption: bool.parse(element['use_encryption']), | ||
status: element['status'])); | ||
}); | ||
return list; | ||
} catch (e) { | ||
print(e); | ||
return e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class ProxyInfo { | ||
ProxyInfo( | ||
{required this.proxy_name, | ||
required this.use_compression, | ||
required this.local_ip, | ||
required this.node, | ||
required this.local_port, | ||
required this.remote_port, | ||
required this.domain, | ||
required this.icp, | ||
required this.sk, | ||
required this.id, | ||
required this.proxy_type, | ||
required this.use_encryption, | ||
required this.status}); | ||
|
||
final String proxy_name; | ||
final bool use_compression; | ||
final String local_ip; | ||
final int node; | ||
final int local_port; | ||
final int remote_port; | ||
final String domain; | ||
final String? icp; | ||
final String sk; | ||
final int id; | ||
final String proxy_type; | ||
final bool use_encryption; | ||
final status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.