|
@@ -387,71 +387,73 @@ const mutations = {
|
|
|
},
|
|
|
//移动板块 (暂时停用)
|
|
|
moveModule(state, data) {
|
|
|
- Message.error('移动板块功能暂时停用!');
|
|
|
+ // Message.error('移动板块功能暂时停用!');
|
|
|
// pageStatus == 1 首页
|
|
|
- // if (state.pageStatus == 1) {
|
|
|
- // const moveType = data.moveType;
|
|
|
- // const moduleId = data.i;
|
|
|
- // const modules = state.pageData.index;
|
|
|
- // // 查找模块在数组中的实际索引
|
|
|
- // const thisIndex = modules.findIndex(module => module.i === moduleId);
|
|
|
- // if (thisIndex === -1) {
|
|
|
- // Message.error('模块未找到!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // const thisY = modules[thisIndex].y;
|
|
|
- // let thatY;
|
|
|
- // if (moveType === 'up') {
|
|
|
- // thatY = Math.max(
|
|
|
- // ...modules.filter(item => item.y < thisY).map(item => item.y)
|
|
|
- // );
|
|
|
- // if (thatY === -Infinity) {
|
|
|
- // Message.error('已经是顶部了!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
- // if (thatIndex === -1) {
|
|
|
- // Message.error('上方模块未找到!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
+ if (state.pageStatus == 1) {
|
|
|
+ const moveType = data.moveType;
|
|
|
+ const moduleId = data.i;
|
|
|
+ const modules = state.pageData.index;
|
|
|
+ // 查找模块在数组中的实际索引
|
|
|
+ const thisIndex = modules.findIndex(module => module.i === moduleId);
|
|
|
+ if (thisIndex === -1) {
|
|
|
+ Message.error('模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const thisY = modules[thisIndex].y;
|
|
|
+ let thatY;
|
|
|
+ if (moveType === 'up') {
|
|
|
+ thatY = Math.max(
|
|
|
+ ...modules.filter(item => item.y < thisY).map(item => item.y)
|
|
|
+ );
|
|
|
+ if (thatY === -Infinity) {
|
|
|
+ Message.error('已经是顶部了!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
+ if (thatIndex === -1) {
|
|
|
+ Message.error('上方模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
+
|
|
|
+ } else if (moveType === 'down') {
|
|
|
+ thatY = Math.min(
|
|
|
+ ...modules.filter(item => item.y > thisY).map(item => item.y)
|
|
|
+ );
|
|
|
+ if (thatY === Infinity) {
|
|
|
+ Message.error('已经是底部了!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
+ if (thatIndex === -1) {
|
|
|
+ Message.error('下方模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
+ } else {
|
|
|
+ Message.error('未知的移动类型!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 交换后对模块进行排序以确保顺序一致
|
|
|
+ modules.sort((a, b) => a.y - b.y);
|
|
|
+ // 使用 Vue.set 强制更新数组,确保视图更新
|
|
|
+ Vue.set(state.pageData, 'index', [...modules]);
|
|
|
+ console.log(state.pageData.index); //打印查看是否已修改
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- // } else if (moveType === 'down') {
|
|
|
- // thatY = Math.min(
|
|
|
- // ...modules.filter(item => item.y > thisY).map(item => item.y)
|
|
|
- // );
|
|
|
- // if (thatY === Infinity) {
|
|
|
- // Message.error('已经是底部了!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
- // if (thatIndex === -1) {
|
|
|
- // Message.error('下方模块未找到!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
- // } else {
|
|
|
- // Message.error('未知的移动类型!');
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // // 交换后对模块进行排序以确保顺序一致
|
|
|
- // modules.sort((a, b) => a.y - b.y);
|
|
|
- // // 使用 Vue.set 强制更新数组,确保视图更新
|
|
|
- // Vue.set(state.pageData, 'index', [...modules]);
|
|
|
- // console.log(state.pageData.index); //打印查看是否已修改
|
|
|
- // }
|
|
|
// pageStatus == 2 分类页
|
|
|
- // if (state.pageStatus == 2) {}
|
|
|
- // // pageStatus == 3 列表页
|
|
|
- // if (state.pageStatus == 3) {}
|
|
|
- // // pageStatus == 4 详情页
|
|
|
- // if (state.pageStatus == 4) {}
|
|
|
- // // pageStatus == 5 搜索页
|
|
|
- // if (state.pageStatus == 5) {}
|
|
|
- // // pageStatus == 6 自定义列表页
|
|
|
- // if (state.pageStatus == 6) {}
|
|
|
- // // pageStatus == 7 自定义详情页
|
|
|
- // if (state.pageStatus == 7) {}
|
|
|
+ if (state.pageStatus == 2) {}
|
|
|
+ // pageStatus == 3 列表页
|
|
|
+ if (state.pageStatus == 3) {}
|
|
|
+ // pageStatus == 4 详情页
|
|
|
+ if (state.pageStatus == 4) {}
|
|
|
+ // pageStatus == 5 搜索页
|
|
|
+ if (state.pageStatus == 5) {}
|
|
|
+ // pageStatus == 6 自定义列表页
|
|
|
+ if (state.pageStatus == 6) {}
|
|
|
+ // pageStatus == 7 自定义详情页
|
|
|
+ if (state.pageStatus == 7) {}
|
|
|
},
|
|
|
//修改首页板块高度
|
|
|
setModuleHeight(state,data){
|