mirror of
https://github.com/langgenius/dify.git
synced 2026-09-05 16:55:14 +08:00
Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: 姜涵煦 <hanxujiang@jianghanxudeMacBook-Pro-2.local> Co-authored-by: L1nSn0w <l1nsn0w@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import type { TemplateCategory } from './categories'
|
|
|
|
export const PAGE_LINK_CLASS =
|
|
'flex h-8 items-center justify-center rounded-lg border-[0.5px] border-divider-regular px-3 system-sm-medium text-text-secondary outline-hidden hover:bg-state-base-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid'
|
|
export const PAGE_LINK_DISABLED_CLASS =
|
|
'flex h-8 cursor-not-allowed items-center justify-center rounded-lg border-[0.5px] border-divider-subtle px-3 system-sm-medium text-text-quaternary'
|
|
|
|
export type TemplatesHrefOptions = {
|
|
category: TemplateCategory
|
|
languages?: string[]
|
|
page?: number
|
|
query?: string
|
|
sortBy?: string
|
|
sortOrder?: string
|
|
view?: string
|
|
}
|
|
|
|
export function buildTemplatesHref({
|
|
category,
|
|
languages,
|
|
page = 1,
|
|
query,
|
|
sortBy,
|
|
sortOrder,
|
|
view,
|
|
}: TemplatesHrefOptions) {
|
|
const searchParams = new URLSearchParams()
|
|
if (query) searchParams.set('q', query)
|
|
if (sortBy) searchParams.set('sort_by', sortBy)
|
|
if (sortOrder) searchParams.set('sort_order', sortOrder)
|
|
if (view) searchParams.set('view', view)
|
|
if (languages?.length) searchParams.set('languages', languages.join(','))
|
|
if (page > 1) searchParams.set('page', String(page))
|
|
const queryString = searchParams.toString()
|
|
const basePath = category === 'all' ? '/templates' : `/templates/${category}`
|
|
return queryString ? `${basePath}?${queryString}` : basePath
|
|
}
|