chore: baseline import

This commit is contained in:
Codex
2026-04-23 01:08:18 +08:00
commit c8ddfdf660
260 changed files with 117643 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
import type { CollectionConfig } from 'payload'
import { independentDocListFilter } from '@/payload/admin/localized-list-filter'
import { getDocLocaleDefault, resolveDocLocale, syncDocLocaleWithRequestLocale } from '@/payload/doc-locale-hook'
const statusField = {
name: 'status',
type: 'select' as const,
localized: true,
defaultValue: 'draft',
options: ['draft', 'review', 'published', 'archived'],
required: true,
}
export const Downloads: CollectionConfig = {
slug: 'downloads',
hooks: {
beforeChange: [syncDocLocaleWithRequestLocale],
beforeValidate: [syncDocLocaleWithRequestLocale],
},
admin: {
baseFilter: independentDocListFilter('title'),
defaultColumns: ['title', 'docLocale', 'product', 'type', 'version', 'status', 'updatedAt'],
description:
'Firmware packages, manuals, software installers, and release notes tied to products. English and Chinese download entries are maintained as separate documents.',
group: { en: 'Catalog', zh: '产品' },
useAsTitle: 'title',
},
labels: {
plural: { en: 'Downloads', zh: '下载' },
singular: { en: 'Download', zh: '下载条目' },
},
access: {
read: ({ req }) => {
const locale = resolveDocLocale(req)
if (!locale) return true
return { docLocale: { equals: locale } }
},
},
fields: [
{
name: 'docLocale',
type: 'select',
required: true,
defaultValue: getDocLocaleDefault,
options: [
{ label: 'English Doc', value: 'en' },
{ label: '中文 Doc', value: 'zh' },
],
admin: {
position: 'sidebar',
description: 'Independent document language for this download entry.',
},
},
{ name: 'title', type: 'text', required: true, localized: true },
{
name: 'type',
type: 'select',
localized: true,
required: true,
options: ['firmware', 'manual', 'software', 'other'],
},
{ name: 'product', type: 'relationship', relationTo: 'products', required: true },
{ name: 'version', type: 'text', localized: true },
{ name: 'releaseDate', type: 'date', localized: true },
{ name: 'file', type: 'upload', relationTo: 'files', localized: true },
{ name: 'checksum', type: 'text', localized: true },
{ name: 'changelog', type: 'richText', localized: true },
{ name: 'notes', type: 'richText', localized: true },
{
name: 'visibility',
type: 'group',
localized: true,
fields: [
{
name: 'showInDownloadsCenter',
type: 'checkbox',
defaultValue: true,
admin: {
description: 'Controls whether this item appears in the downloads center and per-product download pages.',
},
},
],
},
statusField,
],
}