chore: build a simple store
based on localstorage
This commit is contained in:
@@ -178,7 +178,7 @@
|
|||||||
<script>
|
<script>
|
||||||
// lunr = window.lunr
|
// lunr = window.lunr
|
||||||
// mitt = window.mitt
|
// mitt = window.mitt
|
||||||
(function ({ mitt, lunr }, data) {
|
(function ({ mitt, lunr, localStorage }, data) {
|
||||||
const emitter = mitt();
|
const emitter = mitt();
|
||||||
const stringAscending = (a, b) => {
|
const stringAscending = (a, b) => {
|
||||||
const aa = a.toLowerCase();
|
const aa = a.toLowerCase();
|
||||||
@@ -189,6 +189,10 @@
|
|||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
const getMultiValues = node => Array.from(node.selectedOptions).map(o => o.value);
|
const getMultiValues = node => Array.from(node.selectedOptions).map(o => o.value);
|
||||||
|
const store = {
|
||||||
|
get: id => JSON.parse(localStorage.getItem(id)),
|
||||||
|
set: (id, val) => localStorage.setItem(id, JSON.stringify(val)),
|
||||||
|
};
|
||||||
|
|
||||||
// vue helpers
|
// vue helpers
|
||||||
Vue.filter('capitalize', value => {
|
Vue.filter('capitalize', value => {
|
||||||
|
|||||||
Reference in New Issue
Block a user