mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-17 16:20:05 +08:00
🐛 fix asciinema ssr failed
This commit is contained in:
parent
60ccdf8a7a
commit
c7883863c7
@ -15,7 +15,7 @@ options:
|
||||
:::
|
||||
|
||||
:::tip 提示
|
||||
如何**安装**驱动器请参考 [安装驱动器](../start/install-driver.md)
|
||||
如何**安装**驱动器请参考 [安装驱动器](../start/install-driver.mdx)
|
||||
|
||||
如何**使用**驱动器请参考 [配置](./configuration.md#driver)
|
||||
:::
|
||||
|
@ -15,7 +15,7 @@ description: 插件入门
|
||||
|
||||
### 模块插件(单文件形式)
|
||||
|
||||
在合适的路径创建一个 `.py` 文件即可。例如在 [创建项目](../create-project.md) 中创建的项目中,我们可以在 `awesome_bot/plugins/` 目录中创建一个文件 `foo.py`。
|
||||
在合适的路径创建一个 `.py` 文件即可。例如在 [创建项目](../create-project.mdx) 中创建的项目中,我们可以在 `awesome_bot/plugins/` 目录中创建一个文件 `foo.py`。
|
||||
|
||||
```tree title=Project {4}
|
||||
📦 AweSome-Bot
|
||||
@ -37,7 +37,7 @@ description: 插件入门
|
||||
|
||||
### 包插件(文件夹形式)
|
||||
|
||||
在合适的路径创建一个文件夹,并在文件夹内创建文件 `__init__.py` 即可。例如在 [创建项目](../create-project.md) 中创建的项目中,我们可以在 `awesome_bot/plugins/` 目录中创建一个文件夹 `foo`,并在这个文件夹内创建一个文件 `__init__.py`。
|
||||
在合适的路径创建一个文件夹,并在文件夹内创建文件 `__init__.py` 即可。例如在 [创建项目](../create-project.mdx) 中创建的项目中,我们可以在 `awesome_bot/plugins/` 目录中创建一个文件夹 `foo`,并在这个文件夹内创建一个文件 `__init__.py`。
|
||||
|
||||
```tree title=Project {4,5}
|
||||
📦 AweSome-Bot
|
||||
|
@ -14,7 +14,7 @@ options:
|
||||
请勿在插件被加载前 `import` 插件模块,这会导致 NoneBot 无法将其转换为插件而损失部分功能。
|
||||
:::
|
||||
|
||||
加载插件通常在机器人的入口文件进行,例如在 [创建项目](../create-project.md) 中创建的项目中的 `bot.py` 文件。在 NoneBot 初始化完成后即可加载插件。
|
||||
加载插件通常在机器人的入口文件进行,例如在 [创建项目](../create-project.mdx) 中创建的项目中的 `bot.py` 文件。在 NoneBot 初始化完成后即可加载插件。
|
||||
|
||||
```python title=bot.py {5}
|
||||
import nonebot
|
||||
|
@ -11,7 +11,7 @@ options:
|
||||
# 使用适配器
|
||||
|
||||
:::tip 提示
|
||||
如何**安装**协议适配器请参考 [安装协议适配器](../start/install-adapter.md)
|
||||
如何**安装**协议适配器请参考 [安装协议适配器](../start/install-adapter.mdx)
|
||||
:::
|
||||
|
||||
## 协议适配器的功能
|
||||
|
35
website/src/components/Asciinema/container.tsx
Normal file
35
website/src/components/Asciinema/container.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
import * as AsciinemaPlayer from "asciinema-player";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
|
||||
export type AsciinemaOptions = {
|
||||
cols: number;
|
||||
rows: number;
|
||||
autoPlay: boolean;
|
||||
preload: boolean;
|
||||
loop: boolean;
|
||||
startAt: number | string;
|
||||
speed: number;
|
||||
idleTimeLimit: number;
|
||||
theme: string;
|
||||
poster: string;
|
||||
fit: string;
|
||||
fontSize: string;
|
||||
};
|
||||
|
||||
export type AsciinemaProps = {
|
||||
url: string;
|
||||
options?: Partial<AsciinemaOptions>;
|
||||
};
|
||||
|
||||
export default function AsciinemaContainer({
|
||||
url,
|
||||
options = {},
|
||||
}: AsciinemaProps): JSX.Element {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
AsciinemaPlayer.create(url, ref.current, options);
|
||||
}, []);
|
||||
|
||||
return <div ref={ref} className="not-prose w-full max-w-full my-4"></div>;
|
||||
}
|
@ -2,38 +2,17 @@ import "asciinema-player/dist/bundle/asciinema-player.css";
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
import * as AsciinemaPlayer from "asciinema-player";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import React from "react";
|
||||
|
||||
export type AsciinemaOptions = {
|
||||
cols: number;
|
||||
rows: number;
|
||||
autoPlay: boolean;
|
||||
preload: boolean;
|
||||
loop: boolean;
|
||||
startAt: number | string;
|
||||
speed: number;
|
||||
idleTimeLimit: number;
|
||||
theme: string;
|
||||
poster: string;
|
||||
fit: string;
|
||||
fontSize: string;
|
||||
};
|
||||
import BrowserOnly from "@docusaurus/BrowserOnly";
|
||||
|
||||
export type AsciinemaProps = {
|
||||
url: string;
|
||||
options?: Partial<AsciinemaOptions>;
|
||||
};
|
||||
|
||||
export default function Asciinema({
|
||||
url,
|
||||
options = {},
|
||||
}: AsciinemaProps): JSX.Element {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
AsciinemaPlayer.create(url, ref.current, options);
|
||||
}, []);
|
||||
|
||||
return <div ref={ref} className="not-prose w-full max-w-full my-4"></div>;
|
||||
export default function Asciinema(props): JSX.Element {
|
||||
return (
|
||||
<BrowserOnly fallback={<div></div>}>
|
||||
{() => {
|
||||
const AsciinemaContainer = require("./container.tsx").default;
|
||||
return <AsciinemaContainer {...props} />;
|
||||
}}
|
||||
</BrowserOnly>
|
||||
);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import copy from "copy-to-clipboard";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import Link from "@docusaurus/Link";
|
||||
import type { IconName } from "@fortawesome/fontawesome-common-types";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
import type { Obj } from "../../libs/store";
|
||||
|
Loading…
x
Reference in New Issue
Block a user