情景推荐
This commit is contained in:
150
lib/models/scenario/jinrishici_sdk_config.dart
Normal file
150
lib/models/scenario/jinrishici_sdk_config.dart
Normal file
@@ -0,0 +1,150 @@
|
||||
/// 今日诗词安卓 SDK 用法和接口文档
|
||||
///
|
||||
/// 创建时间:2026-04-08
|
||||
/// 作用:记录今日诗词 SDK 的使用方法和 API 接口信息
|
||||
/// 最后更新:2026-04-08 - 初始创建
|
||||
|
||||
/// 今日诗词 SDK 配置信息
|
||||
class JinrishiciSdkConfig {
|
||||
/// SDK 名称
|
||||
static const String sdkName = '今日诗词安卓 SDK';
|
||||
|
||||
/// SDK 包名
|
||||
static const String packageName = 'com.jinrishici:android-sdk';
|
||||
|
||||
/// GitHub 仓库地址
|
||||
static const String githubUrl = 'https://github.com/xenv/jinrishici-sdk-android';
|
||||
|
||||
/// 许可证
|
||||
static const String license = 'BSD 3-Clause "New" or "Revised" License';
|
||||
|
||||
/// Token 获取接口
|
||||
static const String tokenUrl = 'https://v2.jinrishici.com/token';
|
||||
|
||||
/// 获取诗词接口
|
||||
static const String sentenceUrl = 'https://v2.jinrishici.com/sentence';
|
||||
|
||||
/// SDK 版本号(需要根据实际发布版本更新)
|
||||
static const String version = '{release-version}';
|
||||
}
|
||||
|
||||
/// SDK 使用方法说明
|
||||
class JinrishiciSdkUsage {
|
||||
/// 初始化方法
|
||||
static const String initMethod = '''
|
||||
// 初始化(两种方式任选一种)
|
||||
JinrishiciFactory.init(getContext());
|
||||
JinrishiciClient.getInstance().init(getContext());
|
||||
''';
|
||||
|
||||
/// 异步获取诗词方法
|
||||
static const String asyncMethod = '''
|
||||
// 异步方法
|
||||
JinrishiciClient client = JinrishiciClient.getInstance();
|
||||
client.getOneSentenceBackground(new JinrishiciCallback() {
|
||||
@Override
|
||||
public void done(PoetySentence poetySentence) {
|
||||
// 处理成功结果
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(JinrishiciRuntimeException e) {
|
||||
// 处理错误
|
||||
}
|
||||
});
|
||||
''';
|
||||
|
||||
/// 同步获取诗词方法
|
||||
static const String syncMethod = '''
|
||||
// 同步方法(会抛出 JinrishiciRuntimeException)
|
||||
PoetySentence poetySentence = JinrishiciClient.getInstance().getOneSentence();
|
||||
''';
|
||||
|
||||
/// 自定义控件使用方法
|
||||
static const String customWidget = '''
|
||||
// XML 布局中使用
|
||||
<com.jinrishici.sdk.android.view.JinrishiciTextView
|
||||
android:id="@+id/jinrisiciTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="18sp" />
|
||||
''';
|
||||
}
|
||||
|
||||
/// SDK 自定义控件属性
|
||||
class JinrishiciWidgetAttributes {
|
||||
/// 点击 TextView 时是否刷新
|
||||
static const String refreshOnClick = 'jrsc_refresh_on_click';
|
||||
|
||||
/// 当请求出现错误时,是否直接将错误信息显示到 TextView 上
|
||||
static const String showError = 'jrsc_show_error';
|
||||
|
||||
/// 是否在加载数据时显示加载文本
|
||||
static const String showLoadingText = 'jrsc_show_loading_text';
|
||||
|
||||
/// 加载数据时显示的文本
|
||||
static const String textLoading = 'jrsc_text_loading';
|
||||
|
||||
/// 加载失败时显示的文本
|
||||
static const String textError = 'jrsc_text_error';
|
||||
}
|
||||
|
||||
/// SDK 工作流程
|
||||
class JinrishiciSdkWorkflow {
|
||||
/// 工作流程步骤
|
||||
static const List<String> steps = [
|
||||
'SDK 首先从本地 SharedPreferences 检查是否有缓存的 token',
|
||||
'如果没有 token,调用 https://v2.jinrishici.com/token 获取 token',
|
||||
'使用 token 调用 https://v2.jinrishici.com/one.json 获取诗词内容',
|
||||
'返回 PoetySentence 对象,包含诗词内容、来源、作者等信息',
|
||||
];
|
||||
|
||||
/// Gradle 依赖配置
|
||||
static const String gradleDependency = '''
|
||||
implementation 'com.jinrishici:android-sdk:{release-version}'
|
||||
''';
|
||||
|
||||
/// Maven 依赖配置
|
||||
static const String mavenDependency = '''
|
||||
<dependency>
|
||||
<groupId>com.jinrishici</groupId>
|
||||
<artifactId>android-sdk</artifactId>
|
||||
<version>{release-version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
''';
|
||||
}
|
||||
|
||||
/// SDK 数据模型
|
||||
class JinrishiciSdkData {
|
||||
/// PoetySentence - 诗词句子对象
|
||||
static const Map<String, String> poetySentenceFields = {
|
||||
'ipAddress': 'IP 地址',
|
||||
'data': '诗词数据对象(DataBean)',
|
||||
};
|
||||
|
||||
/// DataBean - 诗词数据对象
|
||||
static const Map<String, String> dataBeanFields = {
|
||||
'content': '诗词内容',
|
||||
'origin': '诗词来源信息(OriginBean)',
|
||||
'matchTags': '匹配标签',
|
||||
'recommendedReason': '推荐理由',
|
||||
};
|
||||
|
||||
/// OriginBean - 诗词来源对象
|
||||
static const Map<String, String> originBeanFields = {
|
||||
'title': '诗词标题',
|
||||
'dynasty': '朝代',
|
||||
'author': '作者',
|
||||
'content': '完整诗词内容',
|
||||
'translate': '翻译',
|
||||
'note': '注释',
|
||||
};
|
||||
|
||||
/// PoetyToken - Token 对象
|
||||
static const Map<String, String> poetyTokenFields = {
|
||||
'token': '访问令牌',
|
||||
'status': '状态',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user