正在显示
12 个修改的文件
包含
278 行增加
和
52 行删除
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Aside; | 3 | namespace App\Http\Controllers\Aside; |
| 4 | 4 | ||
| 5 | -use App\Models\Template\AHeadFoot; | 5 | +use App\Models\Template\ATemplateHtml; |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | * 模板 | 8 | * 模板 |
| @@ -22,22 +22,9 @@ class TemplateController extends BaseController | @@ -22,22 +22,9 @@ class TemplateController extends BaseController | ||
| 22 | */ | 22 | */ |
| 23 | public function index(){ | 23 | public function index(){ |
| 24 | 24 | ||
| 25 | - $data = AHeadFoot::all(); | ||
| 26 | - $lists = []; | ||
| 27 | - // 以名字为单位区分 | ||
| 28 | - foreach ($data as $datum){ | ||
| 29 | - if(empty($lists[$datum['name']])) $lists[$datum['name']] = []; | ||
| 30 | - $lists[$datum['name']]['name'] = $datum['name']; | ||
| 31 | - $lists[$datum['name']]['default'] = $datum['is_default']; | ||
| 32 | - $lists[$datum['name']]['sort'] = $datum['sort']; | ||
| 33 | - $lists[$datum['name']]['status'] = $datum['status']; | ||
| 34 | - $lists[$datum['name']]['created_at'] = $datum['created_at']; | ||
| 35 | -// $lists[$datum['name']]['tags'] = $datum['tags']; | ||
| 36 | - $lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html']; | ||
| 37 | - } | ||
| 38 | 25 | ||
| 39 | - return $this->success($lists); | ||
| 40 | 26 | ||
| 27 | + return view('a'); | ||
| 41 | } | 28 | } |
| 42 | 29 | ||
| 43 | 30 |
| @@ -26,7 +26,7 @@ class CustomController extends BaseController | @@ -26,7 +26,7 @@ class CustomController extends BaseController | ||
| 26 | 'title' => ['required','max:200'], | 26 | 'title' => ['required','max:200'], |
| 27 | 'keywords' => ['required','max:200'], | 27 | 'keywords' => ['required','max:200'], |
| 28 | 'description' => ['required','max:250'], | 28 | 'description' => ['required','max:250'], |
| 29 | - 'html' => ['required'], | 29 | +// 'html' => ['required'], |
| 30 | 'url' => ['required','max:200'], | 30 | 'url' => ['required','max:200'], |
| 31 | 'status' => ['required','in:0,1'], | 31 | 'status' => ['required','in:0,1'], |
| 32 | ], | 32 | ], |
| @@ -144,5 +144,33 @@ class CustomController extends BaseController | @@ -144,5 +144,33 @@ class CustomController extends BaseController | ||
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | 146 | ||
| 147 | + /** | ||
| 148 | + * @param $id | ||
| 149 | + * @return \Illuminate\Http\JsonResponse | ||
| 150 | + * @author:dc | ||
| 151 | + * @time 2023/5/10 14:10 | ||
| 152 | + */ | ||
| 153 | + public function html($id) | ||
| 154 | + { | ||
| 155 | + $data = BCustom::_find($this->user['project_id'],$id); | ||
| 156 | + if(!$data){ | ||
| 157 | + return $this->response('数据不存在','B_CUSTOM_NOTFOUND'); | ||
| 158 | + } | ||
| 159 | + if($this->isPost()){ | ||
| 160 | + $html = $this->param['html']??''; | ||
| 161 | + | ||
| 162 | + $data->html = $html; | ||
| 163 | + | ||
| 164 | + $data->save(); | ||
| 165 | + | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + | ||
| 169 | + return $this->response('',Code::SUCCESS,$data['html']); | ||
| 170 | + | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + | ||
| 147 | 175 | ||
| 148 | } | 176 | } |
| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside; | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside; | ||
| 5 | 5 | ||
| 6 | use App\Models\Template\ATemplate; | 6 | use App\Models\Template\ATemplate; |
| 7 | use App\Models\Template\BSetting; | 7 | use App\Models\Template\BSetting; |
| 8 | +use App\Models\Template\BTemplateData; | ||
| 8 | 9 | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| @@ -71,5 +72,49 @@ class TemplateController extends BaseController | @@ -71,5 +72,49 @@ class TemplateController extends BaseController | ||
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | 74 | ||
| 75 | + /** | ||
| 76 | + * 保存模板 | ||
| 77 | + * @author:dc | ||
| 78 | + * @time 2023/5/10 10:53 | ||
| 79 | + */ | ||
| 80 | + public function save(){ | ||
| 81 | + | ||
| 82 | + $html = '<header id="globalso-header" class="web_head sticky-top py-1 py-md-0" style="background-color: #318fff;">asdf</header>'; | ||
| 83 | + | ||
| 84 | + // 替换 header | ||
| 85 | + $html = preg_replace("/<header(.*)id=\"globalso-header\"(.*)>([\s\S]*)<\/header>/iU",'',$html); | ||
| 86 | + $html = preg_replace("/<main(.*)id=\"globalso-main\"(.*)>([\s\S]*)<\/main>/iU",'',$html); | ||
| 87 | + $html = preg_replace("/<footer(.*)id=\"globalso-footer\"(.*)>([\s\S]*)<\/footer>/iU",'',$html); | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 自定义块 | ||
| 99 | + * @author:dc | ||
| 100 | + * @time 2023/5/10 14:55 | ||
| 101 | + */ | ||
| 102 | + public function customChunk(){ | ||
| 103 | + | ||
| 104 | + $html = $this->param['html']??[]; | ||
| 105 | + if(!is_array($html)){ | ||
| 106 | + return $this->response('参数异常','B_CUSTOM_CHUNK_PARAMS'); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + | ||
| 112 | + $data = BTemplateData::_insert(); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + | ||
| 74 | 119 | ||
| 75 | } | 120 | } |
| @@ -30,10 +30,10 @@ class LoginAuthMiddleware | @@ -30,10 +30,10 @@ class LoginAuthMiddleware | ||
| 30 | return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); | 30 | return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); |
| 31 | } | 31 | } |
| 32 | // 设置数据信息 | 32 | // 设置数据信息 |
| 33 | -// $project = ProjectServer::useProject($info['project_id']); | ||
| 34 | -// if($project){ | ||
| 35 | -// return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); | ||
| 36 | -// } | 33 | + $project = ProjectServer::useProject($info['project_id']); |
| 34 | + if($project){ | ||
| 35 | + return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); | ||
| 36 | + } | ||
| 37 | //操作权限设置 | 37 | //操作权限设置 |
| 38 | $projectRoleModel = new ProjectRoleModel(); | 38 | $projectRoleModel = new ProjectRoleModel(); |
| 39 | $role_info = $projectRoleModel->read(['id'=>$info['role_id']]); | 39 | $role_info = $projectRoleModel->read(['id'=>$info['role_id']]); |
| @@ -59,7 +59,7 @@ class BCustom extends Base | @@ -59,7 +59,7 @@ class BCustom extends Base | ||
| 59 | $model->description = $data['description']; | 59 | $model->description = $data['description']; |
| 60 | $model->url = $data['url']; | 60 | $model->url = $data['url']; |
| 61 | $model->status = $data['status']; | 61 | $model->status = $data['status']; |
| 62 | - $model->html = $data['html']; | 62 | + $model->html = $data['html']??''; |
| 63 | 63 | ||
| 64 | $model->save(); | 64 | $model->save(); |
| 65 | 65 |
| @@ -81,5 +81,19 @@ class ATemplate extends \App\Models\Base{ | @@ -81,5 +81,19 @@ class ATemplate extends \App\Models\Base{ | ||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | + /** | ||
| 85 | + * 查询 | ||
| 86 | + * @param $id | ||
| 87 | + * @return mixed | ||
| 88 | + * @author:dc | ||
| 89 | + * @time 2023/5/10 10:15 | ||
| 90 | + */ | ||
| 91 | + public static function _find($id) | ||
| 92 | + { | ||
| 93 | + return static::where('id',$id)->first(); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + | ||
| 84 | 98 | ||
| 85 | } | 99 | } |
| @@ -24,6 +24,16 @@ class ATemplateHtml extends \App\Models\Base{ | @@ -24,6 +24,16 @@ class ATemplateHtml extends \App\Models\Base{ | ||
| 24 | use SoftDeletes; | 24 | use SoftDeletes; |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | + /** | ||
| 28 | + * 模板中的数据 | ||
| 29 | + * @param $template_id | ||
| 30 | + * @return mixed | ||
| 31 | + * @author:dc | ||
| 32 | + * @time 2023/5/10 10:30 | ||
| 33 | + */ | ||
| 34 | + public static function _all($template_id){ | ||
| 35 | + return static::where(['template_id'=>$template_id])->get(); | ||
| 36 | + } | ||
| 27 | 37 | ||
| 28 | 38 | ||
| 29 | } | 39 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Models\Template; | 3 | namespace App\Models\Template; |
| 4 | 4 | ||
| 5 | use Illuminate\Database\Eloquent\SoftDeletes; | 5 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 6 | +use Illuminate\Support\Facades\DB; | ||
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| 8 | * 当前用户的模板 | 9 | * 当前用户的模板 |
| @@ -71,6 +72,30 @@ class BSetting extends \App\Models\Base{ | @@ -71,6 +72,30 @@ class BSetting extends \App\Models\Base{ | ||
| 71 | 72 | ||
| 72 | $data->save(); | 73 | $data->save(); |
| 73 | 74 | ||
| 75 | + // 是否有模板 | ||
| 76 | +// if(!BTemplate::_isExist($project_id,$template_id)){ | ||
| 77 | +// // 没有模板 | ||
| 78 | +// $aData = ATemplate::_find($template_id); | ||
| 79 | +// // 保存到自己的数据中 | ||
| 80 | +// BTemplate::_insert($project_id,$aData); | ||
| 81 | +// | ||
| 82 | +// $aDataHtml = ATemplateHtml::_all($template_id); | ||
| 83 | +// DB::beginTransaction(); | ||
| 84 | +// foreach ($aDataHtml as $item){ | ||
| 85 | +// try { | ||
| 86 | +// // 插入子数据 | ||
| 87 | +// BTemplateHtml::_insert($project_id,$item); | ||
| 88 | +// }catch (\Throwable $e){ | ||
| 89 | +// DB::rollBack(); | ||
| 90 | +// | ||
| 91 | +// return $data->id; | ||
| 92 | +// break; | ||
| 93 | +// } | ||
| 94 | +// | ||
| 95 | +// } | ||
| 96 | +// DB::commit(); | ||
| 97 | +// } | ||
| 98 | + | ||
| 74 | return $data->id; | 99 | return $data->id; |
| 75 | 100 | ||
| 76 | } | 101 | } |
| @@ -11,48 +11,46 @@ namespace App\Models\Template; | @@ -11,48 +11,46 @@ namespace App\Models\Template; | ||
| 11 | */ | 11 | */ |
| 12 | class BTemplate extends \App\Models\Base{ | 12 | class BTemplate extends \App\Models\Base{ |
| 13 | 13 | ||
| 14 | - protected $table = 'gl_web_template_html'; | 14 | + protected $table = 'gl_web_template'; |
| 15 | 15 | ||
| 16 | + protected $hidden = ['project_id']; | ||
| 16 | 17 | ||
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | - * @param $project_id | ||
| 20 | - * @return mixed | 20 | + * 是否存在模板 |
| 21 | + * @param int $template_id | ||
| 21 | * @author:dc | 22 | * @author:dc |
| 22 | - * @time 2023/5/4 16:13 | 23 | + * @time 2023/5/10 10:00 |
| 23 | */ | 24 | */ |
| 24 | - public static function _get($project_id){ | ||
| 25 | - return static::where(['project_id'=>$project_id])->get(['html','type'])->pluck('html','type')->toArray(); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - public static function _all($project_id){ | ||
| 30 | - return static::where(['project_id'=>$project_id])->get(); | 25 | + public static function _isExist(int $project_id, int $template_id) |
| 26 | + { | ||
| 27 | + return static::where(['project_id'=>$project_id,'template_id'=>$template_id])->limit(1)->count(); | ||
| 31 | } | 28 | } |
| 32 | 29 | ||
| 33 | 30 | ||
| 34 | /** | 31 | /** |
| 35 | - * 保存 | 32 | + * 插入 |
| 36 | * @param $project_id | 33 | * @param $project_id |
| 37 | - * @param $type | ||
| 38 | - * @param $html | 34 | + * @param $data |
| 35 | + * @return mixed | ||
| 39 | * @author:dc | 36 | * @author:dc |
| 40 | - * @time 2023/5/4 17:50 | 37 | + * @time 2023/5/10 10:23 |
| 41 | */ | 38 | */ |
| 42 | - public static function _save($project_id,$type,$html){ | ||
| 43 | - $data = static::where(['project_id'=>$project_id,'type'=>$type])->first(); | ||
| 44 | - if(!$data){ | ||
| 45 | - $data = new static(); | ||
| 46 | - $data->project_id = $project_id; | ||
| 47 | - $data->type = $type; | ||
| 48 | - } | ||
| 49 | - $data->html = $html; | 39 | + public static function _insert($project_id,$data) |
| 40 | + { | ||
| 41 | + $model = new static(); | ||
| 50 | 42 | ||
| 51 | - $data->save(); | 43 | + $model->project_id = $project_id; |
| 44 | + $model->template_id = $data['id']; | ||
| 45 | + $model->name = $data['name']; | ||
| 46 | + $model->thumb = $data['thumb']; | ||
| 47 | + $model->html = $data['html']; | ||
| 52 | 48 | ||
| 53 | - return $data->id; | ||
| 54 | - } | 49 | + $model->save(); |
| 55 | 50 | ||
| 51 | + return $model->id; | ||
| 52 | + | ||
| 53 | + } | ||
| 56 | 54 | ||
| 57 | 55 | ||
| 58 | } | 56 | } |
app/Models/Template/BTemplateData.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Template; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @author:dc | ||
| 9 | + * @time 2023/5/10 14:31 | ||
| 10 | + * Class BTemplateData | ||
| 11 | + * @package App\Models\Template | ||
| 12 | + */ | ||
| 13 | +class BTemplateData extends \App\Models\Base{ | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + protected $table = 'gl_web_template_data'; | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + protected $hidden = ['project_id']; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 插入 | ||
| 25 | + * @param $project_id | ||
| 26 | + * @param $data | ||
| 27 | + * @return mixed | ||
| 28 | + * @author:dc | ||
| 29 | + * @time 2023/5/10 10:23 | ||
| 30 | + */ | ||
| 31 | + public static function _insert($project_id,$data) | ||
| 32 | + { | ||
| 33 | + | ||
| 34 | + $model = new static(); | ||
| 35 | + | ||
| 36 | + $model->project_id = $project_id; | ||
| 37 | + | ||
| 38 | + $model->template_id = $data['template_id']; | ||
| 39 | + | ||
| 40 | + $model->name = $data['name']; | ||
| 41 | + $model->type = $data['type']; | ||
| 42 | + $model->is_edit = $data['is_edit']; | ||
| 43 | + $model->css = $data['css']; | ||
| 44 | + $model->script = $data['script']; | ||
| 45 | + $model->html = $data['html']; | ||
| 46 | + $model->data_ext = $data['data_ext']; | ||
| 47 | + | ||
| 48 | + $model->save(); | ||
| 49 | + | ||
| 50 | + return $model->id; | ||
| 51 | + | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +} |
app/Models/Template/BTemplateHtml.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Template; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * | ||
| 9 | + * 模板 | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/5/9 13:56 | ||
| 12 | + * Class ATemplate | ||
| 13 | + * @package App\Models\Template | ||
| 14 | + */ | ||
| 15 | +class BTemplateHtml extends \App\Models\Base{ | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + protected $table = 'gl_web_template_html'; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + protected $hidden = ['deleted_at','project_id']; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + use SoftDeletes; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 插入 | ||
| 31 | + * @param $project_id | ||
| 32 | + * @param $data | ||
| 33 | + * @return mixed | ||
| 34 | + * @author:dc | ||
| 35 | + * @time 2023/5/10 10:23 | ||
| 36 | + */ | ||
| 37 | + public static function _insert($project_id,$data) | ||
| 38 | + { | ||
| 39 | + | ||
| 40 | + $model = new static(); | ||
| 41 | + | ||
| 42 | + $model->project_id = $project_id; | ||
| 43 | + | ||
| 44 | + $model->template_id = $data['template_id']; | ||
| 45 | + | ||
| 46 | + $model->name = $data['name']; | ||
| 47 | + $model->type = $data['type']; | ||
| 48 | + $model->is_edit = $data['is_edit']; | ||
| 49 | + $model->css = $data['css']; | ||
| 50 | + $model->script = $data['script']; | ||
| 51 | + $model->html = $data['html']; | ||
| 52 | + $model->data_ext = $data['data_ext']; | ||
| 53 | + | ||
| 54 | + $model->save(); | ||
| 55 | + | ||
| 56 | + return $model->id; | ||
| 57 | + | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + | ||
| 61 | +} |
| @@ -224,7 +224,6 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -224,7 +224,6 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 224 | Route::any('/send_media', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'send_media'])->name('ayr_release_send_media'); | 224 | Route::any('/send_media', [\App\Http\Controllers\Bside\AyrShare\AyrReleaseController::class, 'send_media'])->name('ayr_release_send_media'); |
| 225 | }); | 225 | }); |
| 226 | }); | 226 | }); |
| 227 | - | ||
| 228 | // 自定义页面 | 227 | // 自定义页面 |
| 229 | Route::prefix('template')->group(function () { | 228 | Route::prefix('template')->group(function () { |
| 230 | Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer'); | 229 | Route::get('/', [\App\Http\Controllers\Bside\TemplateController::class, 'index'])->name('template_header_footer'); |
| @@ -233,7 +232,14 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -233,7 +232,14 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 233 | Route::get('/system', [\App\Http\Controllers\Bside\TemplateController::class, 'system_all_html'])->name('template_header_footer_system'); | 232 | Route::get('/system', [\App\Http\Controllers\Bside\TemplateController::class, 'system_all_html'])->name('template_header_footer_system'); |
| 234 | Route::get('/custom', [\App\Http\Controllers\Bside\TemplateController::class, 'custom'])->name('template_custom'); | 233 | Route::get('/custom', [\App\Http\Controllers\Bside\TemplateController::class, 'custom'])->name('template_custom'); |
| 235 | }); | 234 | }); |
| 236 | - | 235 | + // 自定义页面,专题页 |
| 236 | + Route::prefix('custom')->group(function () { | ||
| 237 | + Route::get('/', [\App\Http\Controllers\Bside\CustomController::class, 'index'])->name('bside_custom'); | ||
| 238 | + Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'create'])->name('bside_custom_create'); | ||
| 239 | + Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'update'])->name('bside_custom_update'); | ||
| 240 | + Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete'); | ||
| 241 | + Route::any('/html/{id}', [\App\Http\Controllers\Bside\CustomController::class, 'html'])->where('id','\d+')->name('bside_custom_delete'); | ||
| 242 | + }); | ||
| 237 | // 导航栏编辑 | 243 | // 导航栏编辑 |
| 238 | Route::prefix('nav')->group(function () { | 244 | Route::prefix('nav')->group(function () { |
| 239 | Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav'); | 245 | Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav'); |
| @@ -242,9 +248,6 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -242,9 +248,6 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 242 | Route::delete('/delete', [\App\Http\Controllers\Bside\NavController::class, 'delete'])->name('bside_nav_delete'); | 248 | Route::delete('/delete', [\App\Http\Controllers\Bside\NavController::class, 'delete'])->name('bside_nav_delete'); |
| 243 | }); | 249 | }); |
| 244 | 250 | ||
| 245 | - | ||
| 246 | - | ||
| 247 | - | ||
| 248 | }); | 251 | }); |
| 249 | 252 | ||
| 250 | //无需登录验证的路由组 | 253 | //无需登录验证的路由组 |
-
请 注册 或 登录 后发表评论