|
@@ -23,8 +23,6 @@ const state = {
|
|
|
aloneList:[],//自定义列表页
|
|
|
aloneArticle:[],//自定义详情页
|
|
|
},
|
|
|
- editWindowStatus:false,//编辑弹出框是否显示
|
|
|
- editWindowTitle:"",//编辑弹出框标题
|
|
|
// layout: [
|
|
|
// // i = id
|
|
|
// // w = 最大宽度是12
|
|
@@ -45,6 +43,13 @@ const state = {
|
|
|
//2.站点数据 end------------------------------------------------------------>
|
|
|
|
|
|
//3.网站数据 start------------------------------------------------------------>
|
|
|
+ editWindowStatus:false,//编辑弹出框是否显示
|
|
|
+ editWindowTitle:"",//编辑弹出框标题
|
|
|
+ editSectorId:0,//当前正在编辑的板块id
|
|
|
+ editComponentSort:0,//当前正在编辑的组件id
|
|
|
+ editComponentType:0,//当前正在编辑的组件类型
|
|
|
+ editComponentSize:0,//当前组件展示的条数
|
|
|
+
|
|
|
webSiteData:{
|
|
|
//1.base网站基本信息
|
|
|
base:{
|
|
@@ -55,40 +60,16 @@ const state = {
|
|
|
styleId:1,//风格id
|
|
|
},
|
|
|
//3.板块信息 header,menu,footer 是页面自带的无需构建
|
|
|
- template:[
|
|
|
- { //index = 首页 class=分类页 list=列表页 article=详情页 search=搜索页 aloneList=自定义列表页 aloneArticle=自定义详情页
|
|
|
- index:[{
|
|
|
- sectorName:"bannerName",//板块名称
|
|
|
- sectorId:1,//板块id
|
|
|
- sort:1,//板块排序
|
|
|
- componentList:[
|
|
|
- {
|
|
|
- component_type:1,//组件类型 1=新闻(单个) 2=新闻(多个) 3=广告 4=友情链接 5=底部导航 6=静态html组件
|
|
|
- component_name:"componentName",//组件名称
|
|
|
- sort:1,//组件排序
|
|
|
- componentData:{//该组件请求的数据
|
|
|
- category_id:[[5,11],[6,24,45]],//请求的导航id 如果上面的component_type是1,这里只会有1个[[1]],如果是2,这里就会有多个
|
|
|
- page:1,//请求第几页
|
|
|
- pageSize:1,//请求的条数
|
|
|
- listType:[//请求的数据应该包含哪些字段
|
|
|
- "title",//标题
|
|
|
- "created_time",//创建时间
|
|
|
- "author",//作者
|
|
|
- "imgUrl",//缩略图片
|
|
|
- "introduce",//描述
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }],
|
|
|
- class:[],//分类页
|
|
|
- list:[],//列表页
|
|
|
- article:[],//详情页
|
|
|
- search:[],//搜索页
|
|
|
- aloneList:[],//自定义列表页
|
|
|
- aloneArticle:[],//自定义详情页
|
|
|
- }
|
|
|
- ]
|
|
|
+ template:{
|
|
|
+ //index = 首页 class=分类页 list=列表页 article=详情页 search=搜索页 aloneList=自定义列表页 aloneArticle=自定义详情页
|
|
|
+ index:[],
|
|
|
+ class:[],//分类页
|
|
|
+ list:[],//列表页
|
|
|
+ article:[],//详情页
|
|
|
+ search:[],//搜索页
|
|
|
+ aloneList:[],//自定义列表页
|
|
|
+ aloneArticle:[],//自定义详情页
|
|
|
+ }
|
|
|
}
|
|
|
//3.网站数据 end------------------------------------------------------------>
|
|
|
}
|
|
@@ -111,14 +92,21 @@ const mutations = {
|
|
|
state.pageStatus = num;
|
|
|
},
|
|
|
//打开编辑弹出框
|
|
|
- setEditWindowStatus(state,title){
|
|
|
+ setEditWindowStatus(state,data){
|
|
|
+ console.log(data);
|
|
|
state.editWindowStatus = true;
|
|
|
- state.editWindowTitle = title;
|
|
|
+ state.editSectorId = data.id;
|
|
|
+ state.editComponentSort = data.sort;
|
|
|
+ state.editComponentType = data.type;
|
|
|
+ state.editComponentSize = data.size;
|
|
|
},
|
|
|
//关闭编辑弹出框
|
|
|
closeEditWindowStatus(state){
|
|
|
state.editWindowStatus = false;
|
|
|
- state.editWindowTitle = "";
|
|
|
+ state.editSectorId = "";
|
|
|
+ state.editComponentSort = "";
|
|
|
+ state.editComponentType = "";
|
|
|
+ state.editComponentSize = "";
|
|
|
},
|
|
|
//0.全局配置 start------------------------------------------------------------>
|
|
|
//1.配置模块 start------------------------------------------------------------>
|
|
@@ -130,8 +118,10 @@ const mutations = {
|
|
|
return;
|
|
|
}else{
|
|
|
//data.type 组件名称 data.h 模块高度
|
|
|
- // 计算当前布局的最大 y 值
|
|
|
+ //计算当前布局的最大 y 值
|
|
|
const maxY = Math.max(...state.pageData.index.map(item => item.y), 0);
|
|
|
+ //添加板块id
|
|
|
+
|
|
|
state.pageData.index.push({
|
|
|
i: state.pageData.index.length,
|
|
|
x: 0,
|
|
@@ -139,16 +129,14 @@ const mutations = {
|
|
|
w: 12,
|
|
|
h: data.h,
|
|
|
type: data.type,
|
|
|
- content:""
|
|
|
+ content:"123",
|
|
|
+ sectorData:data.jsonData
|
|
|
});
|
|
|
- console.log(state.pageData.index);
|
|
|
- }
|
|
|
+ console.log(state.pageData.index.length);
|
|
|
+ data.jsonData.sectorId = state.pageData.index.length;
|
|
|
+ console.log(data.jsonData);
|
|
|
|
|
|
- //添加板块数据到webSiteData.template.index
|
|
|
- //state.webSiteData.template.index.push()
|
|
|
- console.log(data);
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
},
|
|
|
//删除首页板块
|
|
|
deleteIndexModule(state,data){
|
|
@@ -280,7 +268,30 @@ const mutations = {
|
|
|
|
|
|
// }
|
|
|
// },
|
|
|
+ //格式化模板信息
|
|
|
+ formatTemplateInfo(state, data) {
|
|
|
+ //console.log(data.type);
|
|
|
+ //按照data.data.y的大小排序
|
|
|
+ data.data.sort((a, b) => a.y - b.y);
|
|
|
+ //获取板块的sort
|
|
|
+ for (let index in data.data) {
|
|
|
+ console.log(data.data[index].sectorData);
|
|
|
+ data.data[index].sectorData.sort = Number(index)+1;
|
|
|
+ if(data.type=="index"){
|
|
|
+ state.webSiteData.template.index.push(data.data[index].sectorData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //保存模板
|
|
|
+ saveTemplate(state) {
|
|
|
+ //调用mutations中的方法无需使用$store
|
|
|
+ //格式化index的信息
|
|
|
+ this.commit('template/formatTemplateInfo',{data:state.pageData.index,type:"index"});
|
|
|
+
|
|
|
+ console.log(state.webSiteData);
|
|
|
+ },
|
|
|
//1.配置模块 end------------------------------------------------------------>
|
|
|
+
|
|
|
//2.获取站点信息 start------------------------------------------------------------>
|
|
|
//获取站点详情
|
|
|
setWebsiteInfo(state,data){
|