|
|
@@ -36,6 +36,33 @@ Vue.prototype.$echarts = echarts
|
|
|
|
|
|
import '@/permission'
|
|
|
|
|
|
+// 全局配置 Message 的默认 duration 为 5000 毫秒(5秒)
|
|
|
+Vue.use(ElementUI, {
|
|
|
+ size: 'small',
|
|
|
+ zIndex: 3000
|
|
|
+})
|
|
|
+
|
|
|
+// 单独为 Message 修改原型上的默认属性
|
|
|
+Vue.prototype.$message = function(options) {
|
|
|
+ if (typeof options === 'string') {
|
|
|
+ options = { message: options }
|
|
|
+ }
|
|
|
+ // 默认加入 duration: 5000,如果传入了新值则覆盖默认值
|
|
|
+ options.duration = options.duration === undefined ? 1000 : options.duration
|
|
|
+ return ElementUI.Message(options)
|
|
|
+};
|
|
|
+
|
|
|
+// 挂载快捷方法(如 .warning, .success 等)
|
|
|
+['success', 'warning', 'info', 'error'].forEach(type => {
|
|
|
+ Vue.prototype.$message[type] = function(options) {
|
|
|
+ if (typeof options === 'string') {
|
|
|
+ options = { message: options }
|
|
|
+ }
|
|
|
+ options.type = type
|
|
|
+ return Vue.prototype.$message(options)
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
Vue.config.productionTip = false // 阻止控制台打印生产模式下的消息
|
|
|
Vue.prototype.baseURL = process.env.VUE_APP_SERVER_URL
|
|
|
new Vue({
|