|
31 | 31 | import axios from 'axios'; |
32 | 32 | import 'prismjs/themes/prism.css'; // Choose a theme you like |
33 | 33 | import { v4 as uuidv4 } from 'uuid'; |
34 | | - import { inject } from 'vue'; |
| 34 | + import { inject, computed } from 'vue'; |
35 | 35 | import { obpApiHostKey } from '@/obp/keys'; |
36 | 36 | import { getCurrentUser } from '../obp'; |
37 | 37 | import { getOpeyJWT, getobpConsent, answerobpConsentChallenge } from '@/obp/common-functions' |
|
40 | 40 | import { useConnectionStore } from '@/stores/connection'; |
41 | 41 | import { useChatStore } from '@/stores/chat'; |
42 | 42 | import { ElMessage } from 'element-plus'; |
| 43 | + import { useRoute } from 'vue-router'; |
43 | 44 |
|
44 | 45 | import 'prismjs/components/prism-markup'; |
45 | 46 | import 'prismjs/components/prism-javascript'; |
|
73 | 74 |
|
74 | 75 | const { isConnected } = storeToRefs(connectionStore); |
75 | 76 |
|
76 | | - return {isStreaming, chatMessages, lastError, currentMessageSnapshot, chatStore, connectionStore} |
| 77 | + const route = useRoute(); |
| 78 | + const loginUrl = computed(() => { |
| 79 | + const currentPath = route.path; |
| 80 | + const queryString = new URLSearchParams(route.query as Record<string, string>).toString(); |
| 81 | + const fullPath = queryString ? `${currentPath}?${queryString}` : currentPath; |
| 82 | + return `/api/oauth2/connect?redirect=${encodeURIComponent(fullPath)}`; |
| 83 | + }); |
| 84 | +
|
| 85 | + return {isStreaming, chatMessages, lastError, currentMessageSnapshot, chatStore, connectionStore, loginUrl} |
77 | 86 | }, |
78 | 87 | data() { |
79 | 88 | return { |
|
378 | 387 |
|
379 | 388 | </div> |
380 | 389 | <div v-else class="chat-messages"> |
381 | | - <p>Opey is only availabled when logged in. <a v-bind:href="'/api/oauth2/connect'">Log In</a> </p> |
| 390 | + <p>Opey is only availabled when logged in. <a v-bind:href="loginUrl">Log In</a> </p> |
382 | 391 | </div> |
383 | 392 | <el-alert |
384 | 393 | v-if="this.errorState" |
|
0 commit comments