chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,30 @@
|
||||
export function shouldRenderHostProjectSettings(supported: boolean): boolean {
|
||||
return supported === true
|
||||
}
|
||||
|
||||
export function withOptionalProjectDir<T extends Record<string, unknown>>(
|
||||
data: T,
|
||||
projectDir?: string | null,
|
||||
): T & { project_dir?: string } {
|
||||
const trimmed = typeof projectDir === 'string' ? projectDir.trim() : ''
|
||||
const next: Record<string, unknown> = { ...data }
|
||||
delete next.project_dir
|
||||
if (trimmed) next.project_dir = trimmed
|
||||
return next as T & { project_dir?: string }
|
||||
}
|
||||
|
||||
export function projectDirBasename(dir: string): string {
|
||||
const trimmed = dir.replace(/[\\/]+$/, '').trim()
|
||||
if (!trimmed) return dir
|
||||
const parts = trimmed.split(/[/\\]/).filter(Boolean)
|
||||
return parts[parts.length - 1] || dir
|
||||
}
|
||||
|
||||
export function hostWorkspaceHeaderText(
|
||||
hostWorkspaceDir: string | null | undefined,
|
||||
temporaryLabel: string,
|
||||
): string {
|
||||
const trimmed = hostWorkspaceDir?.trim() ?? ''
|
||||
if (!trimmed) return temporaryLabel
|
||||
return projectDirBasename(trimmed)
|
||||
}
|
||||
Reference in new issue
Block a user