Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
feat: sync title
Browse files Browse the repository at this point in the history
  • Loading branch information
Wen-ace committed Mar 24, 2024
1 parent a749337 commit c1f6a99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion components/ui-components/tickets/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ const getTicketChatList = (id: string) => {
})
}
const ticketsStore = useTicketStore()
const title = computed(() => {
return ticketsStore.currentTicket.name
})
watch(() => ticketsStore.currentSessionId, (id) => {
if (id) {
Expand All @@ -125,7 +128,7 @@ watch(() => ticketsStore.currentSessionId, (id) => {

<template>
<div class="w-full h-full shadow-light-50 shadow-right relative">
<div class="bg-white px-2 py-4 border-b-gray-300 border-b-1">message</div>
<div class="bg-white px-2 py-4 border-b-gray-300 border-b-1">{{ title || 'message' }}</div>
<div class="relative chat-area h-full overflow-auto" ref="chatAreaRef">
<div class="w-full h-full p-2">
<div class="pb-27" ref="messageRef">
Expand Down
1 change: 1 addition & 0 deletions components/ui-components/tickets/TicketCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const isActive = computed(() => {
const onTicketClick = (id: string) => {
// getTicketChatList(id)
ticketsStore.currentSessionId = id
ticketsStore.setCurrentTicket({ ...props.data, })
}
</script>
Expand Down
8 changes: 8 additions & 0 deletions store/ticket.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { defineStore } from 'pinia'
type ITicket = {
id: number,
name: string
}

export const useTicketStore = defineStore('ticket', {
state: () => {
return {
currentTicket: {} as ITicket,
currentSessionId: '',
}
},
actions: {

setCurrentTicket(data: ITicket) {
this.$state.currentTicket = data
}
},
})
4 changes: 3 additions & 1 deletion tools/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ const URL_PREFIX = '/api'

export default (url: string, options?: Partial<RequestInit>) => {
url = URL_PREFIX + url
return fetch(url, options)
return fetch(url, options).catch((error) => {
console.warn('error :>> ', error);
})
}

0 comments on commit c1f6a99

Please sign in to comment.