-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from qianmoQ/feature-dev
[Chat] Add Resizable chat
- Loading branch information
Showing
22 changed files
with
701 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script setup lang="ts"> | ||
import { type HTMLAttributes, computed } from 'vue' | ||
import { SplitterResizeHandle, type SplitterResizeHandleEmits, type SplitterResizeHandleProps, useForwardPropsEmits } from 'radix-vue' | ||
import { DragHandleDots2Icon } from '@radix-icons/vue' | ||
import { cn } from '@/lib/utils' | ||
const props = defineProps<SplitterResizeHandleProps & { class?: HTMLAttributes['class'], withHandle?: boolean }>() | ||
const emits = defineEmits<SplitterResizeHandleEmits>() | ||
const delegatedProps = computed(() => { | ||
const { class: _, ...delegated } = props | ||
return delegated | ||
}) | ||
const forwarded = useForwardPropsEmits(delegatedProps, emits) | ||
</script> | ||
|
||
<template> | ||
<SplitterResizeHandle v-bind="forwarded" :class="cn('relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 [&[data-orientation=vertical]]:h-px [&[data-orientation=vertical]]:w-full [&[data-orientation=vertical]]:after:left-0 [&[data-orientation=vertical]]:after:h-1 [&[data-orientation=vertical]]:after:w-full [&[data-orientation=vertical]]:after:-translate-y-1/2 [&[data-orientation=vertical]]:after:translate-x-0 [&[data-orientation=vertical]>div]:rotate-90', props.class)"> | ||
<template v-if="props.withHandle"> | ||
<div class="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border"> | ||
<DragHandleDots2Icon class="h-2.5 w-2.5" /> | ||
</div> | ||
</template> | ||
</SplitterResizeHandle> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script setup lang="ts"> | ||
import { type HTMLAttributes, computed } from 'vue' | ||
import { SplitterGroup, type SplitterGroupEmits, type SplitterGroupProps, useForwardPropsEmits } from 'radix-vue' | ||
import { cn } from '@/lib/utils' | ||
const props = defineProps<SplitterGroupProps & { class?: HTMLAttributes['class'] }>() | ||
const emits = defineEmits<SplitterGroupEmits>() | ||
const delegatedProps = computed(() => { | ||
const { class: _, ...delegated } = props | ||
return delegated | ||
}) | ||
const forwarded = useForwardPropsEmits(delegatedProps, emits) | ||
</script> | ||
|
||
<template> | ||
<SplitterGroup v-bind="forwarded" :class="cn('flex h-full w-full data-[panel-group-direction=vertical]:flex-col', props.class)"> | ||
<slot /> | ||
</SplitterGroup> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as ResizablePanelGroup } from './ResizablePanelGroup.vue' | ||
export { default as ResizableHandle } from './ResizableHandle.vue' | ||
export { SplitterPanel as ResizablePanel } from 'radix-vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<Avatar> | ||
<AvatarImage :src="src as string" :alt="alt as string" :width="width" :height="height" :class="imageClass"/> | ||
<AvatarFallback>{{ alt }}</AvatarFallback> | ||
</Avatar> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' | ||
export default defineComponent({ | ||
name: 'IAvatar', | ||
components: { | ||
Avatar, AvatarImage, AvatarFallback | ||
}, | ||
props: { | ||
src: { | ||
type: String | ||
}, | ||
alt: { | ||
type: String | ||
}, | ||
width: { | ||
type: Number, | ||
default: 32 | ||
}, | ||
height: { | ||
type: Number, | ||
default: 32 | ||
}, | ||
imageClass: { | ||
type: String, | ||
default: '' | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<TooltipProvider :delay-duration="duration"> | ||
<Tooltip> | ||
<TooltipTrigger as-child> | ||
<slot/> | ||
</TooltipTrigger> | ||
<TooltipContent :side="side as any"> | ||
<p v-if="content">{{ content }}</p> | ||
<slot v-else name="content"/> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' | ||
export default defineComponent({ | ||
name: 'ITooltip', | ||
components: { | ||
Tooltip, TooltipContent, TooltipProvider, TooltipTrigger | ||
}, | ||
props: { | ||
content: { | ||
type: String | ||
}, | ||
duration: { | ||
type: Number, | ||
default: 0 | ||
}, | ||
side: { | ||
type: String, | ||
default: 'top' | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<div class="flex flex-1 flex-col"> | ||
<div class="flex flex-1 flex-col gap-4 p-4 md:gap-8 md:p-8"> | ||
<Card> | ||
<CardHeader class="flex flex-row items-center justify-between"> | ||
<template #title> | ||
<div class="flex items-center space-x-4"> | ||
<Avatar> | ||
<AvatarImage alt="SUA" src="https://www.shadcn-vue.com/avatars/01.png"/> | ||
|
@@ -13,6 +13,8 @@ | |
<p class="text-sm text-muted-foreground">[email protected]</p> | ||
</div> | ||
</div> | ||
</template> | ||
<template #extra> | ||
<TooltipProvider> | ||
<Tooltip :delay-duration="200"> | ||
<TooltipTrigger as-child> | ||
|
@@ -23,25 +25,24 @@ | |
<TooltipContent :side-offset="10">{{ $t('common.common.newMessage') }}</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
</CardHeader> | ||
<Separator/> | ||
<CardContent class="mt-3"> | ||
</template> | ||
<div class="mt-3 mb-3"> | ||
<div class="space-y-4"> | ||
<div v-for="(message, index) in messages" :key="index" | ||
:class="cn( 'flex w-max max-w-[75%] flex-col gap-2 rounded-lg px-3 py-2 text-sm', message.role === 'user' ? 'ml-auto bg-primary text-primary-foreground' : 'bg-muted')"> | ||
{{ `${message.content} ${index + 1}` }} | ||
{{ `${ message.content } ${ index + 1 }` }} | ||
</div> | ||
</div> | ||
</CardContent> | ||
<CardFooter> | ||
</div> | ||
<template #footer> | ||
<form class="flex w-full items-center space-x-2" @submit.prevent="handlerSubmit"> | ||
<Input v-model="inputValue as string" :placeholder="$t('common.tip.inputMessage')" class="flex-1"/> | ||
<Button class="p-2.5 flex items-center justify-center" :disabled="!inputValue"> | ||
<Send class="w-4 h-4"/> | ||
<span class="sr-only">{{ $t('common.common.send') }}</span> | ||
</Button> | ||
</form> | ||
</CardFooter> | ||
</template> | ||
</Card> | ||
</div> | ||
<ChatUser :visible="visible" @close="visible = $event"/> | ||
|
@@ -50,24 +51,24 @@ | |
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card' | ||
import Card from '@/ui/card/card.vue' | ||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' | ||
import { Button } from '@/components/ui/button' | ||
import { Input } from '@/components/ui/input' | ||
import { cn } from '@/lib/utils' | ||
import { cn } from '@/lib/utils.ts' | ||
import { PlusIcon, Send } from 'lucide-vue-next' | ||
import { createMessages } from '@/views/pages/chat/ChatUtils' | ||
import { createMessages } from '@/views/pages/chat/basic/ChatUtils.ts' | ||
import { useI18n } from 'vue-i18n' | ||
import { Separator } from '@/components/ui/separator' | ||
import ChatUser from '@/views/pages/chat/components/ChatUser.vue' | ||
import ChatUser from '@/views/pages/chat/basic/components/ChatUser.vue' | ||
export default defineComponent({ | ||
name: 'ChatHome', | ||
components: { | ||
ChatUser, | ||
Separator, | ||
Card, CardContent, CardFooter, CardHeader, | ||
Card, | ||
Avatar, AvatarFallback, AvatarImage, | ||
Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, | ||
Button, | ||
|
File renamed without changes.
Oops, something went wrong.