File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ class PasteShowHandler extends Handler {
166166// Hydro会在服务初始化完成后调用该函数。
167167export async function apply() {
168168 // 注册一个名为 paste_create 的路由,匹配 '/paste/create',
169- // 使用PasteCreateHandler处理,访问改路由需要PRIV.PRIV_USER_PROFILE权限
169+ // 使用 PasteCreateHandler 处理,访问该路由需要 PRIV.PRIV_USER_PROFILE 权限
170170 // 提示:路由匹配基于 path-to-regexp
171171 ctx .Route (' paste_create' , ' /paste/create' , PasteCreateHandler , PRIV .PRIV_USER_PROFILE );
172172 ctx .Route (' paste_show' , ' /paste/show/:id' , PasteShowHandler );
@@ -183,3 +183,21 @@ export async function apply() {
183183## Step5 locale
184184
185185用于提供多国翻译。格式与 Hydro 的 locale 文件夹格式相同。
186+
187+ ## Step6 frontend
188+
189+ 在 frontend 文件夹下编写前端代码。命名符合 ` [a-zA-Z0-9_]+.page.tsx? ` 的文件会被自动作为入口点加载。
190+ paste 功能并不需要在前端有任何额外 js 驱动的交互,因此下方给出一个最基础的格式示例。
191+
192+ ``` tsx
193+ import ' ./foo.css' ; // 如果有额外的样式
194+ import { addPage , NamedPage , AutoloadPage } from ' @hydrooj/ui-default' ;
195+
196+ addPage (new NamedPage ([' problem_detail' ], () => {
197+ console .log (' 仅在题目详情页面执行' );
198+ }));
199+
200+ addPage (new AutoloadPage (' my_page_name' , () => {
201+ console .log (' 在所有页面均会执行' );
202+ }));
203+ ```
You can’t perform that action at this time.
0 commit comments