nw-app-lofter

Open Lofter App

Usage no npm install needed!

<script type="module">
  import nwAppLofter from 'https://cdn.skypack.dev/nw-app-lofter';
</script>

README

nw-app-lofter

功能

在H5中尝试打开Lofter App内的特定页面,如果没有安装APP,则跳转App下载页

使用

npm: 通过npm安装nw-app-lofter

import {openAppLofter} from 'nw-app-lofter'
openAppLofter({
    path: 'webview',
    query: {
        url: 'http://qatest5.lofter.com'
    }
})

参数

参数为Object类型,参数各字段定义如下:

参数属性 类型 描述
path String webview或具体页面类型
query Object 参数
act String 非必须,活动包统计参数,跳下载会携带

具体可用path和query参数如下:

path query 描述
app 只唤起app,不跳转其他页面
webview url:WAP页面的url 如果指定WAP页面已实现APP打开功能,则打开APP内的对应页面;否则通过webview打开
homepage id:用户id 个人主页
post id: 帖子id,userId:用户id 单日志页
tag tagName:标签名 标签页
publishText userId:用户id,tagName:标签名(逗号分隔) 发布文字页
publishPhoto userId:用户id,tagName:标签名(逗号分隔) 发布图片页
publishVideo userId:用户id,tagName:标签名(逗号分隔) 发布视频页

其中,path为webview时,url指定为WAP页url。如APP可打开对应页面,则打开;否则通过webview打开。

示例:

个人主页

{
    path: 'webview',
    query: {
       // 个人主页WAP页url
       url: 'http://qatest5.lofter.com'
    }
}

{
    path: 'homepage',
    query: {
        id: 'qatest5'
    }
}

单日志页

{
    path: 'webview',
    query: {
       // 单日志页WAP页url
       url: 'http://newsexpress.lofter.com/post/1e7dc1d6_cea03e7'
    }
}

{
    path: 'post',
    query: {
        id: '1e7dc1d6_cea03e7',
        userId: 'newsexpress'
    }
}

标签页

{
    path: 'webview',
    query: {
       // 标签WAP页url
       url: 'http://www.lofter.com/tag/%E9%9F%B3%E4%B9%90'
    }
}

{
    path: 'tag',
    query: {
        tagName: '音乐'
    }
}

发布文字页

{
    path: 'webview',
    query: {
       //发布文字WAP页面url   
       url: 'http://www.lofter.com/blog/qatest5/new/text?extraTags=%E9%9F%B3%E4%B9%90,music,happy%20new%20year'
    }
}

{
    path: 'publishText',
    query: {
        userId: 'qatest5',
        tagName: '音乐,music,happy new year'
    }
}

等等...