handleAllpks.js 583 B

1234567891011121314151617181920212223242526272829303132333435
  1. import {cacheTools} from 'nc-lightapp-front';
  2. function get() {
  3. return cacheTools.get('allpks') || [];
  4. }
  5. function add(pk) {
  6. let allpks = get();
  7. const index = allpks.indexOf(pk);
  8. if (index === -1) {
  9. allpks.unshift(pk);
  10. }
  11. set(allpks);
  12. }
  13. function remove(pk) {
  14. let allpks = get();
  15. const index = allpks.indexOf(pk);
  16. if (index > -1) {
  17. allpks.splice(index, 1);
  18. }
  19. set(allpks);
  20. }
  21. function set(pks) {
  22. cacheTools.set('allpks', pks);
  23. }
  24. let handleAllpks = {
  25. get,
  26. set,
  27. add,
  28. remove
  29. };
  30. export default handleAllpks;