Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
dwb1994 committed Oct 19, 2018
1 parent 41d7884 commit cc407fe
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 423 deletions.
30 changes: 2 additions & 28 deletions _site/documents/course.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html><html lang="zh-CN"><head><meta charSet="UTF-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" sizes="180x180" href="../ydoc/images/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="../ydoc/images/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="../ydoc/images/favicon-16x16.png"/><link rel="manifest" href="../ydoc/images/manifest.json"/><link rel="mask-icon" href="../ydoc/images/safari-pinned-tab.svg" color="#5bbad5"/><meta name="theme-color" content="#ffffff"/><meta http-equiv="Cache-Control" content="no-transform"/><meta http-equiv="Cache-Control" content="no-siteapp"/><title>教程-文档</title><link rel="stylesheet" href="../ydoc/styles/style.css"/><meta name="author" content="ymfe"/><meta name="keywords"/><meta name="description" content="qunar scan tool"/><meta id="releativePath" content=".."/><link rel="stylesheet" href="../ydoc/ydoc-plugin-search/search.css"/></head><body><div class="g-doc"><div class="m-aside"><div class="m-summary" id="js-menu"><div class="m-summary-content" id="js-menu-content"><div class="m-summary-block"><ul class="m-summary-list"><li class="item"><a href="index.html" class="href">简介</a></li></ul></div><div class="m-summary-block"><ul class="m-summary-list"><li class="item"><div class="m-summary-block"><a href="install.html" class="href">安装依赖</a><ul class="m-summary-list indent"><li class="item"><a href="install.html#%e5%ae%89%e8%a3%85%e5%b7%a5%e5%85%b7" class="href">安装工具</a></li><li class="item"><a href="install.html#%e5%ae%89%e8%a3%85-qscan" class="href">安装 QScan</a></li></ul></div></li><li class="item"><div class="m-summary-block"><a href="" class="href">教程</a><ul class="m-summary-list indent"><li class="item"><a href="course.html#%e9%85%8d%e7%bd%ae" class="href">配置</a></li><li class="item"><div class="m-summary-block"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f" class="href">调用方式</a><ul class="m-summary-list indent"><li class="item"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f-%e5%91%bd%e4%bb%a4%e8%a1%8c%e8%b0%83%e7%94%a8" class="href">命令行调用</a></li><li class="item"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f-%e4%bd%9c%e4%b8%ba-node-%e6%a8%a1%e5%9d%97%e4%bd%bf%e7%94%a8" class="href">作为 node 模块使用</a></li><li class="item"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f-%e4%bd%9c%e4%b8%ba-koaexpress-%e7%9a%84%e4%b8%ad%e9%97%b4%e4%bb%b6%e4%bd%bf%e7%94%a8" class="href">作为 koa/express 的中间件使用</a></li></ul></div></li><li class="item"><a href="course.html#%e8%87%aa%e5%ae%9a%e4%b9%89%e6%a8%a1%e5%bc%8f" class="href">自定义模式</a></li></ul></div></li></ul></div></div></div><div class="m-summary-switch" id="js-summary-switch"><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="bottom"><g transform="translate(904.92214,-879.1482)"><path d="m -673.67664,1221.6502 -231.2455,-231.24803 55.6165,-55.627 c 30.5891,-30.59485 56.1806,-55.627 56.8701,-55.627 0.6894,0 79.8637,78.60862 175.9427,174.68583 l 174.6892,174.6858 174.6892,-174.6858 c 96.079,-96.07721 175.253196,-174.68583 175.942696,-174.68583 0.6895,0 26.281,25.03215 56.8701,55.627 l 55.6165,55.627 -231.245496,231.24803 c -127.185,127.1864-231.5279,231.248 -231.873,231.248 -0.3451,0 -104.688,-104.0616 -231.873,-231.248 z" fill="#fff"></path></g></svg><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="top"><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="aaa" fill="#fff" fill-rule="nonzero"><path d="M231.2455,342.502 L0,111.25397 L55.6165,55.62697 C86.2056,25.03212 111.7971,-2.99999998e-05 112.4866,-2.99999998e-05 C113.176,-2.99999998e-05 192.3503,78.60859 288.4293,174.6858 L463.1185,349.3716 L637.8077,174.6858 C733.8867,78.60859 813.060896,-2.99999997e-05 813.750396,-2.99999997e-05 C814.439896,-2.99999997e-05 840.031396,25.03212 870.620496,55.62697 L926.236996,111.25397 L694.9915,342.502 C567.8065,469.6884 463.4636,573.75 463.1185,573.75 C462.7734,573.75 358.4305,469.6884 231.2455,342.502 Z" id="Shape" transform="translate(463.118498, 286.874985) scale(1, -1) translate(-463.118498, -286.874985) "></path></g></g></svg></div></div><div class="m-main" id="js-panel"><header class="m-header" id="js-header"><div class="m-header-title js-logo"><a href="../index.html" target="_self"><img class="logo" width="36" src="../ydoc/images/[email protected]"/><h6 class="name">QScan</h6></a></div><div><div class="m-search">
<!DOCTYPE html><html lang="zh-CN"><head><meta charSet="UTF-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" sizes="180x180" href="../ydoc/images/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="../ydoc/images/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="../ydoc/images/favicon-16x16.png"/><link rel="manifest" href="../ydoc/images/manifest.json"/><link rel="mask-icon" href="../ydoc/images/safari-pinned-tab.svg" color="#5bbad5"/><meta name="theme-color" content="#ffffff"/><meta http-equiv="Cache-Control" content="no-transform"/><meta http-equiv="Cache-Control" content="no-siteapp"/><title>教程-文档</title><link rel="stylesheet" href="../ydoc/styles/style.css"/><meta name="author" content="ymfe"/><meta name="keywords"/><meta name="description" content="qunar scan tool"/><meta id="releativePath" content=".."/><link rel="stylesheet" href="../ydoc/ydoc-plugin-search/search.css"/></head><body><div class="g-doc"><div class="m-aside"><div class="m-summary" id="js-menu"><div class="m-summary-content" id="js-menu-content"><div class="m-summary-block"><ul class="m-summary-list"><li class="item"><a href="index.html" class="href">简介</a></li></ul></div><div class="m-summary-block"><ul class="m-summary-list"><li class="item"><div class="m-summary-block"><a href="install.html" class="href">安装依赖</a><ul class="m-summary-list indent"><li class="item"><a href="install.html#%e5%ae%89%e8%a3%85%e5%b7%a5%e5%85%b7" class="href">安装工具</a></li><li class="item"><a href="install.html#%e5%ae%89%e8%a3%85-qscan" class="href">安装 QScan</a></li></ul></div></li><li class="item"><div class="m-summary-block"><a href="" class="href">教程</a><ul class="m-summary-list indent"><li class="item"><a href="course.html#%e9%85%8d%e7%bd%ae" class="href">配置</a></li><li class="item"><div class="m-summary-block"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f" class="href">调用方式</a><ul class="m-summary-list indent"><li class="item"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f-%e5%91%bd%e4%bb%a4%e8%a1%8c%e8%b0%83%e7%94%a8" class="href">命令行调用</a></li><li class="item"><a href="course.html#%e8%b0%83%e7%94%a8%e6%96%b9%e5%bc%8f-%e4%bd%9c%e4%b8%ba-node-%e6%a8%a1%e5%9d%97%e4%bd%bf%e7%94%a8" class="href">作为 node 模块使用</a></li></ul></div></li><li class="item"><a href="course.html#%e8%87%aa%e5%ae%9a%e4%b9%89%e6%a8%a1%e5%bc%8f" class="href">自定义模式</a></li></ul></div></li></ul></div></div></div><div class="m-summary-switch" id="js-summary-switch"><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="bottom"><g transform="translate(904.92214,-879.1482)"><path d="m -673.67664,1221.6502 -231.2455,-231.24803 55.6165,-55.627 c 30.5891,-30.59485 56.1806,-55.627 56.8701,-55.627 0.6894,0 79.8637,78.60862 175.9427,174.68583 l 174.6892,174.6858 174.6892,-174.6858 c 96.079,-96.07721 175.253196,-174.68583 175.942696,-174.68583 0.6895,0 26.281,25.03215 56.8701,55.627 l 55.6165,55.627 -231.245496,231.24803 c -127.185,127.1864-231.5279,231.248 -231.873,231.248 -0.3451,0 -104.688,-104.0616 -231.873,-231.248 z" fill="#fff"></path></g></svg><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="top"><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="aaa" fill="#fff" fill-rule="nonzero"><path d="M231.2455,342.502 L0,111.25397 L55.6165,55.62697 C86.2056,25.03212 111.7971,-2.99999998e-05 112.4866,-2.99999998e-05 C113.176,-2.99999998e-05 192.3503,78.60859 288.4293,174.6858 L463.1185,349.3716 L637.8077,174.6858 C733.8867,78.60859 813.060896,-2.99999997e-05 813.750396,-2.99999997e-05 C814.439896,-2.99999997e-05 840.031396,25.03212 870.620496,55.62697 L926.236996,111.25397 L694.9915,342.502 C567.8065,469.6884 463.4636,573.75 463.1185,573.75 C462.7734,573.75 358.4305,469.6884 231.2455,342.502 Z" id="Shape" transform="translate(463.118498, 286.874985) scale(1, -1) translate(-463.118498, -286.874985) "></path></g></g></svg></div></div><div class="m-main" id="js-panel"><header class="m-header" id="js-header"><div class="m-header-title js-logo"><a href="../index.html" target="_self"><img class="logo" width="36" src="../ydoc/images/[email protected]"/><h6 class="name">QScan</h6></a></div><div><div class="m-search">
<div class="icon">&#xf0fd;</div>
<input type="text" class="input js-input" placeholder="搜索" />
<div class="m-search-result js-search-result"></div>
</div></div><nav class="m-header-nav js-nav"><ul class="m-header-items"><li class="item active"><a class="href" href="index.html">文档</a></li><li class="item "><a class="href" href="../usage/index.html">方案</a></li><li class="item "><a class="href" href="../experience/index.html">前车之鉴</a></li></ul></nav><div id="js-nav-btn" class="m-header-btn ui-font-ydoc"></div></header><div class="m-content" id="js-content"><div id="markdown-body" class="m-content-container markdown-body"><h1>教程</h1>
<p>为了保证核心代码的纯粹,我们只提供最纯粹的自动扫码功能。</p>
<p>QScan 可以作为一个 Node 模块使用,也可以作为一个 koa/express 中间件使用,因此使用起来非常灵活 ~</p>
<p>QScan 可以直接使用命令行调用,也可以作为一个 Node 模块使用,使用起来非常灵活 ~</p>
<h2 id="配置">配置</h2>
<p>QScan 扫码需要一个配置,这个配置可以写在 <code>~/.qscanrc</code> 文件中,也可以写在代码中,这个配置的格式如下:</p>
<pre><code class="language-json"><span class="token punctuation">{</span>
Expand Down Expand Up @@ -126,32 +126,6 @@ <h4>scan.loadModel({ model, udid, port, opts }) 自定义传入的 Model:</h4>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h3 id="调用方式-作为-koaexpress-的中间件使用">作为 koa/express 的中间件使用</h3>
<pre><code class="language-js"><span class="token keyword">const</span> Koa <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'Koa'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> app <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Koa</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> QScan <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'qscan'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// model 配置</span>
<span class="token keyword">const</span> modelOpts <span class="token operator">=</span> <span class="token punctuation">{</span>
<span class="token string">'wx-default'</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token comment">// model 名称</span>
udid<span class="token punctuation">:</span> <span class="token string">'3HX0217705004280'</span><span class="token punctuation">,</span> <span class="token comment">// 安卓设备 id,通过 adb service 命令查看</span>
port<span class="token punctuation">:</span> <span class="token string">'4723'</span><span class="token punctuation">,</span> <span class="token comment">// 端口号</span>
opts<span class="token punctuation">:</span> <span class="token punctuation">{</span>
user<span class="token punctuation">:</span> <span class="token string">'xxx'</span><span class="token punctuation">,</span> <span class="token comment">// 微信用户名</span>
pass<span class="token punctuation">:</span> <span class="token string">'xxx'</span> <span class="token comment">// 微信密码</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// 使用 QScan 的中间件,传入 model 名称与选项</span>
app<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>QScan<span class="token punctuation">.</span><span class="token function">middleWare</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
modelOpts <span class="token comment">// 传入 model 选项</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

app<span class="token punctuation">.</span><span class="token function">listen</span><span class="token punctuation">(</span><span class="token number">9001</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token template-string"><span class="token string">`Port[9001] started! `</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h2 id="自定义模式">自定义模式</h2>
<p>QScan 提供了自定义模式</p>
</div><div class="m-content-container m-paging"><div class="m-paging-prev m-paging-item"><a href="install.html" class="href"><span class="ui-font-ydoc"></span>安装依赖</a></div></div></div></div></div><div></div><script>
Expand Down
Loading

0 comments on commit cc407fe

Please sign in to comment.