提交Salon旧接口清理与安全配置基线

This commit is contained in:
2026-11-01 14:43:04 +08:00
parent f30abbc26c
commit 203dac2370
49 changed files with 73 additions and 19388 deletions
-41
View File
@@ -1,41 +0,0 @@
import { cartApi } from '@/api/cart'
import { toOptionalIdString } from '@/utils/id'
/**
* Purpose: fetchCartProductIdSet supports cart-state.ts by holding or executing the fetch cart product id set page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
export const fetchCartProductIdSet = async () => {
try {
const response = await cartApi.getCartList() as unknown as Array<{ productId?: string | number }>
return new Set(
(Array.isArray(response) ? response : [])
.map(item => toOptionalIdString(item && item.productId))
.filter((id): id is string => Boolean(id))
)
} catch (error) {
return new Set<string>()
}
}
/**
* Purpose: hasCartProduct supports cart-state.ts by holding or executing the has cart product page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
export const hasCartProduct = (cartProductIdSet: Set<string>, productId: unknown) => {
const normalizedId = toOptionalIdString(productId)
return Boolean(normalizedId && cartProductIdSet.has(normalizedId))
}
/**
* Purpose: withAddedCartProduct supports cart-state.ts by holding or executing the with added cart product page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
export const withAddedCartProduct = (cartProductIdSet: Set<string>, productId: unknown) => {
const next = new Set(cartProductIdSet || [])
const normalizedId = toOptionalIdString(productId)
if (normalizedId) {
next.add(normalizedId)
}
return next
}
+1 -4
View File
@@ -10,16 +10,13 @@ describe('recovery utils', () => {
it('adds default routes and primary action state', () => {
const actions = buildRecoveryActions([
{ key: 'retry', text: '重试' },
{ key: 'orders', text: '查看订单' },
{ key: 'cart', text: '返回购物车' }
{ key: 'orders', text: '查看订单' }
])
const retryAction = actions[0]
const ordersAction = actions[1]
const cartAction = actions[2]
expect(retryAction?.primary).toBe(true)
expect(ordersAction?.route).toBe('/orders')
expect(cartAction?.route).toBe('/cart')
expect(recoveryRouteFor('products')).toBe('/products')
})
})
+1 -2
View File
@@ -1,4 +1,4 @@
export type RecoveryActionKey = 'retry' | 'orders' | 'cart' | 'products' | 'profile' | 'contact'
export type RecoveryActionKey = 'retry' | 'orders' | 'products' | 'profile' | 'contact'
export interface RecoveryAction {
key: RecoveryActionKey
@@ -9,7 +9,6 @@ export interface RecoveryAction {
const DEFAULT_ROUTES: Record<string, string> = {
orders: '/orders',
cart: '/cart',
products: '/products',
profile: '/profile'
}
@@ -10,11 +10,7 @@ const USER_ACTION_PREFIXES = [
'/help',
'/product/',
'/shop/',
'/coupons',
'/vip-center',
'/cart',
'/notifications',
'/wishlist',
'/profile',
'/settings',
'/artist-orders',
@@ -81,15 +77,5 @@ export const buildSystemMessageActionPath = (message: MessageLike) => {
if (businessType === 'SHOP' && businessId) {
return `/shop/${encodeURIComponent(businessId)}`
}
if (businessType === 'VIP') {
return '/vip-center'
}
if (businessType === 'COUPON') {
return '/coupons'
}
if (businessType === 'CART') {
return '/cart'
}
return ''
}