@hyxf/cover-editor 0.0.0-stage → 0.0.10
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 +69 -2
- package/bin/ximage.js +15 -0
- package/dist/assets/index-227Gs3cf.js +515 -0
- package/dist/assets/index-BVq-pIyA.css +1 -0
- package/dist/fonts/DouyinSansBold.otf +0 -0
- package/dist/icons/18.svg +9 -0
- package/dist/icons/18a.svg +12 -0
- package/dist/icons/18c.svg +11 -0
- package/dist/icons/18d.svg +11 -0
- package/dist/index.html +17 -0
- package/package.json +59 -3
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cover Editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
基于 React、TypeScript、Vite 和 Fabric.js 的电子书封面编辑器。可在浏览器中创建封面、排版文字和装饰元素,并导出 PNG 图片。
|
|
4
|
+
|
|
5
|
+
[项目主页与源码](https://github.com/hyxf/image-editor) · MIT License
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
- 设置画布尺寸:使用常见宽高比、设备分辨率或自定义尺寸。
|
|
10
|
+
- 设置背景:选择纯色或渐变,上传背景图并按画布比例裁剪。
|
|
11
|
+
- 编辑元素:添加标题、作者文字、矩形、图片、贴图和智能徽章。
|
|
12
|
+
- 调整文字样式:编辑内容、方向、字体、字号、字距、颜色和描边。
|
|
13
|
+
- 拖动调整左侧编辑栏宽度;锁定、删除元素并调整图层顺序。
|
|
14
|
+
- 导出为 2 倍分辨率 PNG。
|
|
15
|
+
|
|
16
|
+
## 安装并运行
|
|
17
|
+
|
|
18
|
+
### 作为命令行工具使用
|
|
19
|
+
|
|
20
|
+
需要 Node.js 22.0.0 或更高版本:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install --global @hyxf/cover-editor
|
|
24
|
+
ximage
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
命令会启动本地服务(默认端口 `3002`);按终端提示在浏览器中打开编辑器。
|
|
28
|
+
|
|
29
|
+
### 本地开发
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/hyxf/image-editor.git
|
|
33
|
+
cd image-editor
|
|
34
|
+
pnpm install
|
|
35
|
+
pnpm dev
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Vite 会在终端显示本地开发地址。生产构建与检查命令:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm build # 类型检查并生成 dist/ 生产构建
|
|
42
|
+
pnpm preview # 本地预览生产构建
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 基本使用
|
|
46
|
+
|
|
47
|
+
1. 在“画布与背景”中选择比例、设备预设或输入自定义尺寸。
|
|
48
|
+
2. 设置纯色、渐变背景,或上传背景图。双击背景图可打开裁剪界面。
|
|
49
|
+
3. 从“添加元素”插入文字、形状、图片或贴图;选中元素后在属性编辑区修改样式。
|
|
50
|
+
4. 拖动元素调整位置;使用侧栏操作锁定、置顶、置底或删除元素。
|
|
51
|
+
5. 点击“下载封面”导出 PNG。
|
|
52
|
+
|
|
53
|
+
## 配置
|
|
54
|
+
|
|
55
|
+
画布预设、颜色、字体和贴图路径集中在 `src/config.ts`。添加自定义字体时,将字体文件放入 `public/fonts/`,并在字体配置中填写名称、标识和以 `/fonts/` 开头的路径。贴图资源可放在 `public/icons/`,并添加到贴图列表。
|
|
56
|
+
|
|
57
|
+
## 开发说明
|
|
58
|
+
|
|
59
|
+
应用界面位于 `src/components/`,画布状态和 Fabric.js 操作位于 `src/hooks/useCanvasStore/`。提交前运行 `pnpm build`。目前仓库未配置自动化测试。
|
|
60
|
+
|
|
61
|
+
## 发布
|
|
62
|
+
|
|
63
|
+
发布新版本前更新版本号并推送提交和标签,然后发布 npm 包:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm version patch
|
|
67
|
+
git push
|
|
68
|
+
git push --tags
|
|
69
|
+
npm publish --access public
|
|
70
|
+
```
|
package/bin/ximage.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { startServer } from '@hyxf/xbin'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
/* =========================
|
|
7
|
+
* Application
|
|
8
|
+
* ========================= */
|
|
9
|
+
|
|
10
|
+
startServer({
|
|
11
|
+
name: 'ximage',
|
|
12
|
+
description: 'image editor',
|
|
13
|
+
defaultPort: 3002,
|
|
14
|
+
distDir: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../dist')
|
|
15
|
+
})
|