作者 lyh

gx

... ... @@ -82,17 +82,6 @@ class InitProject extends Command
}
/**
* @remark :保存默认扩展模块
* @name :saveModule
* @author :lyh
* @method :post
* @time :2023/12/28 15:53
*/
public function saveModule(){
}
/**
* @param NoticeLog $log
*/
public function retry($log, $remark){
... ...
... ... @@ -73,7 +73,7 @@ class BTemplateLogic extends BaseLogic
'is_custom'=>$is_custom, 'is_list'=>$is_list
]);
if($templateInfo === false){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
$html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
... ... @@ -128,8 +128,8 @@ class BTemplateLogic extends BaseLogic
* @time :2023/7/27 15:08
*/
public function getInitModule($type,$is_custom,$is_list){
if($is_custom == BTemplate::SOURCE_CUSTOM) {
$type = BTemplate::TYPE_CUSTOM;
if($is_custom == BTemplate::IS_CUSTOM) {
$type = BTemplate::SOURCE_CUSTOM;
}
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
... ... @@ -189,26 +189,26 @@ class BTemplateLogic extends BaseLogic
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_ONE;
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_THREE;
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_TWO;
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_FIVE;
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_FOUR;
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_SEVEN;
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_SIX;
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
... ... @@ -223,7 +223,7 @@ class BTemplateLogic extends BaseLogic
*/
public function getSettingTemplate($source,$is_list){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
... ... @@ -336,7 +336,7 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/15 10:59
*/
public function handleVisualizationParam($html,$source, $is_list,$data){
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
... ... @@ -453,13 +453,13 @@ class BTemplateLogic extends BaseLogic
if ($pageInfo === false) {
return $this->success($type);
}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list == 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list == 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list == 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
}
return $this->success($type);
}
... ... @@ -581,7 +581,7 @@ class BTemplateLogic extends BaseLogic
$param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
if(!isset($param['is_custom'])){
$param['is_custom'] = BTemplate::SOURCE_NO_CUSTOM;
$param['is_custom'] = BTemplate::IS_NO_CUSTOM;
}
$param['type'] = BTemplate::PAGE_HTML;//不显示整个HTML
return $this->success($param);
... ...
... ... @@ -126,7 +126,7 @@ class InitHtmlLogic extends BaseLogic
$templateCommonModel = new BTemplateCommon();
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
$is_head = $this->user['configuration']['is_head'] ?? 0;
if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::扩展模块无独立头部底部
if($is_custom == BTemplate::IS_CUSTOM){//todo::扩展模块无独立头部底部
$is_head = BTemplate::IS_NO_HEADER;
}
if($is_head == BTemplate::IS_HEADER) {
... ... @@ -174,8 +174,8 @@ class InitHtmlLogic extends BaseLogic
* @time :2023/7/27 15:08
*/
public function getInitModule($type,$is_custom,$is_list){
if($is_custom == BTemplate::SOURCE_CUSTOM) {
$type = BTemplate::TYPE_CUSTOM;
if($is_custom == BTemplate::IS_CUSTOM) {
$type = BTemplate::SOURCE_CUSTOM;
}
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
... ... @@ -192,7 +192,7 @@ class InitHtmlLogic extends BaseLogic
public function getTypeCommonHtml($template_id,$type,$is_custom,$is_list){
//判断当前项目是否有设置独立头部的权限
$is_head = $this->user['configuration']['is_head'] ?? 0;
if($is_custom == BTemplate::SOURCE_CUSTOM){//todo::拓展模块默认取首页
if($is_custom == BTemplate::IS_CUSTOM){//todo::拓展模块默认取首页
$is_head = BTemplate::IS_NO_HEADER;
}
//获取首页公共部分
... ... @@ -221,23 +221,23 @@ class InitHtmlLogic extends BaseLogic
$resultType = BTemplate::SOURCE_HOME;
if($type == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$resultType = BTemplate::TYPE_THREE;
$resultType = BTemplate::TYPE_PRODUCT_LIST;
}else{
$resultType = BTemplate::TYPE_TWO;
$resultType = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($type == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$resultType = BTemplate::TYPE_FIVE;
$resultType = BTemplate::TYPE_BLOG_LIST;
}else{
$resultType = BTemplate::TYPE_FOUR;
$resultType = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($type == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$resultType = BTemplate::TYPE_SEVEN;
$resultType = BTemplate::TYPE_NEWS_LIST;
}else{
$resultType = BTemplate::TYPE_SIX;
$resultType = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $this->success($resultType);
... ...
... ... @@ -12,34 +12,31 @@ use App\Models\Base;
*/
class BTemplate extends Base
{
const SOURCE_CUSTOM = 1;//自定义模块
const SOURCE_HOME = 1;//首页
const SOURCE_PRODUCT = 2;//产品
const SOURCE_BLOG = 3;//博客
const SOURCE_NEWS = 4;//新闻详情页
const SOURCE_KEYWORD = 5;//聚合页
const SOURCE_CUSTOM = 7;//自定义模块
const ALL_HTML = 1;//无需拼接数据,获取整个html
const PAGE_HTML = 0;//默认保存方式为0,
const SOURCE_VISUALIZATION = 1;//定制项目
const SOURCE_NO_CUSTOM = 0;//默认模块
const STATUS = 0;
const TYPE_ONE = 1;//首页类型
const TYPE_TWO = 2;//产品详情
const TYPE_THREE = 3;//产品列表
const TYPE_FOUR = 4;//博客详情
const TYPE_FIVE = 5;//博客列表
const TYPE_SIX = 6;//新闻详情
const TYPE_SEVEN = 7;//新闻列表
const TYPE_EIGHT = 8;//自定义页面
const TYPE_CUSTOM = 7;//扩展详情
const TYPE_HOME = 1;//首页类型
const TYPE_PRODUCT_DETAIL = 2;//产品详情
const TYPE_PRODUCT_LIST = 3;//产品列表
const TYPE_BLOG_DETAIL = 4;//博客详情
const TYPE_BLOG_LIST = 5;//博客列表
const TYPE_NEWS_DETAIL = 6;//新闻详情
const TYPE_NEWS_LIST = 7;//新闻列表
const TYPE_CUSTOM_PAGE = 8;//自定义页面
const IS_LIST = 1;//列表页
const IS_HEADER = 1;//独立头部底部
const IS_NO_HEADER = 0;//非独立头部底部
const IS_CUSTOM = 1;//为扩展模块
const IS_NO_CUSTOM = 0;//为默认模块
const IS_VISUALIZATION = 1;//定制项目
protected $table = 'gl_web_template';
//连接数据库
... ... @@ -110,10 +107,21 @@ class BTemplate extends Base
]
];
/**
* @remark :对用模块类型
* @name :typeMap
* @author :lyh
* @method :post
* @time :2023/12/29 10:57
*/
public function typeMap()
{
return [
self::SOURCE_HOME => 'xxxx',
'SOURCE_HOME'=>self::SOURCE_HOME,
'SOURCE_PRODUCT'=>self::SOURCE_PRODUCT,
'SOURCE_BLOG'=>self::SOURCE_BLOG,
'SOURCE_NEWS'=>self::SOURCE_NEWS,
'SOURCE_KEYWORD'=>self::SOURCE_KEYWORD,
];
}
}
... ...
... ... @@ -8,6 +8,7 @@
namespace App\Services;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
... ... @@ -102,8 +103,43 @@ class ProjectServer extends BaseService
*/
public static function saveInitParam($project_id){
$created_at = date('Y-m-d H:i:s');
self::initGroup($project_id,$created_at);
//初始化单页
self::init404Page($project_id);
//初始化模块数据
self::initModule($project_id);
DB::disconnect('custom_mysql');
return true;
}
//菜单
/**
* @remark :初始化模块
* @name :initModule
* @author :lyh
* @method :post
* @time :2023/12/29 9:34
*/
public function initModule($project_id){
$moduleModel = new CustomModule();
$info = $moduleModel->read(['route'=>'video']);
if($info === false){
$data = [
'name'=>'视频模块',
'project_id'=>$project_id,
'route'=>'video',
];
$moduleModel->add($data);
}
return true;
}
/**
* @remark :菜单
* @name :initGroup
* @author :lyh
* @method :post
* @time :2023/12/29 9:30
*/
public static function initGroup($project_id,$created_at){
$info = DB::connection('custom_mysql')->table('gl_web_nav')->first();
if(empty($info)) {
$data = [
... ... @@ -116,7 +152,6 @@ class ProjectServer extends BaseService
];
DB::connection('custom_mysql')->table('gl_web_nav')->insert($data);
}
//菜单组
$info = DB::connection('custom_mysql')->table('gl_web_nav_group')->first();
if(empty($info)) {
... ... @@ -126,11 +161,20 @@ class ProjectServer extends BaseService
];
DB::connection('custom_mysql')->table('gl_web_nav_group')->insert($data);
}
return true;
}
//初始化单页
/**
* @remark :初始化404页面
* @name :init404Page
* @author :lyh
* @method :post
* @time :2023/12/29 9:32
*/
public function init404Page($project_id){
$info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
if(empty($info)) {
$data = ['project_id' => $project_id, 'name' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'status' => 1, 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'html' => '<main>
$main_404_html = '<main>
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
id="sectionIdyxqu938">
<div class="layout" data-unable="demo01-error404">
... ... @@ -156,7 +200,14 @@ class ProjectServer extends BaseService
<script>
</script>
</section>
</main>', 'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at];
</main>';
$data = [
'project_id' => $project_id,
'name' => BCustomTemplate::NOT_FOUND_PAGE_URL,
'status' => 1,
'url' => BCustomTemplate::NOT_FOUND_PAGE_URL,
'html' => $main_404_html,
'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at];
$id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);
//路由
$info = DB::connection('custom_mysql')->table('gl_route_map')->first();
... ... @@ -165,8 +216,5 @@ class ProjectServer extends BaseService
DB::connection('custom_mysql')->table('gl_route_map')->insert($data);
}
}
DB::disconnect('custom_mysql');
return true;
}
}
... ...