feat: custom shortcuts

This commit is contained in:
qier222 2021-06-09 20:39:00 +08:00
parent 78d90f15f5
commit e54c606c6d
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
9 changed files with 439 additions and 56 deletions

View file

@ -8,6 +8,21 @@ const updateSetting = () => {
...parsedSettings,
};
if (
settings.shortcuts.length !== initLocalStorage.settings.shortcuts.length
) {
// 当新增 shortcuts 时
const oldShortcutsId = settings.shortcuts.map(s => s.id);
const newShortcutsId = initLocalStorage.settings.shortcuts.filter(
s => oldShortcutsId.includes(s.id) === false
);
newShortcutsId.map(id => {
settings.shortcuts.push(
initLocalStorage.settings.shortcuts.find(s => s.id === id)
);
});
}
localStorage.setItem('settings', JSON.stringify(settings));
};