main.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import axios from 'axios'
  5. import MuseUI from 'muse-ui';
  6. import 'muse-ui/dist/muse-ui.css';
  7. // 全局插件
  8. import Toast from 'muse-ui-toast';
  9. import Loading from 'muse-ui-loading';
  10. import Message from 'muse-ui-message';
  11. Vue.use(Message);
  12. import NProgress from 'muse-ui-progress';
  13. Vue.use(NProgress);
  14. // import VConsole from 'vconsole/dist/vconsole.min.js' //import vconsole
  15. // let vConsole = new VConsole() // 初始化
  16. Vue.use(MuseUI);
  17. Vue.locale = () => {
  18. };
  19. let ToastConfig = {
  20. position: 'bottom', // 弹出的位置
  21. time: 2000, // 显示的时长
  22. closeIcon: 'close', // 关闭的图标
  23. close: true, // 是否显示关闭按钮
  24. successIcon: 'check_circle', // 成功信息图标
  25. infoIcon: 'info', // 信息信息图标
  26. warningIcon: 'priority_high', // 提醒信息图标
  27. errorIcon: 'warning'
  28. };
  29. Vue.use(Toast, ToastConfig);
  30. Vue.use(Loading);
  31. // 演示版本数据
  32. require('./Mock/index.js');
  33. Vue.config.productionTip = false;
  34. new Vue({
  35. render: h => h(App),
  36. router,
  37. }).$mount('#app');
  38. Vue.prototype.axios = axios;
  39. //Toast
  40. Vue.prototype.Toast = function (e, color) {
  41. let ToastColor = !color ? 'warning' : color;
  42. let that = this;
  43. switch (ToastColor) {
  44. case 'message':
  45. that.$toast.message(e);
  46. break;
  47. case 'success':
  48. that.$toast.success(e);
  49. break;
  50. case 'info':
  51. that.$toast.info(e);
  52. break;
  53. case 'warning':
  54. that.$toast.warning(e);
  55. break;
  56. case 'error':
  57. that.$toast.error(e);
  58. break;
  59. }
  60. };
  61. // loading
  62. Vue.prototype.Loading = function (target) {
  63. let loading = this.$loading({
  64. overlayColor: 'hsla(0,0%,100%,.9)', // 背景色
  65. size: 48,
  66. color: 'warning', // color
  67. });
  68. setTimeout(() => {
  69. loading.close();
  70. }, 3000)
  71. };
  72. Vue.prototype.TransMemo = function (text) {
  73. let that = this;
  74. switch (text) {
  75. case '记录不存在':
  76. that.$toast.error(that.$t('Record does not exist'));
  77. break;
  78. case '服务器繁忙,请稍后再试':
  79. that.$toast.error(that.$t('The server is busy. Please try again later'));
  80. break;
  81. case '服务暂不可用':
  82. that.$toast.error(that.$t('Service is temporarily unavailable'));
  83. break;
  84. case 'key不存在':
  85. that.$toast.error(that.$t('Key does not exist'));
  86. break;
  87. case '用户名或密码错误':
  88. that.$toast.error(that.$t('Wrong user name or password'));
  89. break;
  90. case '图形验证码错误':
  91. that.$toast.error(that.$t('Graphic verification code error'));
  92. break;
  93. case '密码格式错误':
  94. that.$toast.error(that.$t('Password format error'));
  95. break;
  96. case '密码错误':
  97. that.$toast.error(that.$t('Password error'));
  98. break;
  99. case '用户已存在':
  100. that.$toast.error(that.$t('User already exists'));
  101. break;
  102. case '发送频率过高':
  103. that.$toast.error(that.$t('Transmission frequency too high'));
  104. break;
  105. case '用户被禁用':
  106. that.$toast.error(that.$t('User is disabled'));
  107. break;
  108. case '用户状态异常':
  109. that.$toast.error(that.$t('Abnormal user status'));
  110. break;
  111. case '用户不存在':
  112. that.$toast.error(that.$t('user does not exist'));
  113. break;
  114. case '验证码错误':
  115. that.$toast.error(that.$t('Verification code error'));
  116. break;
  117. case '登录失效':
  118. that.$toast.error(that.$t('Logon failure'));
  119. break;
  120. case 'MAC已存在':
  121. that.$toast.error(that.$t('MAC already exists'));
  122. break;
  123. case '不是完整的逗号分隔列表格式':
  124. that.$toast.error(that.$t('Is not a complete comma separated list format'));
  125. break;
  126. case 'HBase错误':
  127. that.$toast.error(that.$t('HBase error'));
  128. break;
  129. case '请重新上传图片':
  130. that.$toast.error(that.$t('Please upload the picture again'));
  131. break;
  132. default:
  133. that.$toast.error(text);
  134. break
  135. }
  136. };