提交 6fa3f048 authored 作者: 王鹏飞's avatar 王鹏飞

update

上级 2ce8f1c8
<template> <template>
<header class="header"> <header class="header">
<div class="logo"></div> <div class="logo"></div>
<div class="message"></div> <div class="message">
<!-- <vue-message :option="{ source: 'MESSAGE_WEB' }" /> -->
</div>
</header> </header>
</template> </template>
<script> <script>
import Message from '@/main' import Message from '@/main.js'
export default { export default {
mounted() { mounted() {
new Message({ el: '.message', source: 'MESSAGE_WEB' }) Message({ container: '.message', source: 'MESSAGE_WEB' })
} }
} }
</script> </script>
......
import Vue from 'vue' import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue' import App from './App.vue'
Vue.use(ElementUI)
// import VueMessage from '@/index.js'
// Vue.use(VueMessage, { source: 'MESSAGE_WEB' })
Vue.config.productionTip = false
new Vue({ new Vue({
render: h => h(App) render: h => h(App)
}).$mount('#app') }).$mount('#app')
{ {
"name": "@ezijing/web-message-sdk", "name": "@ezijing/web-message-sdk",
"version": "0.1.2", "version": "0.2.0",
"private": false, "private": false,
"main": "dist/message.umd.min.js", "main": "dist/message.umd.js",
"files": [ "files": [
"dist/", "dist/",
"package.json", "package.json",
......
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" /> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head> </head>
<body> <body>
<noscript> <noscript>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
ref="message" ref="message"
></message-popover> ></message-popover>
</el-popover> </el-popover>
<el-dialog :visible.sync="visible" title="消息中心" :fullscreen="true"> <el-dialog :visible.sync="visible" title="消息中心" :fullscreen="true" :append-to-body="true">
<message v-if="visible" /> <message v-if="visible" />
</el-dialog> </el-dialog>
</div> </div>
...@@ -36,6 +36,7 @@ import Message from '@/components/Message' ...@@ -36,6 +36,7 @@ import Message from '@/components/Message'
import MessagePopover from '@/components/MessagePopover' import MessagePopover from '@/components/MessagePopover'
import * as api from '@/api' import * as api from '@/api'
export default { export default {
name: 'VueMessage',
components: { Message, MessagePopover }, components: { Message, MessagePopover },
data() { data() {
return { return {
......
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
getMessages() { getMessages() {
this.loading = true this.loading = true
api api
.getMessages({ limit: 10, page: this.page, type: this.type, is_read: this.tabActive }) .getMessages({ limit: 10, page: this.page, type: this.type, is_read: this.tabActive, is_platform: 0 })
.then(response => { .then(response => {
this.messages = response.data this.messages = response.data
this.total = response.total this.total = response.total
......
...@@ -26,8 +26,7 @@ export default { ...@@ -26,8 +26,7 @@ export default {
}, },
methods: { methods: {
getMessages() { getMessages() {
const source = this.$option.source api.getMessages({ limit: 4, type: 0, is_read: 0, is_platform: 0 }).then(response => {
api.getMessages({ limit: 4, type: 0, is_read: 0, source }).then(response => {
this.messages = response.data this.messages = response.data
}) })
}, },
......
import Vue from 'vue' import Vue from 'vue'
// import ElementUI from 'element-ui' import Main from './Main.vue'
// import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
Vue.config.productionTip = false let MessageConstructor = Vue.extend(Main)
export default class Message { const Message = function(options = { source: '' }) {
constructor(option = {}) { if (Vue.prototype.$isServer) return
window.messageOption = option const instance = new MessageConstructor({
Vue.prototype.$option = option data: options
if (!Message.instance) { })
Message.renderDom(option) window.messageOption = options
Message.instance = this instance.$mount(options.container)
}
return Message.instance
}
// 渲染vue
static renderDom(option) {
new Vue({
render: h => h(App)
}).$mount(option.el)
}
// 初始化
static init(option, cb) {
if (!this.instance) {
this.instance = new Message(option, cb)
}
return this.instance
}
} }
export default Message
...@@ -6,14 +6,11 @@ module.exports = { ...@@ -6,14 +6,11 @@ module.exports = {
index: { entry: 'examples/main.js' } index: { entry: 'examples/main.js' }
}, },
productionSourceMap: false, productionSourceMap: false,
runtimeCompiler: true,
css: { css: {
extract: false extract: false
}, },
configureWebpack: { configureWebpack: {
externals: {
vue: 'Vue',
'element-ui': 'ElementUI'
},
output: { output: {
libraryExport: 'default' libraryExport: 'default'
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论