26 lines
949 B
TypeScript
26 lines
949 B
TypeScript
export const MATERIAL_ACCESS_SCOPES = ['general', 'operations_g'] as const
|
|
|
|
export type MaterialAccessScope = (typeof MATERIAL_ACCESS_SCOPES)[number]
|
|
|
|
export const MATERIAL_ACCESS_SCOPE_LABELS: Record<MaterialAccessScope, string> = {
|
|
general: '通用素材',
|
|
operations_g: '运营中心 G 专属',
|
|
}
|
|
|
|
export function normalizeMaterialAccessScope(value: unknown): MaterialAccessScope {
|
|
if (value == null || value === '') return 'general'
|
|
if (value === 'general' || value === 'operations_g') return value
|
|
throw new Error('使用范围只能是通用素材或运营中心 G 专属')
|
|
}
|
|
|
|
export function isOperationsGMaterial(material: { accessScope?: string | null }): boolean {
|
|
return material.accessScope === 'operations_g'
|
|
}
|
|
|
|
export function isRestrictedMaterial(material: {
|
|
accessScope?: string | null
|
|
taskDetailPrivate?: boolean | null
|
|
}): boolean {
|
|
return isOperationsGMaterial(material) || material.taskDetailPrivate === true
|
|
}
|