Skip to content

Commit

Permalink
24/12/20
Browse files Browse the repository at this point in the history
Former-commit-id: 9905edb
  • Loading branch information
WindRunnerMax committed Dec 20, 2024
1 parent e4174c2 commit 3b4cda2
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 140 deletions.
1 change: 1 addition & 0 deletions .scripts/sync-blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const blog = path.resolve(root, `../Blog`);
for (const group of DOCS_GROUP) {
console.log("Processing", group);
const from = path.resolve(root, group);
await exec(`rm -rf ${blog}/${group}`);
await exec(`cp -r ${from} ${blog}`);
}

Expand Down
2 changes: 2 additions & 0 deletions .scripts/sync-ssg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const ssg = path.resolve(root, `../Blog-SSG`);
console.log("Processing", group);
const from = path.resolve(root, group);
const to = path.resolve(ssg, `docs/zh-cn`);
await exec(`rm -rf ${to}/${group}`);
await exec(`cp -r ${from} ${to}`);
}

console.log("Processing", "I18N");
const from = path.resolve(root, `i18n`);
const to = path.resolve(ssg, `docs/en-us`);
await exec(`rm -rf ${to}/*`);
await exec(`cp -r ${from}/* ${to}`);

console.log("Processing", "sidebar.ts");
Expand Down
264 changes: 132 additions & 132 deletions Environment/Ubuntu16.04安装QQ机器人.md
Original file line number Diff line number Diff line change
@@ -1,133 +1,133 @@
# Ubuntu安装QQ机器人
> 看了看现在QQ机器人似乎只有酷Q机器人有Docker可以在linux上运行了
> 那就k开始装酷Q机器人,资源占用也不是很大,大概占用180M内存吧
## 安装酷Q HTTP
首先安装好`docker`

![](screenshots/2023-04-14-20-49-41.png)

