Skip to content

Commit

Permalink
fix: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Jul 18, 2023
1 parent fc29bb1 commit 8fa5320
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions docs/src/guide/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@

- 首先我们来看数据绑定,最基本形式是使用“Mustache”语法(双花括号)的文本插值:
<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>output {{sender.user_id}}</span></ChatMsg>
<ChatMsg id="1659488338"><span v-pre>send {{session.sender.user_id}}</span></ChatMsg>
<ChatMsg id="1689919782">1659488338</ChatMsg>
</ChatHistory>
可以看到,在使用文本插值后,可以很快速的让机器人输出信息,我们来看在实际运行中的一个 demo

<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>output [日志][用户:{{sender.nickname}}({{sender.user_id}})]是一个来自{{sender.area == ""?"未知":sender.area}}的{{sender.age}}岁{{sender.sex == "unknown"?"人妖":sender.sex}}</span></ChatMsg>
<ChatMsg id="1659488338"><span v-pre>send [日志][用户:{{session.sender.nickname}}({{session.sender.user_id}})]是一个来自{{session.sender.area == ""?"未知":sender.area}}的{{session.sender.age}}岁{{session.sender.sex == "unknown"?"人妖":sender.sex}}</span></ChatMsg>
<ChatMsg id="1689919782">[日志][用户:master(1659488338)]是一个来自四川的26岁male</ChatMsg>
</ChatHistory>

## image 标签

- image 标签提供了一种快速发送照片的方法,请看下面的例子
<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>output &lt;image src="https://maohaoji.com/image标签.gif"/&gt;</span></ChatMsg>
<ChatMsg id="1659488338"><span v-pre>send &lt;image src="https://maohaoji.com/image标签.gif"/&gt;</span></ChatMsg>
<ChatMsg id="1689919782"> <!-- image标签示例图片由taidixiong233提供 github.com/taidixiong233 !--><img alt="" style="height:100px" src="https://maohaoji.com/image标签.gif" /></ChatMsg>
</ChatHistory>
可以看到,使用 src 标签可以很快的发送想要发送的图片,下面我们来看一个使用 image 标签获取用户头像的实例
<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>output &lt;image :src="`https://q1.qlogo.cn/g?b=qq&nk=${sender.user_id}&s=100`"/&gt;</span></ChatMsg>
<ChatMsg id="1659488338"><span v-pre>send &lt;image :src="`https://q1.qlogo.cn/g?b=qq&nk=${sender.user_id}&s=100`"/&gt;</span></ChatMsg>
<ChatMsg id="1689919782"> <!-- image标签示例图片由taidixiong233提供 github.com/taidixiong233 !--><img alt="" style="height:100px" src="https://q1.qlogo.cn/g?b=qq&nk=1659488338&s=100" /></ChatMsg>
</ChatHistory>
ps 这里的:src 代表此处使用变量为src赋值,在 zhin 中,不支持v-bind代替这个语法,请注意与vue的区别;session可选字段参考`Session`
Expand All @@ -40,7 +40,7 @@
ps &lt;random&gt;会随机输出内部元素,所以实际输出不一定是图示
<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>
output 你喜欢&lt;random&gt;<br />
send 你喜欢&lt;random&gt;<br />
&lt;template&gt;御姐&lt;/template&gt;<br />
&lt;template&gt;萝莉&lt;/template&gt;<br />
&lt;/random&gt;
Expand All @@ -53,10 +53,10 @@
下面这个例子可以体现使用 template 便签的美观性
<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>
output &lt;template&gt;<br />
send &lt;template&gt;<br />
今日图片<br />
&lt;image src="https://maohaoji.com/image标签.gif"/&gt;<br />
欢迎您{{sender.nickname}}({{sender.user_id}})<br />
欢迎您{{session.sender.nickname}}({{session.sender.user_id}})<br />
&lt;image :src="`https://q1.qlogo.cn/g?b=qq&nk=${sender.user_id}&s=100`"/&gt;<br />
&lt;/template&gt;<br />
</span></ChatMsg>
Expand All @@ -77,7 +77,7 @@ ps random 内元素请尽可能使用`<template>`标签包装,以免出现奇
下来我们来看一个例子
<ChatHistory>
<ChatMsg id="1659488338"><span v-pre>
output &lt;random&gt;<br />
send &lt;random&gt;<br />
&lt;template&gt;我猜你喜欢&gt;image src="https://maohaoji.com/zhindocimage/%E9%BB%91%E4%B8%9D.jpg"/ &gt;&lt;/template &gt;<br />
&lt;template&gt;我猜你喜欢&gt;image src="https://maohaoji.com/zhindocimage/%E7%99%BD%E4%B8%9D.jpeg"/&gt; &lt;/template&gt;<br />
&lt;template&gt;我猜你喜欢&gt;image src="https://maohaoji.com/zhindocimage/%E6%B8%94%E7%BD%91.jpg"/&gt; &lt;/template&gt;<br />
Expand All @@ -94,7 +94,7 @@ output &lt;random&gt;<br />
- time 标签相比于 new Date()然后解析来获取时间字符串来说是很方便容易的,它会输出 yyyy-MM-dd hh:mm:ss 格式的时间,我们来看有个例子
<ChatHistory>
<ChatMsg id="1659488338">
<span v-pre>output 现在是&lt;time/&gt;</span>
<span v-pre>send 现在是&lt;time/&gt;</span>
</ChatMsg>
<ChatMsg id="1689919782"> <!-- image标签示例图片由taidixiong233提供 github.com/taidixiong233 !-->
<span>现在是 2023-02-0518:52:02</span>
Expand All @@ -105,7 +105,7 @@ output &lt;random&gt;<br />
<ChatHistory>
<ChatMsg id="1659488338">
<span v-pre>
output &lt;image :src="`https://q1.qlogo.cn/g?b=qq&nk=${sender.user_id}&s=100`" /&gt;[日志][&lt;time /&gt;][用户:{{sender.nickname}}({{sender.user_id}})]是一个来自{{sender.area == ""?"未知":sender.area}}的{{sender.age}}岁{{sender.sex == "unknown"?"人妖":sender.sex}}
send &lt;image :src="`https://q1.qlogo.cn/g?b=qq&nk=${sender.user_id}&s=100`" /&gt;[日志][&lt;time /&gt;][用户:{{session.sender.nickname}}({{session.sender.user_id}})]是一个来自{{session.sender.area == ""?"未知":sender.area}}的{{session.sender.age}}岁{{session.sender.sex == "unknown"?"人妖":sender.sex}}
</span>
</ChatMsg>
<ChatMsg id="1689919782"> <!-- image标签示例图片由taidixiong233提供 github.com/taidixiong233 !-->
Expand All @@ -120,7 +120,7 @@ output &lt;random&gt;<br />
<ChatHistory>
<ChatMsg id="1659488338">
<span v-pre>
output &lt;at user_id="1659488338" /&gt;
send &lt;at user_id="1659488338" /&gt;
</span>
</ChatMsg>
<ChatMsg id="1689919782">
Expand All @@ -131,7 +131,7 @@ output &lt;random&gt;<br />
<ChatHistory>
<ChatMsg id="1659488338">
<span v-pre>
output &lt;at :user_id="sender.user_id" /&gt;
send &lt;at :user_id="sender.user_id" /&gt;
</span>
</ChatMsg>
<ChatMsg id="1689919782">
Expand All @@ -144,7 +144,7 @@ output &lt;random&gt;<br />
<ChatHistory>
<ChatMsg id="1659488338">
<span v-pre>
output &lt;random&gt;<br />
send &lt;random&gt;<br />
&lt;template&gt;taidixiong233<br />
&lt;at user_id="2870926164" /&gt;<br />
&lt;/template&gt;<br />
Expand Down Expand Up @@ -174,7 +174,7 @@ output &lt;random&gt;<br />

