uni-events-helper-wx
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.3 KiB

3 years ago
  1. // 引入全局mixin
  2. import mixin from './libs/mixin/mixin.js'
  3. // 小程序特有的mixin
  4. import mpMixin from './libs/mixin/mpMixin.js'
  5. // 全局挂载引入http相关请求拦截插件
  6. import Request from './libs/luch-request'
  7. // 路由封装
  8. import route from './libs/util/route.js'
  9. // 颜色渐变相关,colorGradient-颜色渐变,hexToRgb-十六进制颜色转rgb颜色,rgbToHex-rgb转十六进制
  10. import colorGradient from './libs/function/colorGradient.js'
  11. // 规则检验
  12. import test from './libs/function/test.js'
  13. // 防抖方法
  14. import debounce from './libs/function/debounce.js'
  15. // 节流方法
  16. import throttle from './libs/function/throttle.js'
  17. // 公共文件写入的方法
  18. import index from './libs/function/index.js'
  19. // 配置信息
  20. import config from './libs/config/config.js'
  21. // props配置信息
  22. import props from './libs/config/props.js'
  23. // 各个需要fixed的地方的z-index配置文件
  24. import zIndex from './libs/config/zIndex.js'
  25. // 关于颜色的配置,特殊场景使用
  26. import color from './libs/config/color.js'
  27. // 平台
  28. import platform from './libs/function/platform'
  29. const $u = {
  30. route,
  31. date: index.timeFormat, // 另名date
  32. colorGradient: colorGradient.colorGradient,
  33. hexToRgb: colorGradient.hexToRgb,
  34. rgbToHex: colorGradient.rgbToHex,
  35. colorToRgba: colorGradient.colorToRgba,
  36. test,
  37. type: ['primary', 'success', 'error', 'warning', 'info'],
  38. http: new Request(),
  39. config, // uView配置信息相关,比如版本号
  40. zIndex,
  41. debounce,
  42. throttle,
  43. mixin,
  44. mpMixin,
  45. props,
  46. ...index,
  47. color,
  48. platform
  49. }
  50. // $u挂载到uni对象上
  51. uni.$u = $u
  52. const install = (Vue) => {
  53. // 时间格式化,同时两个名称,date和timeFormat
  54. Vue.filter('timeFormat', (timestamp, format) => uni.$u.timeFormat(timestamp, format))
  55. Vue.filter('date', (timestamp, format) => uni.$u.timeFormat(timestamp, format))
  56. // 将多久以前的方法,注入到全局过滤器
  57. Vue.filter('timeFrom', (timestamp, format) => uni.$u.timeFrom(timestamp, format))
  58. // 同时挂载到uni和Vue.prototype中
  59. // #ifndef APP-NVUE
  60. // 只有vue,挂载到Vue.prototype才有意义,因为nvue中全局Vue.prototype和Vue.mixin是无效的
  61. Vue.prototype.$u = $u
  62. Vue.mixin(mixin)
  63. // #endif
  64. }
  65. export default {
  66. install
  67. }