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. banner: {
  15. useDot: true,
  16. dotPosition: 'right'
  17. },
  18. // 布局配置
  19. layout: {
  20. // h_row_col1 = 一行一列
  21. // h_row_col2 = 一行两列
  22. home: 'h_row_col1',
  23. // lr_image_text=左图右文
  24. // lr_text_image=左文右图
  25. // tb_image_text=上图下文
  26. // tb_text_image=上文下图
  27. // only_text=仅文字
  28. cardType: 'lr_image_text',
  29. },
  30. // 广告配置(todo)
  31. ad: {
  32. timeout: 3, // 屏蔽广告时长,时间到后自动恢复展示(单位小时)
  33. disabled: false, // 是否屏蔽广告(看广告可以关闭应用内设置的广告)
  34. },
  35. gallery: {
  36. // 是否使用瀑布流
  37. useWaterfull: false
  38. },
  39. links: {
  40. // 是否使用简约模式
  41. useSimple: false,
  42. useGroup: false,
  43. },
  44. about: {
  45. showAdmin: false, // 显示后台登录入口
  46. showAllCount: true, // 默认显示所有的统计信息(关于页面)
  47. },
  48. // 文章配置
  49. article: {
  50. },
  51. // 联系博主页面
  52. contact: {
  53. // 链接是否使用复制的方式,否则直接在内部打开(小程序需要配置对应链接的业务域名)
  54. isLinkCopy: true,
  55. }
  56. }
  57. /**
  58. * 获取应用设置
  59. */
  60. export const getAppSettings = () => {
  61. let _appSettings = uni.getStorageSync('APP_GLOBAL_SETTINGS')
  62. if (_appSettings) return JSON.parse(_appSettings)
  63. uni.setStorageSync('APP_GLOBAL_SETTINGS', JSON.stringify(_DefaultAppSettings))
  64. return _appSettings;
  65. }
  66. /**
  67. * 保存应用设置
  68. */
  69. export const setAppSettings = (appSettings) => {
  70. uni.setStorageSync('APP_GLOBAL_SETTINGS', JSON.stringify(appSettings))
  71. }