feat: friends

This commit is contained in:
dylanmay
2023-09-20 17:51:50 +08:00
parent e3f8a3a94b
commit 5b8b51a894
7 changed files with 169 additions and 7 deletions

View File

@ -0,0 +1,42 @@
import { defineStore } from 'pinia'
import BaseConversation from '../model/BaseConversation'
import Friend from '../model/Friend'
interface FriendStoreModel {
friendList: Array<Friend>
}
export const useFriendStore = defineStore('friendStore', {
state: (): FriendStoreModel => ({
friendList: [
{
id: '1111',
name: 'Elon Musk',
avatar:
'https://img0.baidu.com/it/u=4211304696,1059959254&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=1174',
description: 'cool boy',
createTime: 1695201147622
},
{
id: '2222',
name: 'Spider Man',
avatar:
'https://www.hottoys.com.cn/wp-content/uploads/2019/06/bloggerreview_spiderman_advanced_ben-9.jpg',
description: 'hero',
createTime: 1695201147622
}
]
}),
getters: {
getFriendList(state: FriendStoreModel): Array<Friend> {
return state.friendList
}
},
actions: {
addSession(session: BaseConversation) {
this.friendList.push(session)
}
}
})