Files
what-to-eat/apps/web/app/adapters/feedback.ts
T
toor 8ff7b879b9 refactor: 个人自用,移除登录与云同步全链路
站点只给本人用,云乐坊 SSO 授权、收藏/历史云同步、获客归因和账号切换记账都没有收益,却被登录状态检查和同步失败提示持续打扰。

- 删除 useYunlefunAuth / yunlefunAuth / yunlefunSsoConfig / yunlefunAuth 适配器、useUserDataSync / userDataSync / userData 适配器、三个 client 插件与 /auth/callback 回调页
- 抽出 adapters/cloudbase.ts,让「反馈一下」和匿名筛选信号不再依赖登录态;cook-feedback 云函数保留
- 删除 cook-user-data 云函数与 cook_user_data 权限规则,移除 @yunlefun/sso 依赖
- 「我的」页删掉登录按钮、账号卡、四个统计格和退出登录;「关于」页删掉项目作者、致谢名单和上游宣传链接
- 本地收藏/历史与导出导入保留,删除同步专用的 lastUid 记账

取舍见 docs/decisions/0005-drop-login-and-sync.md
2026-10-22 15:52:54 +08:00

44 lines
1.2 KiB
TypeScript

import type { CloudbaseFunctionCaller } from './cloudbase'
export const FEEDBACK_FUNCTION = 'cook-feedback'
export type FeedbackKind = 'video' | 'stuff' | 'info' | 'other'
export interface RecipeReport {
recipeId: number
recipeName: string
kind: FeedbackKind
note?: string
}
export interface SearchSignal {
type: 'empty' | 'open'
stuff: string[]
tool?: string
mode?: string
recipeId?: number
rank?: number
}
interface FunctionResult {
code?: string
ok?: boolean
}
/**
* Talks to the `cook-feedback` cloud function. Callers are anonymous: the
* function falls back to the random device id to deduplicate and rate limit.
*/
export function createFeedbackRemote(callFunction: CloudbaseFunctionCaller, deviceId: string) {
async function call(data: Record<string, unknown>): Promise<void> {
const result = await callFunction(FEEDBACK_FUNCTION, { ...data, deviceId }) as FunctionResult | null
if (!result || result.ok !== true)
throw new Error(`${FEEDBACK_FUNCTION} failed: ${result?.code ?? 'unknown'}`)
}
return {
report: (report: RecipeReport) => call({ action: 'report', ...report }),
signal: (signal: SearchSignal) => call({ action: 'signal', ...signal }),
}
}