食谱制作页面的快捷列表关键字搜索
This commit is contained in:
@ -1,8 +1,19 @@
|
||||
export function getShortCut() {
|
||||
export function getShortCut(key) {
|
||||
return new Promise((res, rej) => {
|
||||
try {
|
||||
const data = JSON.parse(localStorage.getItem("shortCut") || "[]");
|
||||
res(data);
|
||||
//关键字检索
|
||||
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) {
|
||||
rej(error);
|
||||
}
|
||||
@ -35,6 +46,19 @@ export async function removeShortCut(id) {
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
localStorage.setItem("shortCut", JSON.stringify(newShortCutList));
|
||||
res();
|
||||
} catch (error) {
|
||||
rej(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function editShortCut(data) {
|
||||
const shortCutList = await getShortCut();
|
||||
return new Promise((res, rej) => {
|
||||
|
Reference in New Issue
Block a user