index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. },
  19. pageConfig: {
  20. homeConfig: {
  21. pageTitle: "首页",
  22. useCategory: true,
  23. bannerConfig: {
  24. enabled: true,
  25. showTitle: true,
  26. showIndicator: true,
  27. height: "400rpx",
  28. dotPosition: "right",
  29. type: "post",
  30. list: []
  31. }
  32. },
  33. categoryConfig: {
  34. type: "list"
  35. },
  36. momentConfig: {
  37. useTagRandomColor: true
  38. }
  39. },
  40. auditConfig: {
  41. auditModeEnabled: false,
  42. auditModeData: {
  43. jsonUrl: "",
  44. jsonData: ""
  45. }
  46. }
  47. }
  48. /**
  49. * 获取应用设置
  50. */
  51. export const getAppConfigs = () => {
  52. let configs = uni.getStorageSync(_AppConfigKey)
  53. if (configs) return JSON.parse(configs)
  54. uni.setStorageSync(_AppConfigKey, JSON.stringify(DefaultAppConfigs))
  55. return DefaultAppConfigs;
  56. }
  57. /**
  58. * 保存应用设置
  59. */
  60. export const setAppConfigs = (configs) => {
  61. uni.setStorageSync(_AppConfigKey, JSON.stringify(configs))
  62. }
  63. /**
  64. * 获取应用模拟数据
  65. */
  66. export const getAppMockJson = () => {
  67. let json = uni.getStorageSync(_AppMockJsonKey)
  68. if (json) return JSON.parse(json)
  69. uni.setStorageSync(_AppMockJsonKey, JSON.stringify({}))
  70. return {};
  71. }
  72. /**
  73. * 保存应用模拟数据
  74. */
  75. export const setAppMockJson = (json) => {
  76. uni.setStorageSync(_AppMockJsonKey, JSON.stringify(json))
  77. }