feat: 添加Vditor编辑器支持并扩展文件上传功能

- 新增Vditor编辑器静态资源文件,包括图片、字体和样式文件
- 在文件上传控制器中添加vditorSave方法,支持Vditor编辑器文件上传
- 在文章创建页面添加编辑器类型选择(富文本/Markdown)
- 更新.gitignore文件,排除Playwright和QA截图目录
- 扩展UploadFiles类以支持Vditor编辑器的文件上传格式
This commit is contained in:
augushong
2026-04-30 22:27:03 +08:00
parent cbf9b21b96
commit aed4b285d8
421 changed files with 24125 additions and 1 deletions

View File

@@ -8,6 +8,10 @@ use app\model\Nav;
use app\model\Post as ModelPost;
use app\model\PostCategory;
use app\model\PostTag;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Table\TableExtension;
use League\CommonMark\MarkdownConverter;
use League\HTMLToMarkdown\HtmlConverter;
use think\facade\Cache;
use think\facade\View;
@@ -188,6 +192,10 @@ class Post extends Common
View::assign('post', $model_post);
if ($model_post->content_type === 'markdown') {
return View::fetch('edit_content_markdown');
}
return View::fetch();
}
@@ -223,6 +231,9 @@ class Post extends Common
//
$post_data = $request->post();
// 禁止修改 content_type
unset($post_data['content_type']);
$model_post = ModelPost::find($id);
$categorys = [];
@@ -274,6 +285,14 @@ class Post extends Common
}
}
// Markdown->HTML 自动转换
if ($model_post->getData('content_type') === 'markdown' && isset($post_data['content'])) {
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new TableExtension());
$converter = new MarkdownConverter($environment);
$post_data['content_html'] = $converter->convert($post_data['content'])->getContent();
}
$model_post->save($post_data);
Cache::delete('sitemap_last_etag');