app.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. export const Platform = {
  2. ios: 'ios',
  3. android: 'android'
  4. }
  5. /**
  6. * 检查当前环境是什么环境
  7. */
  8. export const checkPlatform = (name) => {
  9. return uni.getSystemInfoSync().platform === name;
  10. }
  11. // 默认的应用设置
  12. export const _DefaultAppSettings = {
  13. showStartPage: false, // 是否每次启动都显示启动页
  14. isAvatarRadius: false, // 评论头像是否圆形
  15. banner: {
  16. useDot: true,
  17. dotPosition: 'right'
  18. },
  19. // 布局配置
  20. layout: {
  21. // h_row_col1 = 一行一列
  22. // h_row_col2 = 一行两列
  23. home: 'h_row_col1',
  24. // lr_image_text=左图右文
  25. // lr_text_image=左文右图
  26. // tb_image_text=上图下文
  27. // tb_text_image=上文下图
  28. // only_text=仅文字
  29. cardType: 'lr_image_text',
  30. },
  31. // 广告配置(todo)
  32. ad: {
  33. timeout: 3, // 屏蔽广告时长,时间到后自动恢复展示(单位小时)
  34. disabled: false, // 是否屏蔽广告(看广告可以关闭应用内设置的广告)
  35. },
  36. // 评论弹幕(文章详情)
  37. barrage: {
  38. use: false, // 是否启用
  39. type: 'leftBottom' // 弹幕位置(rightToLeft leftBottom)
  40. },
  41. gallery: {
  42. // 是否使用瀑布流
  43. useWaterfull: true
  44. },
  45. links: {
  46. // 是否使用简约模式
  47. useSimple: false,
  48. useGroup: false,
  49. },
  50. about: {
  51. showAdmin: false, // 显示后台登录入口
  52. showAllCount: false, // 默认显示所有的统计信息(关于页面)
  53. },
  54. // 文章配置
  55. article: {
  56. },
  57. // 联系博主页面
  58. contact: {
  59. // 链接是否使用复制的方式,否则直接在内部打开(小程序需要配置对应链接的业务域名)
  60. isLinkCopy: true,
  61. },
  62. }
  63. // 应用设置存储key值
  64. export const _AppSettingsKey = 'APP_GLOBAL_SETTINGS';
  65. /**
  66. * 获取应用设置
  67. */
  68. export const getAppSettings = () => {
  69. let _appSettings = uni.getStorageSync(_AppSettingsKey)
  70. if (_appSettings) return JSON.parse(_appSettings)
  71. uni.setStorageSync(_AppSettingsKey, JSON.stringify(_DefaultAppSettings))
  72. return _appSettings;
  73. }
  74. /**
  75. * 保存应用设置
  76. */
  77. export const setAppSettings = (appSettings) => {
  78. uni.setStorageSync(_AppSettingsKey, JSON.stringify(appSettings))
  79. }