@web-mods/articles 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/components/ArticleNavigationSettings.d.ts +9 -0
- package/dist/components/ValidationIssues.d.ts +5 -0
- package/dist/components/ui/Tooltip.d.ts +3 -1
- package/dist/index.cjs +67 -31
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1712 -1177
- package/dist/server.cjs +3 -3
- package/dist/server.d.ts +3 -2
- package/dist/server.js +80 -42
- package/dist/service.d.ts +9 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +25 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -8,6 +8,26 @@
|
|
|
8
8
|
pnpm add @web-mods/articles
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## 导航设置
|
|
12
|
+
|
|
13
|
+
文章保存时提交 `navEnabled`、`navname`、`navPlacements`,编辑时回显接口配置。启用导航需填写名称并选择至少一个展示位置,网站地址必填。
|
|
14
|
+
|
|
15
|
+
父导航从 `GET /navigation/groups?host=...&position=...` 读取,通过 `POST /navigation/groups` 创建并选中真实 ID,不提供前端示例选项。切换网站地址会清空父导航选择并重新加载;关闭导航会保留名称和位置。页眉暂时仅支持顶级导航,已有父导航只读保留;页尾可选父导航。
|
|
16
|
+
|
|
17
|
+
自定义 `ArticleService` 可实现 `getNavigationGroups`、`createNavigationGroup`;未实现查询方法时禁用导航编辑,文章保存省略导航字段,兼容旧宿主。
|
|
18
|
+
|
|
19
|
+
写操作需要 Bearer Token。默认 service 每次请求会读取当前页面的 `localStorage.accessToken`,并加入 `Authorization: Bearer ...`。自定义 service 可复用宿主凭证:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const articleService = createArticleService('https://api-blog.aisee.live', {
|
|
23
|
+
headers: () => ({ Authorization: `Bearer ${getAccessToken()}` }),
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
本地调试运行 `pnpm dev`(或 `pnpm playground`),访问 `http://localhost:5173/articles`。页面使用默认 service,直接请求 `src/service.ts` 中配置的 `https://api-blog.aisee.live`。仅监听组件库构建请运行 `pnpm build:watch`。
|
|
28
|
+
|
|
29
|
+
接口约定见 [技术交接文档](docs/article-navigation-implementation.md)。
|
|
30
|
+
|
|
11
31
|
> **Peer dependencies**:`react >=18`、`react-dom >=18`
|
|
12
32
|
>
|
|
13
33
|
> `react-router` 仅在 **react-router 环境**下需要(见下方适配说明)。`dayjs`、`lucide-react`、`@monaco-editor/react` 均已打包在内,无需单独安装。
|
|
@@ -76,6 +96,8 @@ export default [
|
|
|
76
96
|
|
|
77
97
|
用 `ReactRouterAdapter` 桥接路由,这是唯一需要 `react-router` 的地方:
|
|
78
98
|
|
|
99
|
+
适配器应放在 `ArticlesProvider` 内,可包裹 `<Outlet />` 或整个 `<Routes>`。编辑和详情页的文章 ID 会从当前 URL 匹配,因此刷新或直接访问也能正常加载,不依赖跳转时的 `state`。
|
|
100
|
+
|
|
79
101
|
```tsx
|
|
80
102
|
// pages/articles/layout.tsx
|
|
81
103
|
import { Outlet } from 'react-router'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ArticleNavigation, ArticleService } from "../types";
|
|
2
|
+
interface ArticleNavigationSettingsProps {
|
|
3
|
+
host: string;
|
|
4
|
+
service: ArticleService;
|
|
5
|
+
value: ArticleNavigation;
|
|
6
|
+
onChange: (value: ArticleNavigation) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function ArticleNavigationSettings({ host, service, value, onChange }: ArticleNavigationSettingsProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -3,6 +3,8 @@ interface TooltipProps {
|
|
|
3
3
|
title: ReactNode;
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
placement?: 'top' | 'bottom';
|
|
6
|
+
align?: 'center' | 'end';
|
|
7
|
+
variant?: 'default' | 'card';
|
|
6
8
|
}
|
|
7
|
-
export declare function Tooltip({ title, children, placement }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function Tooltip({ title, children, placement, align, variant }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export {};
|