Browse Source

首页兼容小程序页面,部分细节未完善

master
mk 1 year ago
parent
commit
8d65ae82e1
  1. 64
      src/lib/components/chat/Header.svelte
  2. 38
      src/lib/components/chat/Messages.svelte
  3. 17
      src/lib/components/chat/Messages/Citations.svelte
  4. 14
      src/lib/components/chat/Placeholder.svelte
  5. BIN
      static/img/logo.gif
  6. BIN
      static/img/phone.png
  7. BIN
      static/img/phone/knowledge.png
  8. BIN
      static/img/phone/record.png
  9. BIN
      static/img/phone/work.png
  10. BIN
      static/img/phone/事件@2x.png
  11. BIN
      static/img/phone/加@2x.png
  12. BIN
      static/img/phone/历史消息-紫@2x.png
  13. BIN
      static/img/phone/历史消息@2x.png
  14. BIN
      static/img/phone/发送@2x.png
  15. BIN
      static/img/phone/图层 1493@2x.png
  16. BIN
      static/img/phone/工作任务_line@2x.png
  17. BIN
      static/img/phone/工作总结 @2x.png
  18. BIN
      static/img/phone/工作总结-绿@2x.png
  19. BIN
      static/img/phone/检索知识库-蓝@2x.png
  20. BIN
      static/img/phone/检索知识库@2x.png
  21. BIN
      static/img/phone/语音@2x.png

64
src/lib/components/chat/Header.svelte

