|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
多说在存储评论的时候其实是把User-Agent一起存储的,只是不显示出来,这个插件的作用就是把User-Agent显示出来,同时还可以标记站长的回复。
|
|
多说在存储评论的时候其实是把User-Agent一起存储的,只是不显示出来,这个插件的作用就是把User-Agent显示出来,同时还可以标记站长的回复。
|
|
|
|
|
|
-使用方法
|
|
|
|
|
|
+安装
|
|
---
|
|
---
|
|
可以通过bower安装:
|
|
可以通过bower安装:
|
|
|
|
|
|
@@ -16,20 +16,32 @@ $ npm install bower
|
|
$ bower install duoshuo-ua
|
|
$ bower install duoshuo-ua
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+文档
|
|
|
|
+---
|
|
duoshuoQuery中可以定义`myIds`和`getUAString`函数:
|
|
duoshuoQuery中可以定义`myIds`和`getUAString`函数:
|
|
-* myIds:是站长自己的多说数字id,可以有多个,用于区分站长的回复,并可在`getUAString`中加上不同的标记,如不定义则不会对站长回复进行区分。
|
|
|
|
-* getUAString:是对每条留言显示内容进行处理的函数,默认将加上操作系统和浏览器的显示。
|
|
|
|
-
|
|
|
|
|
|
+* myIds: *Array*
|
|
|
|
+ 是站长自己的多说数字id,可以有多个,用于区分站长的回复,并可在`getUAString`中加上不同的标记,如不定义则不会对站长回复进行区分。
|
|
|
|
+
|
|
|
|
+* getUAString: *function* (local)
|
|
|
|
+ 是对每条留言显示内容进行处理的函数,默认将加上操作系统和浏览器的显示。
|
|
|
|
+ 参数local是一个object,包括以下属性:
|
|
|
|
+ * agent: *string*
|
|
|
|
+ 本条回复的UserAgent字符串。
|
|
|
|
+ * webmaster: *boolean*
|
|
|
|
+ 是否为站长回复。
|
|
|
|
+
|
|
|
|
+下面是一个简单的例子:
|
|
``` HTML
|
|
``` HTML
|
|
<html>
|
|
<html>
|
|
<head>
|
|
<head>
|
|
|
|
|
|
-<!-- 第1部分:在embed.js之前加载duoshuo-ua.min.js -->
|
|
|
|
-<script src=dist/duoshuo-ua.min.js></script>
|
|
|
|
-
|
|
|
|
-<!-- 第2部分:也可写成异步加载,请写在第1部分后面 -->
|
|
|
|
|
|
+<!-- 第1部分:在embed.js之前定义duoshuoQuery和加载duoshuo-ua
|
|
|
|
+两者顺序可以交换-->
|
|
|
|
+<script src="dist/duoshuo-ua-with-css.min.js"></script>
|
|
<script>var duoshuoQuery={short_name:'test',myIds:[1234567]};</script>
|
|
<script>var duoshuoQuery={short_name:'test',myIds:[1234567]};</script>
|
|
-<script src=http://static.duoshuo.com/embed.js></script>
|
|
|
|
|
|
+
|
|
|
|
+<!-- 第2部分:可写成异步加载,必须写在第1部分后面 -->
|
|
|
|
+<script src="http://static.duoshuo.com/embed.js"></script>
|
|
|
|
|
|
<!-- 只需要按以上顺序加载,不一定要写在<head>中 -->
|
|
<!-- 只需要按以上顺序加载,不一定要写在<head>中 -->
|
|
|
|
|
|
@@ -44,12 +56,13 @@ duoshuoQuery中可以定义`myIds`和`getUAString`函数:
|
|
|
|
|
|
注:
|
|
注:
|
|
|
|
|
|
-1. dist/duoshuo-ua-with-css.min.js是压缩后的代码,集成了CSS,无需单独加载CSS文件,如需自定义,请使用未压缩版本。
|
|
|
|
-1. 此版本使用`Object.defineProperty`,仅支持IE9+。
|
|
|
|
|
|
+1. `dist/duoshuo-ua-with-css.min.js`是压缩后的代码,集成了CSS,无需单独加载CSS文件,也可使用`dist/duoshuo-ua.min.js`和`dist/duoshuo-ua.min.css`或自定义的样式。
|
|
|
|
+1. 此分支使用`Object.defineProperty`,仅支持IE9+,如需支持IE8-可参考Compatible分支。
|
|
|
|
+1. 默认的UA解析比较简单,如有较高要求,可使用<https://github.com/faisalman/ua-parser-js>,参考[examples/faisalman.html](examples/faisalman.html)。
|
|
|
|
|
|
-效果可参见:
|
|
|
|
|
|
|
|
-1. 我的网站:<http://geraldl.net/about>
|
|
|
|
-1. 在线工具:<http://www.atool.org>
|
|
|
|
|
|
+案例
|
|
|
|
+---
|
|
|
|
|
|
-如果对UA解析要求更高一点可以使用<https://github.com/faisalman/ua-parser-js>,参考[test/faisalman.html](test/faisalman.html)。
|
|
|
|
|
|
+1. 我的网站:<http://gerald.top/code/duoshuo-ua>
|
|
|
|
+1. 在线工具:<http://www.atool.org>
|