Files
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

195 lines
5.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { defineNuxtConfig } from 'nuxt/config'
import { simpleGit } from 'simple-git'
// import { pwa } from './app/config/pwa'
import { appDescription } from './app/constants/index'
// for cloudflare
// Object.assign(process.env, {
// VITE_COMMIT_REF: process.env.CF_PAGES_COMMIT_SHA || '',
// })
/**
* Get git repo latest commit
*/
async function getLatestCommit() {
const git = simpleGit()
try {
const log = await git.log({ maxCount: 1 })
return log.latest
}
catch (error) {
console.error('Error fetching latest commit:', error)
return null
}
}
try {
const latestCommit = await getLatestCommit()
/**
* CF_PAGES_COMMIT_SHA is Cloudflare Pages env
*/
process.env.VITE_COMMIT_REF = process.env.CF_PAGES_COMMIT_SHA || latestCommit?.hash || ''
// add build date string to env
process.env.VITE_APP_BUILD_DATE = latestCommit?.date || new Date().toString()
}
catch (e) {
console.error('Not in git repo, get latest commit failed:', e)
process.env.VITE_APP_BUILD_DATE = new Date().toString()
process.env.VITE_COMMIT_REF = ''
}
/**
* @ionic/core 没有声明 sideEffects,@ionic/vue 引用的每个组件模块即使没用到也会被打进首屏 chunk。
* 组件模块只在调用 defineCustomElement 时才注册元素,标记为无副作用后,未使用的组件可以被摇树移除。
*/
const IONIC_COMPONENT_MODULE_RE = /[\\/]@ionic[\\/]core[\\/]components[\\/]ion-[\w-]+\.js$/
export default defineNuxtConfig({
modules: [
'@vueuse/nuxt',
'@unocss/nuxt',
'@pinia/nuxt',
'@nuxtjs/color-mode',
// '@vite-pwa/nuxt',
'@nuxt/eslint',
'@nuxt/test-utils/module',
// fix QQ in iOS, Done
// See https://github.com/unjs/ofetch/pull/366
// 'nuxt-fix-ofetch',
'@nuxt/scripts',
'@nuxtjs/ionic',
],
ssr: false,
components: [
{ path: '~/components', pathPrefix: false },
],
devtools: {
enabled: true,
},
app: {
head: {
// Mask replay text, including account details and user-created recipes.
bodyAttrs: { 'data-clarity-mask': 'true' },
viewport: 'width=device-width,initial-scale=1',
link: [
{ rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' },
{ rel: 'apple-touch-icon', href: '/apple-touch-icon.png' },
],
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, viewport-fit=cover' },
{ name: 'description', content: appDescription },
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
{ name: 'color-scheme', content: 'light dark' },
// 与 iOS 模式的页面 / 导航栏背景一致
{ name: 'theme-color', media: '(prefers-color-scheme: light)', content: '#f2f2f6' },
{ name: 'theme-color', media: '(prefers-color-scheme: dark)', content: '#000000' },
],
script: [
// 系统开启「减弱动态效果」时关闭 Ionic 的转场动画;需要在 Ionic 初始化前写入 window.Ionic.config
{ innerHTML: 'try{if(matchMedia("(prefers-reduced-motion: reduce)").matches)window.Ionic={config:{animated:false}}}catch(e){}' },
],
},
},
css: [
'@unocss/reset/tailwind.css',
'~/styles/css-vars.scss',
'~/styles/index.scss',
'~/styles/index.ts',
],
router: {
options: {
scrollBehaviorType: 'smooth',
},
},
colorMode: {
classSuffix: '',
},
spaLoadingTemplate: 'spa-loading-template.html',
runtimeConfig: {
public: {
clarityProjectId: process.env.NUXT_PUBLIC_CLARITY_PROJECT_ID ?? 'ks1ebw03i5',
clarityDomains: process.env.NUXT_PUBLIC_CLARITY_DOMAINS ?? 'cook.yunyoujun.cn,cook.yunle.fun',
// CloudBase 环境,用于「反馈一下」和匿名筛选信号;不涉及任何账号体系。
yunlefunCloudbaseEnv: process.env.NUXT_PUBLIC_YUNLEFUN_CLOUDBASE_ENV || 'yunlefun-8g7ybcxc7345c490',
},
},
alias: {
'@cook/data': fileURLToPath(new URL('../../packages/data', import.meta.url)),
'@cook/types': fileURLToPath(new URL('../../packages/cook/src/types', import.meta.url)),
// Use browser-safe source in the workspace, without requiring a package build first.
'@yunyoujun/cook/recommend': fileURLToPath(new URL('../../packages/cook/src/utils/recommend.ts', import.meta.url)),
},
future: {
compatibilityVersion: 4,
},
experimental: {
// when using generate, payload js assets included in sw precache manifest
// but missing on offline, disabling extraction it until fixed
payloadExtraction: false,
renderJsonPayloads: true,
typedPages: true,
},
compatibilityDate: '2025-05-15',
nitro: {
esbuild: {
options: {
target: 'esnext',
},
},
prerender: {
crawlLinks: false,
routes: ['/', '/random', '/help', '/user', '/404', '/settings'],
ignore: ['/hi'],
},
},
vite: {
plugins: [
{
name: 'cook:ionic-components-tree-shaking',
transform(_code, id) {
if (IONIC_COMPONENT_MODULE_RE.test(id))
return { moduleSideEffects: false }
},
},
],
},
eslint: {
config: {
standalone: false,
nuxt: {
sortConfigKeys: true,
},
},
},
ionic: {
css: {
core: true,
basic: true,
utilities: true,
},
config: {
mode: 'ios',
backButtonText: '返回',
},
},
// pwa,
})