common.js 803 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export default {
  2. state: {
  3. KeyboardHeight: 0,
  4. moveX: 0,
  5. moveY: 0,
  6. custom_font_size: 14,
  7. },
  8. mutations: {
  9. changeKeyboardHeight(state, h) {
  10. state.KeyboardHeight = h
  11. },
  12. setMoveX(x) {
  13. this.moveX = x;
  14. },
  15. setMoveY(y) {
  16. this.moveY = y;
  17. },
  18. setFontSize(state, val) {
  19. state.custom_font_size = val;
  20. try {
  21. uni.setStorageSync('custom_font_size', val);
  22. } catch (e) {
  23. // error
  24. }
  25. },
  26. },
  27. getters: {
  28. getFontSize(state) {
  29. let size = ''
  30. try {
  31. size = uni.getStorageSync('custom_font_size');
  32. console.log("当前字体大小", size)
  33. if (size) {
  34. return size;
  35. } else {
  36. return state.custom_font_size;
  37. }
  38. } catch (e) {
  39. // error
  40. if (size) {
  41. return size;
  42. } else {
  43. return state.custom_font_size;
  44. }
  45. }
  46. }
  47. }
  48. }