From 9d88fdc1e015f441896230db0eb41e685be51bb3 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Thu, 29 Jul 2021 14:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=96=E5=8A=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/package.json | 2 +- stdiet-ui/src/utils/shortCutUtils.js | 31 +++-- .../InfoView/ShortCutCom/index.vue | 127 +++++++++++++----- 3 files changed, 116 insertions(+), 44 deletions(-) diff --git a/stdiet-ui/package.json b/stdiet-ui/package.json index dc83779d1..ae970217d 100644 --- a/stdiet-ui/package.json +++ b/stdiet-ui/package.json @@ -64,7 +64,7 @@ "path-to-regexp": "2.4.0", "quill": "1.3.7", "screenfull": "4.2.0", - "sortablejs": "1.8.4", + "sortablejs": "^1.14.0", "vue": "2.6.10", "vue-count-to": "1.0.13", "vue-cropper": "0.4.9", diff --git a/stdiet-ui/src/utils/shortCutUtils.js b/stdiet-ui/src/utils/shortCutUtils.js index df49202b9..c45537e34 100644 --- a/stdiet-ui/src/utils/shortCutUtils.js +++ b/stdiet-ui/src/utils/shortCutUtils.js @@ -3,15 +3,20 @@ export function getShortCut(key) { try { const data = JSON.parse(localStorage.getItem("shortCut") || "[]"); //关键字检索 - if(key != undefined && key != null && key != ""){ - const resultData = []; - data.forEach((item,index) => { - if(item.name.indexOf(key) != -1 || (item.className != undefined && item.className != null && item.className.indexOf(key) != -1)){ - resultData.push(item); - } - }); - res(resultData); - }else{ + if (key != undefined && key != null && key != "") { + const resultData = []; + data.forEach((item, index) => { + if ( + item.name.indexOf(key) != -1 || + (item.className != undefined && + item.className != null && + item.className.indexOf(key) != -1) + ) { + resultData.push(item); + } + }); + res(resultData); + } else { res(data); } } catch (error) { @@ -50,7 +55,9 @@ export async function removeMuchShortCut(ids) { const shortCutList = await getShortCut(); return new Promise((res, rej) => { try { - const newShortCutList = shortCutList.filter(obj => ids.indexOf(obj.id) == -1); + const newShortCutList = shortCutList.filter( + obj => ids.indexOf(obj.id) == -1 + ); localStorage.setItem("shortCut", JSON.stringify(newShortCutList)); res(); } catch (error) { @@ -74,3 +81,7 @@ export async function editShortCut(data) { } }); } + +export function updateSortCut(data) { + localStorage.setItem("shortCut", JSON.stringify(data)); +} diff --git a/stdiet-ui/src/views/custom/recipesBuild/InfoView/ShortCutCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/ShortCutCom/index.vue index 1499eff0b..f94ad5c3e 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/ShortCutCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/ShortCutCom/index.vue @@ -1,7 +1,13 @@