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
This commit is contained in:
@@ -4,7 +4,7 @@ import { namespace } from '~/constants'
|
||||
|
||||
export type { CustomRecipe }
|
||||
|
||||
// 和收藏、历史一样始终保存在本机;不参与云同步
|
||||
// 和收藏、历史一样始终保存在本机
|
||||
export const customRecipes = useStorage<CustomRecipe[]>(`${namespace}:custom-recipes`, [])
|
||||
|
||||
export function getCustomRecipe(customId: string) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { UserData, UserDataExportFile } from '~/utils/userData'
|
||||
import type { UserDataLocal } from '~/utils/userDataSync'
|
||||
import {
|
||||
createEmptyUserData,
|
||||
createUserDataExport,
|
||||
@@ -32,22 +31,12 @@ export function writeLocalUserData(data: UserData): void {
|
||||
}
|
||||
}
|
||||
|
||||
export const localUserData: UserDataLocal = {
|
||||
read: readLocalUserData,
|
||||
write: writeLocalUserData,
|
||||
readLastUid: () => userDataMeta.value.lastUid ?? '',
|
||||
writeLastUid: (uid) => {
|
||||
if (userDataMeta.value.lastUid !== uid)
|
||||
userDataMeta.value = { ...userDataMeta.value, lastUid: uid }
|
||||
},
|
||||
}
|
||||
|
||||
export function exportLocalUserData(now = Date.now()): UserDataExportFile {
|
||||
return createUserDataExport(mergeUserData(readLocalUserData(), createEmptyUserData(), now), now)
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge an exported file into local data, using the same rules as cloud sync.
|
||||
* Merge an exported file into local data.
|
||||
* Returns null when the text is not a Cook export.
|
||||
*/
|
||||
export function importLocalUserData(text: string, now = Date.now()): { favorites: number, histories: number } | null {
|
||||
|
||||
@@ -3,21 +3,18 @@ import { useStorage } from '@vueuse/core'
|
||||
import { namespace } from '~/constants'
|
||||
|
||||
/**
|
||||
* Sync bookkeeping kept next to `cook:favorites` and `cook:history`, which stay
|
||||
* in their original format. Deletions are recorded even when logged out so they
|
||||
* can be applied to the cloud after the next login.
|
||||
* Deletion bookkeeping kept next to `cook:favorites` and `cook:history`, which
|
||||
* stay in their original format. Deletions are recorded so they survive an
|
||||
* export/import round trip instead of resurrecting removed records.
|
||||
*/
|
||||
export interface UserDataMeta {
|
||||
favoriteRemovals: FavoriteRemoval[]
|
||||
historyRemovals: HistoryRemoval[]
|
||||
historyClearedAt: number
|
||||
/** The account this device last synced with. */
|
||||
lastUid: string
|
||||
}
|
||||
|
||||
export const userDataMeta = useStorage<UserDataMeta>(`${namespace}:sync`, {
|
||||
favoriteRemovals: [],
|
||||
historyRemovals: [],
|
||||
historyClearedAt: 0,
|
||||
lastUid: '',
|
||||
}, undefined, { mergeDefaults: true })
|
||||
|
||||
Reference in New Issue
Block a user