Skip to content

Commit

Permalink
[*]Frpc manager(unfinished)
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Dec 18, 2023
1 parent 93a6858 commit 8d8ca01
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/dio/frpc/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class FrpcDownloadDio {
try {
return await dio.download(
"https://github.com/LoCyan-Team/LoCyanFrpPureApp/releases/download/v0.51.3/frp_LoCyanFrp-0.51.3_windows_amd64.zip",
"${FileIO().cache_path}/",
"${FileIO.cache_path}/frpc.zip",
cancelToken: cancelToken,
onReceiveProgress: progressCallback);
} on DioException catch (e) {
} on DioException {
if (cancelToken.isCancelled)
return true;
else
Expand Down
1 change: 1 addition & 0 deletions lib/io/frpcManager.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

27 changes: 27 additions & 0 deletions lib/io/userInfoStorage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dart:convert';
import 'dart:io';

import 'package:nyalcf/model/User.dart';
import 'package:nyalcf/util/FileIO.dart';

class UserInfoStorage {
static final path = FileIO.support_path;

/**
* 保存数据
*/
static Future<void> save(User data) async {
final String write_data = jsonEncode(data);
await File("${await path}/session.json")
.writeAsString(write_data, encoding: utf8);
}

/**
* 读取数据
*/
static Future<User> read() async {
final String result =
await File("${await path}/session.json").readAsString(encoding: utf8);
return User.fromJson(jsonDecode(result));
}
}
25 changes: 24 additions & 1 deletion lib/ui/setting/frpcmanager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@ import 'package:flutter/material.dart';

class FrpcManagerSX {
Widget widget() {
return Placeholder();
return ListView(
children: [
Card(
child: Row(
children: [
Expanded(
child: ListTile(
leading: Icon(Icons.cabin),
title: Text("Frpc版本"),
),
),
Expanded(
child: Container(
width: 50,
child: DropdownButton(
items: [DropdownMenuItem(child: Text("Test"))],
onChanged: null,
),
))
],
),
)
],
);
}
}
18 changes: 15 additions & 3 deletions lib/util/FileIO.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import 'package:path_provider/path_provider.dart';

class FileIO {
final _support_path = getApplicationSupportDirectory();
final _cache_path = getApplicationCacheDirectory();
static final _support_path = getApplicationSupportDirectory();
static final _cache_path = getApplicationCacheDirectory();

Future<String> get cache_path async {
/**
* 获取缓存目录
*/
static Future<String> get cache_path async {
String path = "";
await _cache_path.then((value) => path = value.path);
return path;
}

/**
* 获取数据存储目录
*/
static Future<String> get support_path async {
String path = "";
await _support_path.then((value) => path = value.path);
return path;
}
}

0 comments on commit 8d8ca01

Please sign in to comment.