签入版本

This commit is contained in:
2026-10-11 19:06:33 +08:00
parent 17d28de8b7
commit 4084c6bd17
674 changed files with 58855 additions and 1892 deletions
@@ -113,9 +113,9 @@ php artisan db:migrate [选项]
# --drop-target-first → 迁移前先删除目标库中的同名表(避免表已存在报错)
php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=pgsql --dst-host=127.0.0.1 --dst-port=5432 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=postgres --dst-password=123456 \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=postgres --dst-password=123456 \
--drop-target-first
```
@@ -129,9 +129,9 @@ php artisan db:migrate \
# --dst-port=1433 → SQL Server 默认端口
php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=sqlsrv --dst-host=127.0.0.1 --dst-port=1433 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=sa --dst-password=123456 \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=sa --dst-password=123456 \
--drop-target-first
```
@@ -145,8 +145,8 @@ php artisan db:migrate \
# --dst-database → SQLite 文件路径(文件不存在时自动创建)
php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--dst-type=sqlite --dst-database=database/rxthinkcmf.laravel13.elevue.db
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=sqlite --dst-database=database/rxthinkcmf.laravel13.antdvue.db
```
### MySQL → Oracle
@@ -158,9 +158,9 @@ php artisan db:migrate \
# --dst-type=oracle → 目标驱动为 Oracle(自动建用户 + 序列 + 触发器)
php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=oracle --dst-host=127.0.0.1 --dst-port=1521 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=system --dst-password=123456 \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=system --dst-password=123456 \
--drop-target-first
```
@@ -186,9 +186,9 @@ php artisan db:migrate \
# -----------------------------------------------------------------------------
php artisan db:migrate \
--src-type=pgsql --src-host=127.0.0.1 --src-port=5432 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=postgres --src-password=123456 \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=postgres --src-password=123456 \
--dst-type=mysql --dst-host=127.0.0.1 --dst-port=3306 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=root --dst-password=root \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=root --dst-password=root \
--drop-target-first
```
@@ -200,9 +200,9 @@ php artisan db:migrate \
# -----------------------------------------------------------------------------
php artisan db:migrate \
--src-type=sqlsrv --src-host=127.0.0.1 --src-port=1433 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=sa --src-password=123456 \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=sa --src-password=123456 \
--dst-type=mysql --dst-host=127.0.0.1 --dst-port=3306 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=root --dst-password=root \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=root --dst-password=root \
--drop-target-first
```
@@ -215,9 +215,9 @@ php artisan db:migrate \
# --tables=laravel_user,laravel_role,laravel_menu → 只迁移这 3 张表
php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=pgsql --dst-host=127.0.0.1 --dst-port=5432 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=postgres --dst-password=123456 \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=postgres --dst-password=123456 \
--tables=laravel_user,laravel_role,laravel_menu \
--drop-target-first
```
@@ -229,17 +229,17 @@ php artisan db:migrate \
```bash
$ php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=pgsql --dst-host=127.0.0.1 --dst-port=5432 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=postgres --dst-password=123456 \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=postgres --dst-password=123456 \
--drop-target-first
==============================================================
[迁移开始] 源: mysql:rxthinkcmf.laravel13.elevue → 目标: pgsql:rxthinkcmf.laravel13.elevue
[迁移开始] 源: mysql:rxthinkcmf.laravel13.antdvue → 目标: pgsql:rxthinkcmf.laravel13.antdvue
[迁移开始] 待迁移 25 张表
==============================================================
[·] [1/5] 建目标库...
· 目标库 "rxthinkcmf.laravel13.elevue" 已就绪
· 目标库 "rxthinkcmf.laravel13.antdvue" 已就绪
[✓] [1/5] 建目标库 完成(耗时 0ms)
[·] [2/5] 建表结构(25 张表)...
[✓] [2/5] 建表结构 完成(耗时 440ms),25 张表,118 个索引,0 个外键
@@ -271,13 +271,13 @@ $ php artisan db:migrate \
```bash
$ php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=oracle --dst-host=127.0.0.1 --dst-port=1521 \
--dst-database=rxthinkcmf --dst-username=system --dst-password=123456 \
--drop-target-first
==============================================================
[迁移开始] 源: mysql:rxthinkcmf.laravel13.elevue → 目标: oracle:rxthinkcmf.laravel13.elevue
[迁移开始] 源: mysql:rxthinkcmf.laravel13.antdvue → 目标: oracle:rxthinkcmf.laravel13.antdvue
==============================================================
[·] [1/5] 建目标库...
· 目标库 "rxthinkcmf" 已就绪(CREATE USER + GRANT)
@@ -314,9 +314,9 @@ $ php artisan db:migrate \
```bash
$ php artisan db:migrate \
--src-type=mysql --src-host=127.0.0.1 --src-port=3306 \
--src-database=rxthinkcmf.laravel13.elevue --src-username=root --src-password=root \
--src-database=rxthinkcmf.laravel13.antdvue --src-username=root --src-password=root \
--dst-type=pgsql --dst-host=127.0.0.1 --dst-port=5432 \
--dst-database=rxthinkcmf.laravel13.elevue --dst-username=postgres --dst-password=123456 \
--dst-database=rxthinkcmf.laravel13.antdvue --dst-username=postgres --dst-password=123456 \
--tables=laravel_user,laravel_role,laravel_menu \
--drop-target-first
@@ -693,7 +693,7 @@ $PHP_HOME\php.exe -m | findstr sqlite
5. `--drop-target-first` 会删除目标表的全部数据(含索引、外键和注释),请谨慎使用
6. 大表迁移建议调大 `--batch-size`(如 5000)以提高效率
7. 迁移过程中如遇中断,已提交的 `--batch-size` 批次数据不会回滚,建议使用 `--drop-target-first` 重试
8. 含点号的数据库名(如 `rxthinkcmf.laravel13.elevue`)各驱动均已适配
8. 含点号的数据库名(如 `rxthinkcmf.laravel13.antdvue`)各驱动均已适配
9. 索引、外键和注释在建表阶段同步迁移,使用 `--drop-target-first` 重建时会一并重建
10. 外键约束在所有表创建后统一添加,避免引用顺序问题
11. 命令退出码:成功返回 0,失败或行数校验未通过返回 1(可用于 CI/CD 判断)
@@ -721,7 +721,7 @@ A: 调大 `--batch-size`,如 `--batch-size=5000`。默认 1000 行一批,增
A: 会。所有驱动(MySQL / PostgreSQL / SQL Server / Oracle / SQLite)在目标库不存在时都会自动创建,无需手动建库。建库时会自动从源库读取 collation 并应用(仅当源与目标驱动相同时)。
PostgreSQL 走维护库 `postgres` 执行 `CREATE DATABASE`,含点号的库名会自动加双引号(如 `"rxthinkcmf.laravel13.elevue"`);建库失败时抛出 `创建目标数据库失败: …` 并把原始异常保留在 previous 中。
PostgreSQL 走维护库 `postgres` 执行 `CREATE DATABASE`,含点号的库名会自动加双引号(如 `"rxthinkcmf.laravel13.antdvue"`);建库失败时抛出 `创建目标数据库失败: …` 并把原始异常保留在 previous 中。
### Q: 报 `could not find driver` 怎么办?
@@ -763,7 +763,7 @@ A: Oracle 没有原生自增语法。迁移工具会自动为自增列创建序
### Q: 含点号的数据库名支持吗?
A: 支持。如 `rxthinkcmf.laravel13.elevue` 这类含点号的库名,各驱动均已适配。
A: 支持。如 `rxthinkcmf.laravel13.antdvue` 这类含点号的库名,各驱动均已适配。
### Q: SQLite 作为目标有什么限制?
+20 -14
View File
@@ -195,7 +195,7 @@ public function export(): JsonResponse
"code": 0,
"ok": true,
"msg": "导出成功",
"data": "http://file.laravel13.elevue/temp/20261006/用户数据_20261006050143.xlsx"
"data": "http://file.laravel13.antdvue/temp/20261006/用户数据_20261006050143.xlsx"
}
```
@@ -328,27 +328,33 @@ public function export(array $params = []): string
```vue
<template>
<el-upload
<a-upload
:action="'/api/example/import'"
:headers="{ Authorization: `Bearer ${token}` }"
:on-success="handleImportSuccess"
:show-upload-list="false"
accept=".xls,.xlsx"
@change="handleChange"
>
<el-button type="primary">导入</el-button>
</el-upload>
<a-button type="primary">导入</a-button>
</a-upload>
</template>
<script setup>
const handleImportSuccess = (response) => {
if (response.code === 0) {
const { count, errors } = response.data;
if (errors.length === 0) {
ElMessage.success(`成功导入 ${count} 条数据`);
} else {
ElMessage.warning(`成功 ${count} 条,失败 ${errors.length} 条`);
// 可展开 errors 查看行号与原因
import { message } from 'ant-design-vue';
const handleChange = ({ file }) => {
if (file.status === 'done') {
const response = file.response;
if (response.code === 0) {
const { count, errors } = response.data;
if (errors.length === 0) {
message.success(`成功导入 ${count} 条数据`);
} else {
message.warning(`成功 ${count} 条,失败 ${errors.length} 条`);
// 可展开 errors 查看行号与原因
}
refreshTable();
}
refreshTable();
}
};
</script>
@@ -1,7 +1,7 @@
# 7.5 前端文件组件
:::tip 概述
本节介绍前端项目(独立 EleVue 仓库)中的文件处理组件,包括上传组件(BasicUpload)、富文本编辑器(Editor)与 Excel 导入导出组件的使用方法。组件封装了 [7.1 文件上传全流程](/zh/tools/upload.html) 的接口调用。
本节介绍前端项目(独立 AntdVue 仓库)中的文件处理组件,包括上传组件(BasicUpload)、富文本编辑器(Editor)与 Excel 导入导出组件的使用方法。组件封装了 [7.1 文件上传全流程](/zh/tools/upload.html) 的接口调用。
:::
## Upload 上传组件
@@ -72,7 +72,7 @@ const handleImportSuccess = (data) => {
```
:::tip 前端解析 vs 后端导入
- **后端导入(推荐,走业务校验)**:`el-upload` 直传 `/api/{module}/import`,由 Service 逐行 `add()`(字典反查、唯一校验、事务),见 [7.4 数据导入导出](/zh/tools/excel.html);
- **后端导入(推荐,走业务校验)**:`a-upload` 直传 `/api/{module}/import`,由 Service 逐行 `add()`(字典反查、唯一校验、事务),见 [7.4 数据导入导出](/zh/tools/excel.html);
- **前端解析**:`ImportExcel` 组件用 `xlsx` 库本地解析为数组,适合导入前预览、无业务校验的场景。
:::
@@ -83,7 +83,7 @@ FILE_DOMAIN_URL=https://cdn.example.com
| 环境 | 域名示例 |
|------|---------|
| 本地开发 | (留空,使用相对路径) |
| 虚拟域名开发 | `http://file.laravel13.elevue` |
| 虚拟域名开发 | `http://file.laravel13.antdvue` |
| 测试环境 | `https://test-cdn.example.com` |
| 生产环境 | `https://cdn.example.com` 或对象存储域名 |
@@ -247,35 +247,40 @@ function save_remote_file(string $url, string $saveDir = ''): string|false
## 前端集成
### Element Plus 上传组件
### AntDesign 上传组件
```vue
<template>
<el-upload
<a-upload
:action="'/api/upload/uploadFile'"
:data="{ type: 'image' }"
:headers="{ Authorization: `Bearer ${token}` }"
:on-success="handleUploadSuccess"
:before-upload="beforeUpload"
:show-upload-list="false"
@change="handleUploadChange"
>
<el-button type="primary">上传图片</el-button>
</el-upload>
<a-button type="primary">上传图片</a-button>
</a-upload>
</template>
<script setup>
import { message } from 'ant-design-vue';
const token = localStorage.getItem('access_token');
const beforeUpload = (file) => {
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
ElMessage.error('文件大小不能超过 10MB');
message.error('文件大小不能超过 10MB');
}
return isLt10M;
};
const handleUploadSuccess = (response) => {
// 提交表单时保存相对路径(filePath)最稳妥
form.value.avatar = response.data.filePath;
const handleUploadChange = ({ file }) => {
if (file.status === 'done' && file.response.code === 0) {
// 提交表单时保存相对路径(filePath)最稳妥
form.value.avatar = file.response.data.filePath;
}
};
</script>
```