refactor: 只保留 Web,移除 Capacitor 原生壳

删除 android/、ios/ 两个 Capacitor 原生工程与 capacitor.config.ts、
ionic.config.json,以及 scripts/android、scripts/ios.sh 构建脚本;
根与 apps/web 的 @capacitor/* 依赖和相关 npm scripts 一并移除。

Web 侧去掉原生分支:登录只走云乐坊容器授权面板或顶层重定向,
暗色模式不再改原生状态栏,移除 Android 物理返回键处理。

保留 @nuxtjs/ionic(Web UI 框架)、云乐坊 window.ylf 桥接与 PWA。

决策记录见 docs/decisions/0004-web-only.md。
This commit is contained in:
toor
2026-10-21 12:27:50 +08:00
committed by trae-solo-agent
parent 8ded87a3a8
commit 76a5d71252
117 changed files with 204 additions and 3023 deletions
+1 -57
View File
@@ -1,30 +1,12 @@
import type { AcquisitionContext, SsoAuthorizationResult } from '@yunlefun/sso'
import type { YunlefunSsoConfig } from '../apps/web/app/utils/yunlefunSsoConfig'
import { Browser } from '@capacitor/browser'
import { Preferences } from '@capacitor/preferences'
import { SsoIdentityAdoptionError } from '@yunlefun/sso/browser'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { describe, expect, it, vi } from 'vitest'
import {
createCloudbaseIdentityAdapter,
createNativeYunlefunAuthorizationAdapter,
createWebYunlefunAuthorizationAdapter,
} from '../apps/web/app/adapters/yunlefunAuth'
vi.mock('@capacitor/browser', () => ({
Browser: {
close: vi.fn(),
open: vi.fn(),
},
}))
vi.mock('@capacitor/preferences', () => ({
Preferences: {
get: vi.fn(async () => ({ value: null })),
remove: vi.fn(),
set: vi.fn(),
},
}))
const config: YunlefunSsoConfig = {
cloudbaseEnv: 'yunlefun-production',
exchange: {
@@ -135,41 +117,3 @@ describe('cloudbase identity adapter', () => {
await expect(identity.signOut()).rejects.toThrow('CloudBase sign-out failed')
})
})
describe('native authorization adapter', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('clears the pending transaction when authorization is cancelled', async () => {
const nativeConfig: YunlefunSsoConfig = {
...config,
redirect: {
...config.redirect,
clientId: 'cook-mobile',
redirectUri: 'https://cook.yunyoujun.cn/auth/callback?platform=native',
},
}
const adapter = createNativeYunlefunAuthorizationAdapter(nativeConfig, async () => null)
await adapter.start()
expect(Preferences.set).toHaveBeenCalledOnce()
expect(Browser.open).toHaveBeenCalledOnce()
await adapter.cancel()
expect(Preferences.remove).toHaveBeenCalledWith({
key: 'cook:sso:v3:native-transaction',
})
})
it('serializes acquisition into the actual native browser SSO URL', async () => {
const adapter = createNativeYunlefunAuthorizationAdapter(config, async () => null, () => acquisition)
await adapter.start()
const url = new URL(vi.mocked(Browser.open).mock.calls[0]![0].url)
expect(JSON.parse(url.searchParams.get('acquisition')!)).toEqual(acquisition)
expect(url.searchParams.get('client_id')).toBe('cook-web')
expect(url.searchParams.get('code_challenge_method')).toBe('S256')
const transaction = JSON.parse(vi.mocked(Preferences.set).mock.calls[0]![0].value)
expect(transaction.acquisition).toEqual(acquisition)
})
})