fix: collection name mismatch, login/register navigation, and connection config
- Fix teamSessions → team_sessions to match PocketBase collection name - Replace <a @click> with <router-link> in Login and Register views - Update PocketBase default URL and vite proxy target - Comment out docker-compose user directive for permission fix Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// src/api/pocketbase.ts
|
||||
import PocketBase from 'pocketbase'
|
||||
|
||||
const pbUrl = import.meta.env.VITE_PB_URL || '/api'
|
||||
const pbUrl = import.meta.env.VITE_PB_URL || 'http://localhost:8090'
|
||||
|
||||
export const pb = new PocketBase(pbUrl)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function createTeamSession(data: {
|
||||
gameName: string
|
||||
members: string[]
|
||||
}): Promise<TeamSession> {
|
||||
return pb.collection('teamSessions').create({
|
||||
return pb.collection('team_sessions').create({
|
||||
...data,
|
||||
status: 'recruiting'
|
||||
}) as unknown as TeamSession
|
||||
@@ -20,7 +20,7 @@ export async function getActiveTeamSession(): Promise<TeamSession | null> {
|
||||
const user = pb.authStore.model
|
||||
if (!user) return null
|
||||
|
||||
const result = await pb.collection('teamSessions').getList(1, 1, {
|
||||
const result = await pb.collection('team_sessions').getList(1, 1, {
|
||||
filter: `members ~ "${user.id}" && status != "dissolved" && status != "finished"`,
|
||||
sort: '-created'
|
||||
})
|
||||
@@ -30,7 +30,7 @@ export async function getActiveTeamSession(): Promise<TeamSession | null> {
|
||||
|
||||
// 获取群组的临时小组列表
|
||||
export async function getGroupTeamSessions(groupId: string): Promise<TeamSession[]> {
|
||||
const result = await pb.collection('teamSessions').getList(1, 20, {
|
||||
const result = await pb.collection('team_sessions').getList(1, 20, {
|
||||
filter: `sourceGroup="${groupId}"`,
|
||||
sort: '-created'
|
||||
})
|
||||
@@ -46,7 +46,7 @@ export async function updateTeamStatus(sessionId: string, status: TeamStatus): P
|
||||
updateData.dissolvedAt = new Date().toISOString()
|
||||
}
|
||||
|
||||
return pb.collection('teamSessions').update(sessionId, updateData) as unknown as TeamSession
|
||||
return pb.collection('team_sessions').update(sessionId, updateData) as unknown as TeamSession
|
||||
}
|
||||
|
||||
// 结束游戏(解散临时小组)
|
||||
@@ -59,21 +59,21 @@ export async function joinTeamSession(sessionId: string) {
|
||||
const user = pb.authStore.model
|
||||
if (!user) throw new Error('未登录')
|
||||
|
||||
const session = await pb.collection('teamSessions').getOne(sessionId) as { members: string[] }
|
||||
const session = await pb.collection('team_sessions').getOne(sessionId) as { members: string[] }
|
||||
const members = session.members as string[]
|
||||
|
||||
if (members.includes(user.id)) {
|
||||
throw new Error('已在小组中')
|
||||
}
|
||||
|
||||
return pb.collection('teamSessions').update(sessionId, {
|
||||
return pb.collection('team_sessions').update(sessionId, {
|
||||
members: [...members, user.id]
|
||||
})
|
||||
}
|
||||
|
||||
// 订阅临时小组变更
|
||||
export function subscribeTeamSession(sessionId: string, callback: (session: TeamSession) => void) {
|
||||
return pb.collection('teamSessions').subscribe('*', (payload) => {
|
||||
return pb.collection('team_sessions').subscribe('*', (payload) => {
|
||||
if (payload.record.id === sessionId) {
|
||||
callback(payload.record as unknown as TeamSession)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user