Git Product home page Git Product logo

epub-reader's Introduction

epubjs-ebook

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

epubjs的核心工作原理

踩坑与小结

  • 中途遇到了这样的报错Module build failed: TypeError: this.getResolve is not a function at Object.loader,这个错误的原因是安装的sass-loader的版本过高,导致编译失败,查了好久的错误,醉了这也可以,最后将8.0.0版本卸载了装了7.3.1版本就ok啦。
  • get到解决eslint问题报错的方法.
    • 局部生效: /*eslint-disable xxxx*/.
    • 全局生效: eslint配置文件中新增一个rule ‘xxxx':'off’后重启项目.
  • vue文件模板设置,积累一下。
    首选项-代码片段-vue.json中设置。
  • reset.scss是为了消除不同浏览器默认样式的不一致性; global.scss是规定了整个项目的公共样式、公共方法、公共参数等; 在global.scss中有一个公共的字体转换方法px2rem,实现pxrem之间的相互转换,rem= px / fontSize
  • 功能实现
    • 电子书解析与渲染: 1.生成book对象 2.通过book.renderTo方法生成redition 3.rendition.display方法实现渲染;
    • 翻页: rendition.prevrendition.next方法实现翻页;
    • 字体设置: 更改renditionthemes对象的fontSize
    • 主题设置: 定义一组主题数组,数组中包含主题名称与样式,使用themes对象的register方法遍历主题数组去注册这些主题,调用时使用themes.select方法,向其传入主题名称作为参数;
    • 进度条: 需求分析之后需要异步实现,通过epubjs的钩子函数获取booklocations对象,book.ready返回一个promise对象,调用then方法返回一个locations对象,然后通过locations对象的cfiFromPercentage方法实现进度条数值转换为location,再用rendition对象的display方法解析location实现具体定位。
    • 目录: booknavigation对象实现,遍历navigation.toc展示目录。

For a detailed explanation on how things work, check out the guide and docs for vue-loader.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.