app.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. gallery: {
  37. // 是否使用瀑布流
  38. useWaterfull: true
  39. },
  40. links: {
  41. // 是否使用简约模式
  42. useSimple: false,
  43. useGroup: false,
  44. },
  45. about: {
  46. showAdmin: false, // 显示后台登录入口
  47. showAllCount: true, // 默认显示所有的统计信息(关于页面)
  48. },
  49. // 文章配置
  50. article: {
  51. },
  52. // 联系博主页面
  53. contact: {
  54. // 链接是否使用复制的方式,否则直接在内部打开(小程序需要配置对应链接的业务域名)
  55. isLinkCopy: true,
  56. }
  57. }
  58. /**
  59. * 获取应用设置
  60. */
  61. export const getAppSettings = () => {
  62. let _appSettings = uni.getStorageSync('APP_GLOBAL_SETTINGS')
  63. if (_appSettings) return JSON.parse(_appSettings)
  64. uni.setStorageSync('APP_GLOBAL_SETTINGS', JSON.stringify(_DefaultAppSettings))
  65. return _appSettings;
  66. }
  67. /**
  68. * 保存应用设置
  69. */
  70. export const setAppSettings = (appSettings) => {
  71. uni.setStorageSync('APP_GLOBAL_SETTINGS', JSON.stringify(appSettings))
  72. }