index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // 应用设置存储key值
  2. export const _AppConfigKey = 'APP_GLOBAL_CONFIGS';
  3. export const _AppMockJsonKey = 'APP_GLOBAL_MOCK_JSON';
  4. // 默认的应用设置
  5. export const DefaultAppConfigs = {
  6. basicConfig: {
  7. tokenConfig: {
  8. personalToken: "",
  9. }
  10. },
  11. loveConfig: {},
  12. imagesConfig: {},
  13. authorConfig: {},
  14. appConfig: {},
  15. pluginConfig: {
  16. toolsPlugin: {},
  17. linksSubmitPlugin: {},
  18. doubanPlugin: {
  19. position: 'bottom'
  20. }
  21. },
  22. pageConfig: {
  23. homeConfig: {
  24. pageTitle: "首页",
  25. useCategory: true,
  26. bannerConfig: {
  27. enabled: true,
  28. showTitle: true,
  29. showIndicator: true,
  30. height: "400rpx",
  31. dotPosition: "right",
  32. type: "post",
  33. list: []
  34. }
  35. },
  36. categoryConfig: {
  37. type: "list"
  38. },
  39. momentConfig: {
  40. useTagRandomColor: true
  41. }
  42. },
  43. auditConfig: {
  44. auditModeEnabled: false,
  45. auditModeData: {
  46. jsonUrl: "",
  47. jsonData: ""
  48. }
  49. }
  50. }
  51. /**
  52. * 获取应用设置
  53. */
  54. export const getAppConfigs = () => {
  55. let configs = uni.getStorageSync(_AppConfigKey)
  56. if (configs) return JSON.parse(configs)
  57. uni.setStorageSync(_AppConfigKey, JSON.stringify(DefaultAppConfigs))
  58. return DefaultAppConfigs;
  59. }
  60. /**
  61. * 保存应用设置
  62. */
  63. export const setAppConfigs = (configs) => {
  64. uni.setStorageSync(_AppConfigKey, JSON.stringify(configs))
  65. }
  66. /**
  67. * 获取应用模拟数据
  68. */
  69. export const getAppMockJson = () => {
  70. let json = uni.getStorageSync(_AppMockJsonKey)
  71. if (json) return JSON.parse(json)
  72. uni.setStorageSync(_AppMockJsonKey, JSON.stringify({}))
  73. return {};
  74. }
  75. /**
  76. * 保存应用模拟数据
  77. */
  78. export const setAppMockJson = (json) => {
  79. uni.setStorageSync(_AppMockJsonKey, JSON.stringify(json))
  80. }