nativescript-epub-reader
您出色的 NativeScript 插件。
npm i --save nativescript-epub-reader

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 演示

Image

Android 演示

自定义字体

Custom fonts

日间和夜间模式

Day night mode

文本高亮

Highlight

媒体覆盖

Media Overlay

鸣谢

  • https://github.com/FolioReader/FolioReaderKit
  • https://github.com/FolioReader/FolioReader-Android

许可证

Apache 许可证第 2 版,2004 年 1 月