npm i --save nativescript-epub-reader
- 版本: 1.0.0
- GitHub:
- NPM: https://npmjs.net.cn/package/nativescript-epub-reader
- 下载次数
- 前一天: 0
- 上周: 0
- 上个月: 0
nativescript-epub-reader
原生 NativeScript 插件,用于打开和阅读 ePub 文件。
入门指南
npm install nativescript-epub-reader
- 对于 iOS,请将您的
epub
文件放置在App_Resources/iOS
目录中。 - 对于 Android,需要作为参数的绝对文件路径。
- 在您的页面中导入
EpubReader
并打开文件。
Android 权限要求
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
AndroidManifest
从 Android 9.0(API 级别 28)开始,默认禁用明文支持。
{your-app-module}/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
然后在您的应用模块的 AndroidManifest.xml 中添加 network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
...
<application android:networkSecurityConfig="@xml/network_security_config">
...
</application>
</manifest>
代码示例
import {Observable} from 'data/observable';
import { EpubReader } from 'nativescript-epub-reader';
import * as application from "tns-core-modules/application";
export class HelloWorldModel extends Observable {
constructor() {
super();
let ePubReader = new EpubReader();
if (application.android) {
ePubReader.open('/storage/emulated/0/Download/Metamorphosis-jackson.epub');
}else{
ePubReader.open('book');
}
}
}
IOS 演示
Android 演示
自定义字体
日间和夜间模式
文本高亮
媒体覆盖
鸣谢
- https://github.com/FolioReader/FolioReaderKit
- https://github.com/FolioReader/FolioReader-Android
许可证
Apache 许可证第 2 版,2004 年 1 月