Skip to content

Commit

Permalink
Merge pull request #87 from mylxsw/develop
Browse files Browse the repository at this point in the history
桌面端显示诊断功能
  • Loading branch information
mylxsw authored Jan 16, 2024
2 parents 8e4e58c + adaa1ed commit 596e896
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
18 changes: 9 additions & 9 deletions lib/helper/env.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:io' show Platform;

import 'package:askaide/helper/platform.dart';

/// 默认 API 服务器地址
/// 注意:当你使用自己的服务器时,请修改该地址为你自己的服务器地址
const defaultAPIServerURL = 'https://ai-api.aicode.cc';
Expand All @@ -20,14 +22,12 @@ String get apiServerURL {
}

String get getDbBasePath {
String home='';
Map<String, String> envVars = Platform.environment;
if (Platform.isMacOS) {
home = envVars['HOME']!;
} else if (Platform.isLinux) {
home = envVars['HOME']!;
} else if (Platform.isWindows) {
home = envVars['UserProfile']!;
if (PlatformTool.isMacOS() || PlatformTool.isLinux()) {
return envVars['HOME'] ?? '';
} else if (PlatformTool.isWindows()) {
return envVars['UserProfile'] ?? '';
}
return home;
}

return '';
}
20 changes: 12 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ void main() async {
MediaKit.ensureInitialized();
httpx.HttpClient.init();

// FlutterError.onError = (FlutterErrorDetails details) {
// if (details.library == 'rendering library' ||
// details.library == 'image resource service') {
// return;
// }
FlutterError.onError = (FlutterErrorDetails details) {
if (details.library == 'rendering library' ||
details.library == 'image resource service') {
return;
}

// Logger.instance.e(details.summary, details.exception, details.stack);
// print(details.stack);
// };
Logger.instance.e(
details.summary,
error: details.exception,
stackTrace: details.stack,
);
print(details.stack);
};

if (kIsWeb) {
databaseFactory = databaseFactoryFfiWeb;
Expand Down
27 changes: 16 additions & 11 deletions lib/page/setting/setting_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class _SettingScreenState extends State<SettingScreen> {
final databasePath =
await databaseFactory.getDatabasesPath();

Logger.instance.d('databasePath: $databasePath');

// 删除数据库目录
await Directory(databasePath).delete(
recursive: true,
Expand All @@ -209,17 +211,20 @@ class _SettingScreenState extends State<SettingScreen> {
},
),
// 诊断
// SettingsTile(
// title: Text(AppLocale.diagnostic.getString(context)),
// trailing: Icon(
// CupertinoIcons.chevron_forward,
// size: MediaQuery.of(context).textScaleFactor * 18,
// color: Colors.grey,
// ),
// onPressed: (context) {
// context.push('/diagnosis');
// },
// ),
if (PlatformTool.isMacOS() ||
PlatformTool.isLinux() ||
PlatformTool.isWindows())
SettingsTile(
title: Text(AppLocale.diagnostic.getString(context)),
trailing: Icon(
CupertinoIcons.chevron_forward,
size: MediaQuery.of(context).textScaleFactor * 18,
color: Colors.grey,
),
onPressed: (context) {
context.push('/diagnosis');
},
),
// 检查更新
if (!PlatformTool.isIOS())
SettingsTile(
Expand Down

0 comments on commit 596e896

Please sign in to comment.