main.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import App from './App'
  2. import { createSSRApp } from 'vue'
  3. import store from '@/store'
  4. import uView from "@/uni_modules/vk-uview-ui/index.js"
  5. import getConfig from '@/config'
  6. import {delayDel} from '@/libs/tools.js'
  7. import vuexStore from "@/store/$u.mixin.js"
  8. export function createApp() {
  9. const app = createSSRApp(App)
  10. app.config.productionTip = false
  11. app.use(store)
  12. app.use(uView)
  13. app.mixin(vuexStore)
  14. //延迟执行函数
  15. app.config.globalProperties.$delayDel = delayDel
  16. // 系统配置
  17. app.config.globalProperties.$config = function (key) {
  18. const theme = store.state.vuex_theme
  19. return getConfig(theme)[key]
  20. }
  21. /**
  22. * 权限检查
  23. */
  24. app.config.globalProperties.$hasPermissions = function (value) {
  25. let isExist = false;
  26. let permissionsStr = store.state.vuex_userData.permCodes;
  27. if (permissionsStr == undefined || permissionsStr == null) {
  28. return false;
  29. }
  30. let has = permissionsStr.find(item => item == value)
  31. if (has) {isExist = true;}
  32. return isExist;
  33. }
  34. /*
  35. * 提示信息
  36. */
  37. app.config.globalProperties.toashMsg = function (title,duration) {
  38. title = title == undefined ? "系统繁忙" : title;
  39. uni.showToast({
  40. title:title,
  41. icon:'none',
  42. duration: duration||4000
  43. })
  44. }
  45. app.config.globalProperties.showLoading = function (title) {
  46. title = title == undefined ? "正在加载..." : title;
  47. uni.showLoading({
  48. title:title,
  49. mask: true
  50. })
  51. }
  52. return {
  53. app
  54. }
  55. }