pnpm-系统信息同步
This commit is contained in:
parent
5f061ddf14
commit
3f8a11e1e0
@ -5,6 +5,7 @@ import { conversationMapSortList } from '@/stores/conversation'
|
||||
import ConversationSidebarItem from './ConversationSidebarItem'
|
||||
import ConversationSidebarAdd from './ConversationSidebarAdd'
|
||||
import { addConversation } from '@/stores/conversation'
|
||||
import { showConversationEditModal } from '@/stores/ui'
|
||||
|
||||
export default () => {
|
||||
const { t } = useI18n()
|
||||
@ -21,10 +22,9 @@ export default () => {
|
||||
let num = seachText[0].match(/\(\d+\)/g) || 'null'
|
||||
if (num !== 'null') {
|
||||
count = Math.max(count, Number(num[0].replace('(', '').replace(')', '')))
|
||||
console.log(count, Number(num[0].replace('(', '').replace(')', '')))
|
||||
}
|
||||
})
|
||||
title =count?`${setName}(${count + 1})`:`${setName}`
|
||||
title =count?`${setName}(${count + 1})`:`${setName}${numList.length>0?'(1)':''}`
|
||||
return title
|
||||
}
|
||||
|
||||
@ -46,7 +46,8 @@ export default () => {
|
||||
})
|
||||
|
||||
if(setName.switch){
|
||||
addConversation({name:setNameNum(setName.name, numList)})
|
||||
addConversation({name:setNameNum(setName.name, numList),systemInfo:setName.systemInfo})
|
||||
showConversationEditModal.set(true)
|
||||
setName.switch=false
|
||||
sessionStorage.setItem('dialogueName',JSON.stringify({name:setName.name,switch:false}))
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ interface Data {}
|
||||
interface ResponseData {
|
||||
code: number;
|
||||
message: string;
|
||||
data: Array;
|
||||
data: any;
|
||||
url: string;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import { fetchData } from '../../../http/api'
|
||||
export default () => {
|
||||
// dataItemLists.set([{id:'1'},{id:'2'},{id:'3'},{id:'4'},{id:'5'},{id:'6'}])
|
||||
const [list, setList] = createStore({
|
||||
data: [{ id: '1', Topping: false }, { id: '2', Topping: false }, { id: '3', Topping: false }, { id: '4', Topping: false }, { id: '5', Topping: false }, { id: '6', Topping: false }]
|
||||
data: [{title:''}]
|
||||
})
|
||||
|
||||
type errorObj = {
|
||||
@ -25,12 +25,17 @@ export default () => {
|
||||
fetchData({}, function (data) {
|
||||
if (data.code === 200) {
|
||||
setList('data', () => [...data.data])
|
||||
} else {
|
||||
setErrorFun(data.message)
|
||||
}
|
||||
}, '/chat/api', 'GET');
|
||||
}
|
||||
|
||||
//标题
|
||||
let dialogueName = ''
|
||||
let dialogue = {
|
||||
systemmessage:'',
|
||||
title:''
|
||||
}
|
||||
|
||||
//新建对话框
|
||||
const newlyAdded = () => {
|
||||
@ -64,20 +69,21 @@ export default () => {
|
||||
let [pop, setPop] = createSignal(false)
|
||||
let [popType, setPopType] = createSignal('open')
|
||||
|
||||
const popShow = (type: string, e: any, key: number, name: string = '未命名对话') => {
|
||||
const popShow = (type: string, e: any, key: number, dialogueObj: any = {}) => {
|
||||
setPopType(type)
|
||||
if (type == 'delete') {
|
||||
deleteItem['key'] = key as any
|
||||
deleteItem['e'] = e
|
||||
}
|
||||
if (type === 'open') dialogueName = name
|
||||
if (type === 'open') dialogue = dialogueObj
|
||||
setPop(!pop())
|
||||
}
|
||||
|
||||
//确认按钮
|
||||
const determineBtn = () => {
|
||||
if (popType() === 'open') {
|
||||
sessionStorage.setItem('dialogueName', JSON.stringify({ name: dialogueName, switch: true }))
|
||||
console.log(dialogue)
|
||||
sessionStorage.setItem('dialogueName', JSON.stringify({ name: dialogue.title, switch: true,systemInfo:dialogue.systemmessage }))
|
||||
if (isMobile()) {
|
||||
location.pathname = '/'
|
||||
} else {
|
||||
@ -91,6 +97,7 @@ export default () => {
|
||||
|
||||
//显示错误提示
|
||||
const setErrorFun = (message: string) => {
|
||||
// console.log(message)
|
||||
setErrorShow({
|
||||
message,
|
||||
show: true
|
||||
@ -147,7 +154,9 @@ export default () => {
|
||||
<div class="px-2">
|
||||
<For each={list.data}>
|
||||
{(instance, i) => (
|
||||
<Show when={instance.title}>
|
||||
<ConversationSidebarItem popShow={popShow} setErrorFun={setErrorFun} instanceData={{ ...instance }} infoList={list.data} key={i as any} setList={setList} />
|
||||
</Show>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
|
@ -8,9 +8,10 @@ type dataList = {
|
||||
}
|
||||
|
||||
interface Props {
|
||||
instanceData: Omit<dataList, 'messages'> & {
|
||||
instanceData: {
|
||||
title?:string,
|
||||
istop?:number
|
||||
istop?:number,
|
||||
uniqid?:string
|
||||
},
|
||||
key: any,
|
||||
setList: Function,
|
||||
@ -23,7 +24,7 @@ export default ({ instanceData, key, setList, infoList, popShow,setErrorFun }: P
|
||||
|
||||
//设置数据
|
||||
const instanceItem = instanceData
|
||||
let instance = instanceItem || { id: '', name: '' }
|
||||
let instance = instanceItem || { id: '', name: '',uniqid:'' }
|
||||
const isTouchDevice = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
|
||||
|
||||
//置顶数据排序
|
||||
@ -71,7 +72,7 @@ export default ({ instanceData, key, setList, infoList, popShow,setErrorFun }: P
|
||||
class={[
|
||||
'group fi h-10 my-0.5 px-2 gap-2 hv-base rounded-md'
|
||||
].join(' ')}
|
||||
|
||||
onClick={()=>window.open(`${location.protocol}//${window.location.host}/share/?id=${ instance.uniqid }`)}
|
||||
>
|
||||
<div class="fcc w-8 h-8 rounded-full text-xl shrink-0">
|
||||
<div class="text-base i-carbon-chat" />
|
||||
@ -81,7 +82,7 @@ export default ({ instanceData, key, setList, infoList, popShow,setErrorFun }: P
|
||||
<div class={[isTouchDevice ? '' : 'hidden group-hover:block'].join('')}>
|
||||
<div
|
||||
class="inline-flex p-2 items-center gap-1 rounded-md hv-base"
|
||||
onClick={() => popShow('open', null, null, instance.title)}
|
||||
onClick={(e) => {popShow('open', null, null, instance);e.stopPropagation()}}
|
||||
>
|
||||
<div class='add-new-icon'></div>
|
||||
</div>
|
||||
@ -99,7 +100,7 @@ export default ({ instanceData, key, setList, infoList, popShow,setErrorFun }: P
|
||||
<div class={isTouchDevice ? '' : 'hidden group-hover:block'}>
|
||||
<div
|
||||
class="inline-flex p-2 items-center gap-1 rounded-md hv-base"
|
||||
onClick={e => popShow('delete', e, key())}
|
||||
onClick={e => {popShow('delete', e, key());e.stopPropagation()}}
|
||||
>
|
||||
<div class="i-carbon-close" />
|
||||
</div>
|
||||
|
@ -55,6 +55,7 @@ export const rebuildConversationStore = async() => {
|
||||
}
|
||||
|
||||
export const addConversation = action(conversationMap, 'addConversation', (map, instance?: Partial<Conversation>) => {
|
||||
console.log(conversationMap,instance)
|
||||
const instanceId = instance?.id || `id_${Date.now()}`
|
||||
const conversation: Conversation = {
|
||||
id: instanceId,
|
||||
@ -62,6 +63,7 @@ export const addConversation = action(conversationMap, 'addConversation', (map,
|
||||
name: instance?.name || '',
|
||||
icon: instance?.icon || '',
|
||||
lastUseTime: Date.now(),
|
||||
systemInfo:instance?.systemInfo
|
||||
}
|
||||
map.setKey(instanceId, conversation)
|
||||
db.setItem(instanceId, conversation)
|
||||
|
Loading…
x
Reference in New Issue
Block a user