酷Q官网提供了`docker` [COOLQ Docker 2.0](https://cqp.cc/t/34558)
但是我是打算通过`HTTP`进行一些功能开发的,于是选择了大佬做的带`HTTP`插件的 [CQHTTP Docker](https://richardchien.gitee.io/coolq-http-api/docs/4.12/#/Docker)
首先`pull`镜像,我觉得下载的比较慢,挂了一个`screen`慢慢下

```shell
docker pull richardchien/cqhttp:latest
```
下载完成后启动容器进行测试

```powershell
docker run -ti --rm --name coolq \
-v /home/coolq:/home/user/coolq \ # 将宿主目录挂载到容器内用于持久化 酷Q 的程序文件
-p 9000:9000 \ # noVNC 端口,用于从浏览器控制 酷Q
-p 5700:5700 \ # HTTP API 插件开放的端口
-e COOLQ_ACCOUNT=123456 \ # 要登录的 QQ 账号,可选但建议填
-e CQHTTP_POST_URL=http://example.com:8080 \ # 事件上报地址
-e VNC_PASSWD=111111111 \ # noVnc密码
-e CQHTTP_SERVE_DATA_FILES=yes \ # 允许通过 HTTP 接口访问 酷Q 数据文件
richardchien/cqhttp:latest
```
此时可以登录`noVNC`查看并且登录了

![](screenshots/2023-04-14-20-49-49.png)

如果测试没有问题的话,就讲启动参数中的`--rm`改为`-d`就可以存储运行了

```shell
docker start coolq
docker stop coolq
```
## supervisord开机自启
由于我有一个定时任务多久开关机一次,但是`coolq`不会开机自启动,选择`supervisord`进行开机自启
注意`autorestart=false`,由于启动`coolq`后会`exit(0)`,所以`supervisord`会不断尝试重启,我们只需要他启动一次就好
```
[program:coolq]
command=docker start coolq
stderr_logfile=/var/log/supervisor/error_coolq.log
stdout_logfile=/var/log/supervisor/coolq.log
directory=/home
autostart=true
user=docker
autorestart=false
```

## 配置信息
### 账号的配置文件
注意上报地址不能为`127.0.0.1`,因为容器内有自己的`127.0.0.1`,一般情况下可使用机器`ip`作为上报地址

```
[123456789]
use_ws = false
use_ws_reverse = false
serve_data_files = yes
access_token = 11111111111111111
log_level = error
post_url = http://example.com:8080
secret = 11111111111111111
show_log_console = false
event_filter = filter.json
```

### 过滤上报HTTP配置文件
* 私聊消息
* 非匿名发送的@机器人的群消息
* 非匿名的‘出来’群消息
* 加好友消息、加群邀请、加群请求

```
{
".or": [
{
"message_type": "private"
},
{
"message_type": "group",
"anonymous": {
".eq": null
},
"raw_message": {
".regex": "CQ:at,qq=2450184313|^出来$"
}
},
{
"post_type": "request"
}
]
}
```

## 防火墙
由于`Docker`直接更改`iptables`且优先级比`ufw`高,不能通过`ufw`控制其监听端口的开放关闭,需要手动配置`Docker`信息

```shell
# vim /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
```

```shell
# vim /etc/ufw/before.rules
# *filter前面添加下面内容
# 172.17.0.0/16 为docker网桥地址,可能不同
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING ! -o docker0 -s 172.17.0.0/16 -j MASQUERADE
COMMIT

```

```shell
# vim /etc/default/docker
# 添加此条配置信息
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --iptables=false"
```
```shell
# vim /etc/docker/daemon.json
# 没有此文件则创建
{
"iptables": false
}
```
重启`daemon``docker``ufw`
```shell
systemctl daemon-reload && systemctl restart docker && ufw reload
# Ubuntu安装QQ机器人
> 看了看现在QQ机器人似乎只有酷Q机器人有Docker可以在linux上运行了
> 那就k开始装酷Q机器人,资源占用也不是很大,大概占用180M内存吧
## 安装酷Q HTTP
首先安装好`docker`

![](screenshots/2023-04-14-20-49-41.jpg)

酷Q官网提供了`docker` [COOLQ Docker 2.0](https://cqp.cc/t/34558)
但是我是打算通过`HTTP`进行一些功能开发的,于是选择了大佬做的带`HTTP`插件的 [CQHTTP Docker](https://richardchien.gitee.io/coolq-http-api/docs/4.12/#/Docker)
首先`pull`镜像,我觉得下载的比较慢,挂了一个`screen`慢慢下

```shell
docker pull richardchien/cqhttp:latest
```
下载完成后启动容器进行测试

```powershell
docker run -ti --rm --name coolq \
-v /home/coolq:/home/user/coolq \ # 将宿主目录挂载到容器内用于持久化 酷Q 的程序文件
-p 9000:9000 \ # noVNC 端口,用于从浏览器控制 酷Q
-p 5700:5700 \ # HTTP API 插件开放的端口
-e COOLQ_ACCOUNT=123456 \ # 要登录的 QQ 账号,可选但建议填
-e CQHTTP_POST_URL=http://example.com:8080 \ # 事件上报地址
-e VNC_PASSWD=111111111 \ # noVnc密码
-e CQHTTP_SERVE_DATA_FILES=yes \ # 允许通过 HTTP 接口访问 酷Q 数据文件
richardchien/cqhttp:latest
```
此时可以登录`noVNC`查看并且登录了

![](screenshots/2023-04-14-20-49-49.jpg)

如果测试没有问题的话,就讲启动参数中的`--rm`改为`-d`就可以存储运行了

```shell
docker start coolq
docker stop coolq
```
## supervisord开机自启
由于我有一个定时任务多久开关机一次,但是`coolq`不会开机自启动,选择`supervisord`进行开机自启
注意`autorestart=false`,由于启动`coolq`后会`exit(0)`,所以`supervisord`会不断尝试重启,我们只需要他启动一次就好
```
[program:coolq]
command=docker start coolq
stderr_logfile=/var/log/supervisor/error_coolq.log
stdout_logfile=/var/log/supervisor/coolq.log
directory=/home
autostart=true
user=docker
autorestart=false
```

## 配置信息
### 账号的配置文件
注意上报地址不能为`127.0.0.1`,因为容器内有自己的`127.0.0.1`,一般情况下可使用机器`ip`作为上报地址

```
[123456789]
use_ws = false
use_ws_reverse = false
serve_data_files = yes
access_token = 11111111111111111
log_level = error
post_url = http://example.com:8080
secret = 11111111111111111
show_log_console = false
event_filter = filter.json
```

### 过滤上报HTTP配置文件
* 私聊消息
* 非匿名发送的@机器人的群消息
* 非匿名的‘出来’群消息
* 加好友消息、加群邀请、加群请求

```
{
".or": [
{
"message_type": "private"
},
{
"message_type": "group",
"anonymous": {
".eq": null
},
"raw_message": {
".regex": "CQ:at,qq=2450184313|^出来$"
}
},
{
"post_type": "request"
}
]
}
```

## 防火墙
由于`Docker`直接更改`iptables`且优先级比`ufw`高,不能通过`ufw`控制其监听端口的开放关闭,需要手动配置`Docker`信息

```shell
# vim /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
```

```shell
# vim /etc/ufw/before.rules
# *filter前面添加下面内容
# 172.17.0.0/16 为docker网桥地址,可能不同
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING ! -o docker0 -s 172.17.0.0/16 -j MASQUERADE
COMMIT

```

```shell
# vim /etc/default/docker
# 添加此条配置信息
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --iptables=false"
```
```shell
# vim /etc/docker/daemon.json
# 没有此文件则创建
{
"iptables": false
}
```
重启`daemon``docker``ufw`
```shell
systemctl daemon-reload && systemctl restart docker && ufw reload
```
Binary file added Environment/screenshots/2023-04-14-20-49-41.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Environment/screenshots/2023-04-14-20-49-49.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions I18N/Environment/Ubuntu16.04安装QQ机器人.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Installing CoolQ HTTP
First, make sure to install `docker`.

![](screenshots/2023-04-14-20-49-41.png)
![](screenshots/2023-04-14-20-49-41.jpg)

The CoolQ official website provides the `docker` [COOLQ Docker 2.0](https://cqp.cc/t/34558).
However, I prefer to use the one with the `HTTP` plugin for some functionality development. I chose the one made by a senior, which contains the `HTTP` plugin [CQHTTP Docker](https://richardchien.gitee.io/coolq-http-api/docs/4.12/#/Docker).
Expand All @@ -30,7 +30,7 @@ docker run -ti --rm --name coolq \
```
At this point, you can log in to `noVNC` to view and log in.

![](screenshots/2023-04-14-20-49-49.png)
![](screenshots/2023-04-14-20-49-49.jpg)

If the test is successful, change `--rm` to `-d` in the start parameters for persistent running.

Expand Down
2 changes: 1 addition & 1 deletion I18N/RichText/初探富文本之编辑器引擎.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The **data structure** of a text **sample** looks like this:
* Excellent articles on `slate` can be found at `https://github.com/yoyoyohamapi/book-slate-editor-design`.

## Quill.js
`Quill` is a modern rich text editor with excellent compatibility and powerful extensibility, offering some out-of-the-box features. It was open-sourced in `2012` and brought many new features to the rich text editor, making it one of the most popular open-source editors with a rich ecosystem. You can find numerous examples, including comprehensive collaborative instances, on platforms like `Github`.
`Quill` is a modern rich text editor with excellent compatibility and powerful extensibility, offering some out-of-the-box features. It was open-sourced in `2012` and brought many new features to the rich text editor, making it one of the most popular open-source editors with a rich ecosystem. You can find numerous examples, including comprehensive collaborative instances, on platforms like `GitHub`.

The design principles of the framework are described in the documentation:

Expand Down
2 changes: 1 addition & 1 deletion I18N/RichText/基于slate构建文档编辑器.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Description

[Github](https://github.com/WindrunnerMax/DocEditor)[Editor DEMO](https://windrunnermax.github.io/DocEditor/)
[GitHub](https://github.com/WindrunnerMax/DocEditor)[Editor DEMO](https://windrunnermax.github.io/DocEditor/)

A rich text editor is a text editor that can be embedded in a browser and provides a what-you-see-is-what-you-get editing experience. There are many out-of-the-box rich text editors available, such as `UEditor` and `WangEditor`. They may have limited customization, but they offer quick implementation and visible results. On the other hand, frameworks like `Draft.js` and `Slate.js` serve as the core or controller of a rich text editor, providing high customizability but requiring more development time. When considering practical application or technology selection, it is important to conduct thorough research, as there is no absolute advantage or disadvantage of a framework in business scenarios – it's all about suitability.

Expand Down
2 changes: 1 addition & 1 deletion I18N/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sidebar: true

If you like it, please give a `star` on this [EveryDay](https://github.com/WindrunnerMax/EveryDay) 😁

This is a learning journey of a frontend newbie,If you only learn without recording anything, it's basically equivalent to learning in vain. The name of this repository `EveryDay` hopes to inspire me to learn every day. The `gh-pages` branch of the repository is my blog site, the content in the blog is relatively extensive, including study notes of the daily question, records of working on projects, and problems encountered, etc. For technical related articles are written mainly based on summarizing and learning from various articles, the content includes`HTML` basics, `CSS` basics, `JavaScript` basics and extension, `Browser` related, `Vue` usage and analysis, `React` usage and analysis, `Plugin` related, `Patterns` design patterns, `Linux` commands, `MiniProgram` related, `App` related, `PHP` related, `Java` related, `Security` related, `Environment` setup, `IMGProcess` image processing, `LeetCode` solutions, `Interview` related, `MyLife` related, etc. The content is relatively basic and is written with the goal of being able to run immediately.
This is a learning journey of a frontend newbie,If you only learn without recording anything, it's basically equivalent to learning in vain. The name of this repository `EveryDay` hopes to inspire me to learn every day. The `gh-pages` branch of the repository is my blog site, the content in the blog is relatively extensive, including study notes of the daily question, records of working on projects, and problems encountered, etc. For technical related articles are written mainly based on summarizing and learning from various articles, the content includes`HTML` basics, `CSS` basics, `JavaScript` basics and extension, `Browser` related, `Vue` usage and analysis, `React` usage and analysis, `Plugin` related, `RichText` related, `Patterns` design patterns, `Linux` commands, `MiniProgram` related, `App` related, `PHP` related, `Java` related, `Security` related, `Environment` setup, `IMGProcess` image processing, `LeetCode` solutions, `Interview` related, `MyLife` related, etc. The content is relatively basic and is written with the goal of being able to run immediately.

You can [Timeline](https://github.com/WindrunnerMax/EveryDay/blob/master/CATALOG.md) if you want to read the articles in the order I wrote them. If you want a neat view, visit [Blog](https://blog.touchczy.top/). The blog is also the `gh-pages` branch of this repository, which was built on `Git Pages` as a static page and uses `jsdelivr` and `cloudflare` for cache to alleviate access speed problems in China. Later, an `SSG` version of the [Blog-SSG](https://blog-ssg.touchczy.top/) was deployed on the `gh-pages-ssg` branch, and provided an English translation version with the help of `ChatGPT`. The branch is deployed on `Vercel` to alleviate access speed problems in China. There is more content in my blog, besides study notes there are project work records and problems encountered, etc. if you like it, please give a `star`. This is really important to me.

Expand Down
Binary file added Picture/RICHTEXT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
版本库中共有`489`篇文章,总计`92185`行,`1086866`字,`3030415`字符。
<!-- Summary End -->

这是一个前端小白的学习历程,如果只学习而不记录点什么那基本就等于白学了。这个版本库的名字`EveryDay`就是希望激励我能够每天学习,下面的文章就是从`2020.02.25`开始积累的文章,都是参考众多文章归纳整理学习而写的,文章包括了`HTML`基础、`CSS`基础、`JavaScript`基础与拓展、`Browser`浏览器相关、`Vue`使用与分析、`React`使用与分析、`Plugin`插件相关、`Patterns`设计模式、`Linux`命令、`LeetCode`题解等类别,内容都是比较基础的,毕竟我也还是个小。此外基本上每个示例都是本着能够即时运行为目标的,新建一个`HTML`文件复制之后即可在浏览器运行或者直接可以在`console`中运行。
这是一个前端小白的学习历程,如果只学习而不记录点什么那基本就等于白学了。这个版本库的名字`EveryDay`就是希望激励我能够每天学习,下面的文章就是从`2020.02.25`开始积累的文章,都是参考众多文章归纳整理学习而写的,文章包括了`HTML`基础、`CSS`基础、`JavaScript`基础与拓展、`Browser`浏览器相关、`Vue`使用与分析、`React`使用与分析、`Plugin`插件相关、`RichText`富文本、`Patterns`设计模式、`Linux`命令、`LeetCode`题解等类别,内容都是比较基础的,毕竟我也还是个小。此外基本上每个示例都是本着能够即时运行为目标的,新建一个`HTML`文件复制之后即可在浏览器运行或者直接可以在`console`中运行。

如果想按照笔记顺序进行阅读的话可以 [查看目录](./Timeline.md) ,另外如果想更条理地查看的话可以访问 [我的博客](https://blog.touchczy.top/),博客同时也是本版本库的`gh-pages`分支,是作为纯静态页面搭建在`Git Pages`上的,使用`jsdelivr`以及`cloudflare`作为缓存缓解国内访问速度问题。后期还在`gh-pages-ssg`分支上部署了`SSG`版本的 [新版博客](https://blog-ssg.touchczy.top/),并且借助`ChatGPT`提供了英文翻译版本,分支是部署在`Vercel`上来缓解国内访问速度问题。在博客中的内容就相对比较多了,除了学习笔记之外还有一些做项目时的记录以及遇到的坑等。`HXDM`如果觉得还不错,点个`star`吧,这个对我真的很重要。

Expand Down
2 changes: 1 addition & 1 deletion RichText/初探富文本之编辑器引擎.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* 关于`slate`非常不错的文章`https://github.com/yoyoyohamapi/book-slate-editor-design`

## Quill.js
`quill`是一个现代富文本编辑器,具备良好的兼容性及强大的可扩展性,还提供了部分开箱即用的功能。`quill`是在`2012`年开源的,`quill`的出现给富文本编辑器带了很多新的东西,也是目前开源编辑器里面受众非常大的一款编辑器,至今为止的生态已经非常的丰富,可以在`Github`等找到大量的示例,包括比较完善的协同实例。
`quill`是一个现代富文本编辑器,具备良好的兼容性及强大的可扩展性,还提供了部分开箱即用的功能。`quill`是在`2012`年开源的,`quill`的出现给富文本编辑器带了很多新的东西,也是目前开源编辑器里面受众非常大的一款编辑器,至今为止的生态已经非常的丰富,可以在`GitHub`等找到大量的示例,包括比较完善的协同实例。

`quill`的文档中有对于框架的设计原则上的描述:

Expand Down
2 changes: 1 addition & 1 deletion RichText/基于slate构建文档编辑器.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## 描述

[Github](https://github.com/WindrunnerMax/DocEditor)[Editor DEMO](https://windrunnermax.github.io/DocEditor/)
[GitHub](https://github.com/WindrunnerMax/DocEditor)[Editor DEMO](https://windrunnermax.github.io/DocEditor/)

富文本编辑器是一种可内嵌于浏览器,所见即所得的文本编辑器。现在有很多开箱即用的富文本编辑器,例如`UEditor``WangEditor`等,他们的可定制性差一些,但是胜在开箱即用,可以短时间就见到效果。而类似于`Draft.js``Slate.js`,他们是富文本编辑器的`core`或者叫做`controller`,并不是一个完整的功能,这样就能够让我们有非常高的可定制性,当然也就会造成开发所需要的时间比较多。在实际应用或技术选型的时候,还是要多做一些调研,因为在业务上框架没有绝对的优势与劣势,只有合适不合适。

Expand Down

0 comments on commit 3b4cda2

Please sign in to comment.