diff --git a/package.json b/package.json
index 71cdb9d..3ff6328 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,8 @@
"stompjs": "^2.3.3",
"vue": "^3.5.11",
"vue-router": "^4.4.5",
- "vue-stomp": "^0.0.5"
+ "vue-stomp": "^0.0.5",
+ "vue-toastification": "^2.0.0-rc.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.4",
diff --git a/src/main.js b/src/main.js
index 3d21669..bb1bdb9 100644
--- a/src/main.js
+++ b/src/main.js
@@ -5,9 +5,12 @@ import './assets/css/reset.css';
import App from './App.vue'
import router from './router'
import BootstrapVue3 from 'bootstrap-vue-3'
+import Toast from "vue-toastification";
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-vue-3/dist/bootstrap-vue-3.css';
+import "vue-toastification/dist/index.css";
+import { POSITION } from 'vue-toastification';
const app = createApp(App);
const pinia = createPinia();
@@ -15,5 +18,8 @@ const pinia = createPinia();
app.use(router)
app.use(BootstrapVue3)
app.use(pinia);
-
+app.use(Toast, {
+ position: POSITION.BOTTOM_RIGHT,
+ timeout: 5000
+});
app.mount('#app')
diff --git a/src/views/body/chat/Chat.vue b/src/views/body/chat/Chat.vue
index d73d467..33c45a1 100644
--- a/src/views/body/chat/Chat.vue
+++ b/src/views/body/chat/Chat.vue
@@ -182,12 +182,22 @@
const socket = new SockJS('http://localhost:8080/ws-stomp');
stompClient.value = Stomp.over(socket);
+ const token = localStorage.getItem('jwtToken'); // 예시로 로컬 스토리지에서 가져옴
+
+ // 헤더에 Authorization 추가
+ const headers = {};
+ if (token) {
+ headers['Authorization'] = 'Bearer ' + token;
+ }
console.log("connect에서의 roomId: " + room.roomId);
- stompClient.value.connect({}, (frame) => {
+ // stompClient.value.connect({}, (frame) => {
+ stompClient.value.connect(headers, (frame) => {
console.log('Connected: ' + frame);
console.log('roomid value: ' + room.roomId);
+
+ // send to chatting room
stompClient.value.subscribe(`/sub/${room.roomId}`, (message) => {
showMessage(JSON.parse(message.body));
});
@@ -206,7 +216,6 @@
try {
console.log("Fetching message rooms...");
- console.log("Fetching에서의 roomId: " + room.roomId);
const response = await axios.get(`http://localhost:8080/api/v1/chat/${room.roomId}`
, {
headers: {
@@ -254,9 +263,6 @@
type: 'TALK'
};
- console.log("stompClient is alive?" + stompClient);
- console.log('Sending message:', JSON.stringify(sendMessage));
-
try {
await stompClient.value.send(`/pub/message/${roomId.value}`, {}, JSON.stringify(sendMessage));
messageInput.value = '';
@@ -298,8 +304,6 @@
});
};
-
-
// 컴포넌트가 마운트될 때 데이터 가져오기
onMounted(async () => {
console.log("Component is mounted. Now fetching chat rooms...");
diff --git a/src/views/navigation/Navigation.vue b/src/views/navigation/Navigation.vue
index d9e915d..21a273e 100644
--- a/src/views/navigation/Navigation.vue
+++ b/src/views/navigation/Navigation.vue
@@ -105,10 +105,14 @@
-
-
-