A Vue 2 chat module with Vuex and Tailwind CSS.
yarn add module-chat-ai
import Vue from 'vue';
import Vuex from 'vuex';
import ChatAIPlugin, { store } from 'module-chat-ai';
import 'module-chat-ai/dist/module-chat-ai.css';
Vue.use(Vuex);
const appStore = new Vuex.Store({
modules: {
chatAI: store
}
});
Vue.use(ChatAIPlugin, {
baseAPI: 'https://your-api.com',
store: appStore
});
new Vue({
store: appStore,
render: h => h('chat-ai')
}).$mount('#app');
- Add to
plugins/chat-ai.js
:
import Vue from 'vue';
import ChatAIPlugin, { store } from 'module-chat-ai';
export default ({ store }, inject) => {
Vue.use(ChatAIPlugin, {
baseAPI: 'https://your-api.com',
store
});
};
- Update
nuxt.config.js
:
export default {
plugins: [{ src: '~/plugins/chat-ai.js', mode: 'client' }],
css: ['module-chat-ai/dist/module-chat-ai.css']
};
- Use in template:
<template>
<chat-ai @message-sent="onMessageSent" />
</template>
MIT