Files
kotonoha/README.md
T
2026-07-29 21:56:50 +08:00

132 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 言の葉写字板
一个用于歌词/日语文本抄写、假名标注和注释管理的写字板。
## 本地开发
```bash
npm install
npm run dev
```
本地开发地址默认是:
```text
http://localhost:3001/
```
开发模式下,`vite.config.ts` 会提供本地 `/api/saves`,文档保存在项目根目录的 `saves/`
## 生产运行
生产环境使用独立 Express 服务:
```bash
npm install
npm run build
npm run start
```
默认监听:
```text
http://0.0.0.0:3002
```
可用环境变量:
```bash
PORT=3002
HOST=0.0.0.0
SAVES_DIR=/opt/kotonoha/data/saves
```
生产服务会:
- 提供 `/api/saves` 文档保存 API
- 读写 `SAVES_DIR` 指向的 JSON 文档目录
- 静态托管 `dist/` 前端文件
- 对非 `/api` 路径返回前端入口,支持刷新页面
## 1Panel 部署建议
推荐服务器目录:
```text
/opt/kotonoha
```
上传项目后执行:
```bash
cd /opt/kotonoha
npm install
npm run build
mkdir -p /opt/kotonoha/data/saves
```
Node 应用配置:
```text
项目目录:/opt/kotonoha
启动命令:npm run start
端口:3002
环境变量:
PORT=3002
HOST=0.0.0.0
SAVES_DIR=/opt/kotonoha/data/saves
```
OpenResty / 网站反向代理:
```text
/api/ -> http://127.0.0.1:3002
/ -> http://127.0.0.1:3002
```
数据备份重点:
```text
/opt/kotonoha/data/saves
```
## Android App 打包
本项目使用 Capacitor 生成 Android 工程。
Android 测试包会读取 `.env.android`
```text
VITE_API_BASE_URL=https://yiulix.tech
```
网页生产构建默认使用同源 `/api`,由 OpenResty 反向代理到 Node 服务;无需暴露 `3002` 端口。
如果 Android API 域名发生变化,修改 `.env.android`
```text
VITE_API_BASE_URL=https://your-domain.com
```
生成/同步 Android 工程:
```bash
npm install
npm run build:android
npm run cap:sync
npm run cap:open
```
然后在 Android Studio 里:
```text
Build -> Build Bundle(s) / APK(s) -> Build APK(s)
```
当前测试版使用 HTTP 访问服务器,`android/app/src/main/AndroidManifest.xml` 已开启:
```text
android:usesCleartextTraffic="true"
```
以后改成 HTTPS 后可以关闭这个配置。