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