npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@winman-f2e/comic-common

v0.1.7

Published

A library created by fle-cli.

Downloads

13

Readme

网易漫画公共库

包含网页和App的常用交互功能

开始安装

$ npm install @winman-f2e/comic-common

如何使用

import {
  syncLoginInApp,
  openLogin,
  openVip,
  openDetail
} from '@winman-f2e/comic-common'

function addEvent (el, type, fn) {
  if (typeof el === 'string') {
    el = document.querySelector(el)
  }

  el && el.addEventListener(type, fn, false)
}

addEvent('#syncLoginInApp', 'click', () => {
  syncLoginInApp().then(() => {
    console.info('已完成同步!')
  })
})

addEvent('#openLogin', 'click', () => {
  openLogin()
})

addEvent('#openVip', 'click', () => {
  openVip()
})

addEvent('#openDetail', 'click', () => {
  openDetail('4728790999990016560')
})

API

h5Host(常量)

  • 本地或测试环境:https://h5test.manhua.163.com
  • 预发环境:https://h5pre.manhua.163.com
  • 线上环境:https://h5.manhua.163.com

activityHost(常量)

  • 本地或测试环境:https://tactivity.manhua.163.com
  • 预发环境:https://preactivity.manhua.163.com
  • 线上环境:https://activity.manhua.163.com

payHost(常量)

  • 本地或测试环境:https://testpay.manhua.163.com
  • 预发环境:https://prepay.manhua.163.com
  • 线上环境:https://pay.manhua.163.com

getDeviceInfo

功能:获取设备信息和token

返回值:Promise

  • resolve
    • 参数:res { clientInfo, token }
  • reject
    • 参数:{ code, msg }

syncLoginInApp

功能:同步漫画客户端和webview的登录态

返回值:Promise

  • resolve(同步登录成功)
    • 参数:res
  • reject(同步登录失败)
    • 参数:{ code, msg }

setShare

功能:设置漫画客户端和微信的分享参数

参数:data, callback(分享成功后的回调,但不太准确,假如在另外的app取消了分享也会触发,或者分享后选择留在app中不会触发)

  • data.title:分享标题
  • data.description:分享内容
  • data.picurl:分享小图标
  • data.text:分享内容(微博),若没有设置则取description
  • data.link:分享的页面链接,默认当前页面
  • data.activityId:分享的活动ID(漫画客户端)

share

功能:主动唤起漫画客户端,在微信中则引导分享

参数:同上

openAppInBrowser

功能:在浏览器中打开app

参数:data

  • data.path [string]:页面标识
  • data.query [object]:页面参数

返回值:Promise

  • resolve(res)
    • res.code:200(打开成功),-1(打开失败)
    • res.msg
    • res.downloadUrl:App下载地址(仅打开失败才有)

补充说明:在微信中不能直接打开,会跳转至引导页

openLogin

功能:打开漫画登录框

参数:callback(res),客户端登录成功后的回调,不传则刷新页面

补充说明:App中登录成功会刷新页面

openVip

功能:充值VIP

参数:targetUrl(充值成功的回跳地址,默认为当前页面)

openRecharge

功能:充值钻石

参数:targetUrl(充值成功的回跳地址,默认为当前页面)

openDetail

功能:打开漫画详情页

参数:id(漫画ID)

openReader

功能:打开阅读器

参数:id(漫画ID)、sectionId(章节ID,可选)

openTopic

功能:打开话题

参数:id(话题ID)

openRankList

功能:打开排行榜

参数:id(排行榜标识, 1、2、3...)

openSharePicture

功能:分享图片到其它渠道

参数:data

  • data.picurl:图片链接
  • data.text:分享至微博的文案
  • data.link:分享至微博的页面链接,默认当前页面

updateClient

功能:升级客户端

default

callHandler

功能:页面和漫画App进行交互

参数:action, data = {}, callback

  • action:协议名称
  • data:所需参数
    • data.path:页面标识
    • data.encode:是否需要对query进行encode
    • data.query:页面参数
  • callback:回调函数(不一定会执行,根据具体协议而定)
    • 参数:res

registerHandler(actionName, callback)

功能:注册协议方法

schemaCallHandler(schemaPath, query)

功能:schema打开链接

补充信息

其中path的值有:

  • webview:打开页面
    • url:页面地址
    • title:页面标题,可选
    • auth:是否需要认证,可选,如果为1,则会在url后追加_C, _CL参数
  • topPage:App底部模块切换(一级页面)
    • index:0-推荐漫画、1-找漫画、2-我的漫画、3-话题列表、4-账号页、5-广场
  • detail:漫画详情页
    • id
  • reader:漫画阅读器
    • id
    • sectionId
  • topic:话题
    • id
  • search:搜索漫画
    • title:搜索内容(IOS中搜索中文无效)
  • account:个人资料编辑页
    • index:0-资料编辑、1-主题、2-背景、3-挂饰
  • coin:我的金币
  • diamond:我的钻石
  • vip:我的VIP
  • message:我的消息
    • type:0-系统通知
  • user:用户账户页
    • id:用户id
  • postTopic:发表话题
  • downloaded:已下载至本地的漫画
  • feedback:联系客服(反馈问题)
  • settings:设置页
  • reward:我的打赏
  • scan:扫一扫
  • subject:漫画专题
    • id
  • latest:今天更新的漫画
  • rankList:打开排行榜
    • uuid:不传则默认选择第一个标签
  • findList:找漫画列表
    • uuid:不传则默认选择第一个标签
  • openVip:开通VIP(IOS)
  • recharge:打开钻石充值(IOS)

环境配置

构建工具

$ npm install -g fle-cli

# yarn
$ yarn global add fle-cli

命令说明

# 本地开发
fle dev

# 代码构建
fle build

查看更多说明: 构建文档