<ChatHistory>
<ChatMsg id="1659488338">
<span v-pre>output 你是&lt;prompt&gt;请输入姓名&lt;/prompt&gt;,你在&lt;prompt&gt;请输入地址&lt;/prompt&gt;,是个可爱的&lt;prompt&gt;请输入性别&lt;/prompt&gt;孩子</span>
<span v-pre>send 你是&lt;prompt&gt;请输入姓名&lt;/prompt&gt;,你在&lt;prompt&gt;请输入地址&lt;/prompt&gt;,是个可爱的&lt;prompt&gt;请输入性别&lt;/prompt&gt;孩子</span>
</ChatMsg>
<ChatMsg id="1689919782">
<span>请输入姓名</span>
Expand Down Expand Up @@ -207,7 +207,7 @@ output &lt;random&gt;<br />
- confirm 标签可以问询用户是否确定、继续,我们来看一段演示
<ChatHistory>
<ChatMsg id="1659488338">
<span>output 你的选择是&lt;confirm/&gt;</span>
<span>send 你的选择是&lt;confirm/&gt;</span>
</ChatMsg>
<ChatMsg id="1689919782">
<span>输入 yes,y,Yes,YES,Y,.,。,确认为确认</span>
Expand All @@ -225,7 +225,7 @@ output &lt;random&gt;<br />
- execute 标签可以用于执行机器人命令,下图给出了示例,具体命令列表请查看命令列表
<ChatHistory>
<ChatMsg id="1659488338">
<span>output &lt;execute&gt;status&lt;/execute&gt;</span>
<span>send &lt;execute&gt;status&lt;/execute&gt;</span>
</ChatMsg>
<ChatMsg id="1689919782">
<span>当前状态:<br />
Expand All @@ -251,7 +251,7 @@ output &lt;random&gt;<br />
- face 标签可以快速的发送表情消息,需要使用表情的id,示例如下
<ChatHistory>
<ChatMsg id="1659488338">
<span>output &lt;face id="2" /&gt;</span>
<span>send &lt;face id="2" /&gt;</span>
</ChatMsg>
<ChatMsg id="1689919782">
<img alt="" src="https://maohaoji.com/zhindocimage/2.png" style="width: 25px" />
Expand All @@ -261,12 +261,12 @@ output &lt;random&gt;<br />
- 这是一个组合使用face标签的例子
<ChatHistory>
<ChatMsg id="1659488338">
<span>output &lt;random&gt;&lt;face id="1" /&gt;&lt;face id="2" /&gt;&lt;/random&gt;</span>
<span>send &lt;random&gt;&lt;face id="1" /&gt;&lt;face id="2" /&gt;&lt;/random&gt;</span>
</ChatMsg>
<ChatMsg id="1689919782">
<img alt="" src="https://maohaoji.com/zhindocimage/2.png" style="width: 25px" />
</ChatMsg>
<ChatMsg id="2870926164" nickname="taidixiong233">
<span>机器人发的表情色迷迷的</span>
</ChatMsg>
</ChatHistory>
</ChatHistory>

0 comments on commit 8fa5320

Please sign in to comment.