diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index 4ce3d97..26c0d3a 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -383,23 +383,6 @@ class Post extends Common return View::fetch(); } - /** - * 输出管理列表页 - */ - public function postOutputList($id) - { - $model_post = ModelPost::find($id); - if (empty($model_post)) { - $this->error('文章不存在'); - } - $output_list = \app\model\PostOutput::where('post_id', $id) - ->order('id', 'desc') - ->paginate(10); - View::assign('post', $model_post); - View::assign('list', $output_list); - return View::fetch('post_output/index'); - } - /** * 保存输出记录 */ @@ -468,96 +451,6 @@ class Post extends Common } } - /** - * 加载历史记录配置 - */ - public function loadPostOutputConfig() - { - $id = $this->request->param('id', 0); - if (empty($id)) { - return json(['code' => 500, 'msg' => '缺少ID']); - } - - $output = \app\model\PostOutput::find((int) $id); - if (empty($output)) { - return json(['code' => 500, 'msg' => '记录不存在']); - } - - $config = (array) $output->config; - - return json([ - 'code' => 0, - 'msg' => '', - 'data' => [ - 'config' => $config, - 'content_html' => $config['content_html'] ?? '', - 'output_id' => $output->id, - ], - ]); - } - - /** - * 获取输出记录列表(JSON) - */ - public function getOutputListJson() - { - $id = $this->request->param('id', 0); - $list = \app\model\PostOutput::where('post_id', $id) - ->where('output_type', 'phone_image') - ->order('id', 'desc') - ->limit(20) - ->select(); - - $result = []; - foreach ($list as $item) { - $result[] = [ - 'id' => $item->id, - 'status' => $item->status, - 'page_count' => $item->page_count, - 'create_time' => $item->create_time, - ]; - } - - return json(['code' => 0, 'data' => $result]); - } - - /** - * 删除输出记录 - */ - public function deletePostOutput() - { - $id = $this->request->param('id', 0); - if (empty($id)) { - return json(['code' => 500, 'msg' => '缺少ID']); - } - - $phoneImage = new \app\common\tools\PhoneImage(); - $phoneImage->deleteOutput((int) $id); - - return json(['code' => 0, 'msg' => '删除成功']); - } - - /** - * 重新生成(用相同配置) - */ - public function regeneratePostOutput() - { - $id = $this->request->param('id', 0); - if (empty($id)) { - return json(['code' => 500, 'msg' => '缺少ID']); - } - - $output = \app\model\PostOutput::find($id); - if (empty($output)) { - return json(['code' => 500, 'msg' => '输出记录不存在']); - } - - $phoneImage = new \app\common\tools\PhoneImage(); - $phoneImage->deleteOutput((int) $id); - - return json(['code' => 0, 'msg' => '请重新排版', 'data' => ['config' => $output->config]]); - } - /** * 下载ZIP */ @@ -641,40 +534,6 @@ class Post extends Common return View::fetch('post/output_view'); } - /** - * 获取输出文件列表(AJAX) - */ - public function getOutputFiles() - { - $outputId = $this->request->param('output_id', 0); - - if (empty($outputId)) { - return json(['code' => 500, 'msg' => '缺少输出ID']); - } - - $output = \app\model\PostOutput::find((int) $outputId); - if (empty($output)) { - return json(['code' => 500, 'msg' => '输出记录不存在']); - } - - $files = \app\model\PostOutputFile::getByOutput((int) $outputId); - - $result = []; - foreach ($files as $file) { - $result[] = [ - 'id' => $file->id, - 'page' => $file->page, - 'file_url' => $file->file_url, - 'file_size' => $file->file_size, - 'width' => $file->width, - 'height' => $file->height, - 'image_data' => $file->image_data ?: null, - ]; - } - - return json(['code' => 0, 'data' => $result]); - } - /** * AI智能排版推荐. */ diff --git a/app/common/tools/PhoneImage.php b/app/common/tools/PhoneImage.php index 621f077..06f31d8 100644 --- a/app/common/tools/PhoneImage.php +++ b/app/common/tools/PhoneImage.php @@ -250,6 +250,22 @@ class PhoneImage implements PostOutputManagerInterface */ public function createOutput(int $postId, array $config, int $adminId): PostOutput { + $existing = PostOutput::where('post_id', $postId) + ->where('output_type', 'phone_image') + ->where('delete_time', 0) + ->find(); + + if ($existing) { + PostOutputFile::where('output_id', $existing->id)->delete(); + $existing->config = $config; + $existing->status = PostOutput::STATUS_PROCESSING; + $existing->page_count = 0; + $existing->admin_id = $adminId; + $existing->save(); + + return $existing; + } + return PostOutput::create([ 'post_id' => $postId, 'output_type' => 'phone_image', @@ -280,6 +296,20 @@ class PhoneImage implements PostOutputManagerInterface */ public static function saveConfigOnly(int $postId, array $config, int $adminId): PostOutput { + $existing = PostOutput::where('post_id', $postId) + ->where('output_type', 'phone_image') + ->where('delete_time', 0) + ->find(); + + if ($existing) { + $existing->config = $config; + $existing->content_html = $config['content_html'] ?? $existing->content_html; + $existing->admin_id = $adminId; + $existing->save(); + + return $existing; + } + return PostOutput::create([ 'post_id' => $postId, 'output_type' => 'phone_image', diff --git a/view/admin/post/post_output/index.html b/view/admin/post/post_output/index.html deleted file mode 100644 index d64ecac..0000000 --- a/view/admin/post/post_output/index.html +++ /dev/null @@ -1,175 +0,0 @@ - - - -
- - - -| ID | -类型 | -尺寸 | -页数 | -状态 | -创建时间 | -图片 | -操作 | -
|---|---|---|---|---|---|---|---|
| {$vo.id} | -{$vo.output_type_text} | -- {if $vo.config && $vo.config.size} - {if $vo.config.size == 'xiaohongshu'}小红书{/if} - {if $vo.config.size == 'douyin'}抖音{/if} - {else/} - - - {/if} - | -{$vo.page_count} | -{$vo.status_text} | -{$vo.create_time} | -- - | -
-
-
- 下载ZIP
-
-
-
- |
-
| 暂无输出记录,点击"新建排版"创建 | -|||||||