@ -5,11 +5,15 @@
import {
showSidebar,
} from '$lib/stores';
import { t } from 'i18next';
// 判断是否为移动设备
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
let list = [
{
title: '工作',
bg: '/img/work.png',
bg: `/img${isMobile?'/phone':''}/work.png`,
id: '3',
title_color:'#40b0bb',
buttons: [
{
label: '工作总结',
@ -34,8 +38,9 @@
},
{
title: '知识库',
bg: '/img/knowledge.png',
bg: `/img${isMobile?'/phone':''}/knowledge.png`,
id: '2',
title_color:'#4ea2eb',
buttons: [
{
label: '检索知识库',
@ -52,8 +57,9 @@
},
{
title: '使用记录',
bg: '/img/record.png',
bg:`/img${isMobile?'/phone':''}/record.png`,
id: '1',
title_color:'#696ed0',
buttons: [
{
label: '历史消息',
@ -70,7 +76,6 @@
}
];
</script>
<div class="flex flex-col border-box header_box">
<div class="top flex">
<img src={'favicon.png'} alt="" class="w-16 h-16 mr-5" />
@ -79,24 +84,24 @@
<p class="text-gray-800 text-left text-base">需要我帮您做点什么?</p>
</div>
</div>
<div class="flex justify-around w-full mt-10">
<div class="flex main_box w-full {!isMobile?'mt-10':''}">
{#each list as item, itemIndex (item.id)}
<div
class="flex flex-col flex-1 mr-3 rounded-2xl p-6 box-border bg-cover"
class="flex flex-col flex-1 rounded-2xl {!isMobile?'p-6 mr-3 ':'p-2 mr-1.5 flex-1'} box-border bg-cover "
style="background-image: url('{item.bg}')"
>
<h2 class="text-gray-800 text-left text-2xl">{item.title}</h2>
<h2 class="text-gray-800 text-left {isMobile?'text-base':'text-2xl'}" style="color:{item.title_color};">{item.title}</h2>
{#if !isMobile}
<div>
{#each item.introduce as itemP, index (index)}
<p class="text-gray-500 text-left text-sm mt-1.5">{itemP.label}</p>
{/each}
</div>
<div class="flex mt-5.5">
{/if}
<div class="flex {!isMobile?'mt-5.5':'mt-12'}">
{#each item.buttons as but, index (index)}
<button
class="font-medium text-black text-base mr-4 bg-white rounded-2xl px-6 py-1 box-border flex items-center border {but.label === '历史消息'||but.label === '工作总结'?'mt-4.5':''} {but.active
? 'border-blue-500 text-blue-500'
: ''}"
class="font-medium text-black {!isMobile?' text-base px-6 py-1 mr-4':'text-xs px-1.5 py-0.5'} bg-white rounded-2xl box-border flex items-center border {(but.label === '历史消息'|| but.label === '工作总结') && !isMobile?'mt-4.5':''} " style="color:{but.active? item.title_color: ''},border-color:{but.active? item.title_color: ''}"
on:click={() => {
list.forEach((item) => {
item.buttons.forEach((c) => {
@ -107,7 +112,6 @@
c.active = !c.active
}else {
c.active = true;
}
}
});
@ -121,7 +125,7 @@
dispatch('savePlaceholder',but.placeholder || null)
}}
>
<img src={but.active ? but.imgActive : but.img} alt="" class="w-5 h-5 mr-1" />
<img src={but.active ? but.imgActive : but.img} alt="" class="{!isMobile?'w-5 h-5 mr-1':'w-3 h-3'}" />
{but.label}
</button>
{/each}
@ -144,4 +148,38 @@
position: relative;
bottom: 122px;
}
.main_box{
justify-content: space-around;
}
@media (max-width: 768px) {
.main_box{
justify-content: space-around;
}
.header_box {
height: auto;
padding: 20px;
width: 100%;
bottom: 0;
padding: 0;
}
.top {
display: none;
h1{
font-size: 25px;
}
}
.top img {
margin-bottom: 10px;
}
.flex.justify-around {
flex-direction: column;
}
.flex.justify-around > div {
margin-bottom: 20px;
}
}
</style>

38
src/lib/components/chat/Messages.svelte

@ -11,7 +11,7 @@
} from '$lib/stores';
import { tick, getContext, onMount, createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
import { toast } from 'svelte-sonner';
import { getChatList, updateChatById } from '$lib/apis/chats';
import { copyToClipboard, findWordIndices } from '$lib/utils';
@ -24,7 +24,7 @@
const i18n = getContext('i18n');
export let className = 'h-full flex pt-17';
export let className = 'h-full flex pt-17 bg-gray-50';
export let chatId = '';
export let user = $_user;
@ -344,7 +344,10 @@
}
};
</script>
<img src={'/img/messages.png'} style="position: absolute;top: 0;left:0;right:0;bottom:40%;z-index: 0;" alt="">
<img src={'/img/messages.png'} alt="">
<img src={'/img/phone.png'} alt="">
<img src={'/img/logo.gif'} alt="" style="position: absolute;top:51px;left:31px;z-index:2" class=" w-17.5 h-17.5" >
<div class={className } >
{#if Object.keys(history?.messages ?? {}).length == 0}
<ChatPlaceholder
@ -431,3 +434,32 @@
</div>
{/if}
</div>
<style lang="scss" scoped>
img[src="/img/messages.png"] {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 40%;
z-index: 0;
}
img[src="/img/phone.png"] {
display: none;
}
/* 手机端样式 */
@media (max-width: 768px) {
img[src="/img/messages.png"] {
display: none;
}
img[src="/img/phone.png"] {
position: absolute;
left: 0;
right: 0;
bottom: 40%;
z-index: 0;
display: block;
top: 25px;
object-fit: cover; /* 可以根据需要调整图片适配方式 */
}
}
</style>

17
src/lib/components/chat/Messages/Citations.svelte

@ -95,11 +95,9 @@
{showRelevance}
/>
{#if citations.length > 0}
<div class=" py-0.5 -mx-0.5 w-full flex gap-1 items-center flex-wrap">
{#if citations.length <= 3}
<div class="flex text-xs font-medium flex-wrap">
{#each citations as citation, idx}
<!-- {#each citations as citation, idx}
<button
id={`source-${id}-${idx}`}
class="no-toggle outline-hidden flex p-1 bg-white rounded-xl max-w-96"
@ -119,9 +117,8 @@
{citation.source.name}
</div>
</button>
{/each}
{/each} -->
</div>
{:else}
<Collapsible
id="collapsible-sources"
bind:open={isCollapsibleOpen}
@ -139,7 +136,7 @@
>
<div class="flex items-center overflow-auto scrollbar-none w-full max-w-full flex-1">
<div class="flex text-xs font-medium items-center">
{#each citations.slice(0, 2) as citation, idx}
<!-- {#each citations.slice(0, 2) as citation, idx}
<button
class="no-toggle outline-hidden flex p-1 bg-gray-50 hover:bg-gray-100 transition rounded-xl max-w-96"
on:click={() => {
@ -159,7 +156,7 @@
{citation.source.name}
</div>
</button>
{/each}
{/each} -->
</div>
</div>
<div class="flex items-center gap-1 whitespace-nowrap shrink-0">
@ -178,7 +175,7 @@
</div>
<div slot="content">
<div class="flex text-xs font-medium flex-wrap">
{#each citations as citation, idx}
<!-- {#each citations as citation, idx}
<button
id={`source-${id}-${idx}`}
class="no-toggle outline-hidden flex p-1 bg-gray-50 hover:bg-gray-100 transition rounded-xl max-w-96"
@ -196,10 +193,8 @@
{citation.source.name}
</div>
</button>
{/each}
{/each} -->
</div>
</div>
</Collapsible>
{/if}
</div>
{/if}

14
src/lib/components/chat/Placeholder.svelte

@ -6,6 +6,7 @@
import { blur, fade } from 'svelte/transition';
const dispatch = createEventDispatcher();
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
import { config, user, models as _models, temporaryChatEnabled } from '$lib/stores';
import { sanitizeResponseContent, findWordIndices } from '$lib/utils';
@ -88,7 +89,11 @@
onMount(() => {});
</script>
<div class="m-auto w-full max-w-6xl px-2 @2xl:px-20 translate-y-6 py-24 text-center">
<div class=" {!isMobile?'py-24 m-auto px-2 max-w-6xl':'h-full flex flex-col'} w-full @2xl:px-20 translate-y-6 text-center" >
{#if isMobile}
<img src={'/img/phone.png'} alt="" style="height:190px">
<img src={'/img/logo.gif'} alt="" style="position: absolute;top:31px;left:31px;z-index:2" class=" w-17.5 h-17.5" >
{/if}
{#if $temporaryChatEnabled}
<Tooltip
content="This chat won't appear in history and your messages will not be saved."
@ -102,17 +107,14 @@
{/if}
<div
class="w-full text-3xl text-gray-800 font-medium text-center flex items-center gap-4 font-primary"
class="w-full text-3xl text-gray-800 font-medium text-center flex items-center gap-4 font-primary {!isMobile?'':'flex-1 bg-white rounded-xl px-2 pt-2'}"
>
<div class="w-full flex flex-col justify-center items-center">
<div class="flex flex-row justify-center gap-3 @sm:gap-3.5 w-fit px-5">
<div class="w-full flex flex-col justify-between items-center h-full">
<Header
on:savePlaceholder={(val) => {
autofill = val.detail;
}}
></Header>
</div>
<div class="flex mt-1 mb-2">
<div in:fade={{ duration: 100, delay: 50 }}>
{#if models[selectedModelIdx]?.info?.meta?.description ?? null}

BIN
static/img/logo.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
static/img/phone.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

BIN
static/img/phone/knowledge.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
static/img/phone/record.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
static/img/phone/work.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
static/img/phone/事件@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/img/phone/加@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

BIN
static/img/phone/历史消息-紫@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
static/img/phone/历史消息@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
static/img/phone/发送@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
static/img/phone/图层 1493@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
static/img/phone/工作任务_line@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
static/img/phone/工作总结 @2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
static/img/phone/工作总结-绿@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

BIN
static/img/phone/检索知识库-蓝@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/img/phone/检索知识库@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/img/phone/语音@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Loading…
Cancel
Save