Skip to content

Commit

Permalink
feat!: 扩展设置
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Jul 11, 2023
1 parent 87067e9 commit 39dd4ad
Show file tree
Hide file tree
Showing 23 changed files with 2,986 additions and 167 deletions.
11 changes: 11 additions & 0 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,16 @@
"video": "Video",
"novel": "Novel",
"comics": "Comics"
},

"extension-info": {
"author": "Author",
"description": "Description",
"version": "Version",
"language": "Language",
"original-site": "Original Site",
"other-infomation": "Other Infomation",
"license": "License",
"title": "Extension Info"
}
}
13 changes: 12 additions & 1 deletion assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"source-code": "开源",
"source-code-training": "前往 Star",
"license": "许可",
"license-subtitle": "许可"
"license-subtitle": "许可证"
},

"detail": {
Expand Down Expand Up @@ -112,5 +112,16 @@
"video": "影视",
"novel": "小说",
"comics": "漫画"
},

"extension-info": {
"author": "作者",
"description": "描述",
"version": "版本",
"language": "语言",
"original-site": "源站",
"other-infomation": "其他信息",
"license": "许可",
"title": "扩展详情"
}
}
9 changes: 9 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:miru_app/pages/detail/view.dart';
import 'package:miru_app/pages/extension/view.dart';
import 'package:miru_app/pages/extension_log/view.dart';
import 'package:miru_app/pages/extension_repo/view.dart';
import 'package:miru_app/pages/extension_settings/view.dart';
import 'package:miru_app/pages/home/view.dart';
import 'package:miru_app/pages/main/view.dart';
import 'package:miru_app/pages/search/view.dart';
Expand Down Expand Up @@ -158,6 +159,14 @@ final router = GoRouter(
path: '/extension',
builder: (context, state) => _animation(const ExtensionPage()),
),
GoRoute(
path: '/extension_settings',
builder: (context, state) => _animation(
ExtensionSettingsPage(
package: state.queryParameters['package']!,
),
),
),
GoRoute(
path: '/settings',
builder: (context, state) => _animation(const SettingsPage()),
Expand Down
49 changes: 49 additions & 0 deletions lib/models/extension_setting.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:isar/isar.dart';

part 'extension_setting.g.dart';

enum ExtensionSettingType {
// 输入框
input,
// 单选
radio,
// 开关
toggle,
}

@collection
class ExtensionSetting {
Id id = Isar.autoIncrement;

@Index(composite: [CompositeIndex('key')], unique: true)
late String package;
// 标题
late String title;
// 键
late String key;
// 值
String? value;
// 默认值
late String defaultValue;
// 类型
@Enumerated(EnumType.name)
late ExtensionSettingType type;
// 描述
String? description;
// 如果是 radio 类型,这里是各项选项,且必填 , 存储为 ["key:value","key:value"]
// 为啥不直接用 map,因为 isar 还不支持 map 类型
List<String>? options;

static ExtensionSettingType stringToType(String type) {
switch (type) {
case 'input':
return ExtensionSettingType.input;
case 'radio':
return ExtensionSettingType.radio;
case 'toggle':
return ExtensionSettingType.toggle;
default:
return ExtensionSettingType.input;
}
}
}
Loading

0 comments on commit 39dd4ad

Please sign in to comment.