Got stream with default file
This commit is contained in:
@ -32,8 +32,8 @@ import {
|
|||||||
} from '@tauri-apps/plugin-fs'
|
} from '@tauri-apps/plugin-fs'
|
||||||
import makeUrlPathRelative from './lib/makeUrlPathRelative'
|
import makeUrlPathRelative from './lib/makeUrlPathRelative'
|
||||||
import {
|
import {
|
||||||
|
getProjectsInDir,
|
||||||
initializeProjectDirectory,
|
initializeProjectDirectory,
|
||||||
isProjectDirectory,
|
|
||||||
PROJECT_ENTRYPOINT,
|
PROJECT_ENTRYPOINT,
|
||||||
} from './lib/tauriFS'
|
} from './lib/tauriFS'
|
||||||
import DownloadAppBanner from './components/DownloadAppBanner'
|
import DownloadAppBanner from './components/DownloadAppBanner'
|
||||||
@ -278,15 +278,7 @@ const router = createBrowserRouter(
|
|||||||
)
|
)
|
||||||
newDefaultDirectory = projectDir
|
newDefaultDirectory = projectDir
|
||||||
}
|
}
|
||||||
const projectsNoMeta = (await readDir(projectDir)).filter(
|
const projects = await getProjectsInDir(projectDir)
|
||||||
isProjectDirectory
|
|
||||||
)
|
|
||||||
const projects = await Promise.all(
|
|
||||||
projectsNoMeta.map(async (p: DirEntry) => ({
|
|
||||||
entrypointMetadata: await stat(p.name + sep() + PROJECT_ENTRYPOINT),
|
|
||||||
...p,
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projects,
|
projects,
|
||||||
|
@ -41,6 +41,8 @@ function ProjectCard({
|
|||||||
function getDisplayedTime(date: Date) {
|
function getDisplayedTime(date: Date) {
|
||||||
const startOfToday = new Date()
|
const startOfToday = new Date()
|
||||||
startOfToday.setHours(0, 0, 0, 0)
|
startOfToday.setHours(0, 0, 0, 0)
|
||||||
|
// TODO: fix time
|
||||||
|
return ""
|
||||||
return date.getTime() < startOfToday.getTime()
|
return date.getTime() < startOfToday.getTime()
|
||||||
? date.toLocaleDateString()
|
? date.toLocaleDateString()
|
||||||
: date.toLocaleTimeString()
|
: date.toLocaleTimeString()
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
writeTextFile,
|
writeTextFile,
|
||||||
stat,
|
stat,
|
||||||
} from '@tauri-apps/plugin-fs'
|
} from '@tauri-apps/plugin-fs'
|
||||||
import { documentDir, homeDir, sep } from '@tauri-apps/api/path'
|
import { documentDir, homeDir, join, sep } from '@tauri-apps/api/path'
|
||||||
import { isTauri } from './isTauri'
|
import { isTauri } from './isTauri'
|
||||||
import { ProjectWithEntryPointMetadata } from '../Router'
|
import { ProjectWithEntryPointMetadata } from '../Router'
|
||||||
|
|
||||||
@ -51,25 +51,19 @@ export async function initializeProjectDirectory(directory: string) {
|
|||||||
return INITIAL_DEFAULT_DIR
|
return INITIAL_DEFAULT_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isProjectDirectory(fileOrDir: Partial<any>) {
|
|
||||||
return (
|
|
||||||
fileOrDir.children?.length &&
|
|
||||||
fileOrDir.children.some((child) => child.name === PROJECT_ENTRYPOINT)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the contents of a directory
|
// Read the contents of a directory
|
||||||
// and return the valid projects
|
// and return the valid projects
|
||||||
export async function getProjectsInDir(projectDir: string) {
|
export async function getProjectsInDir(projectDir: string) {
|
||||||
const readProjects = (
|
const dirs = await readDir(projectDir)
|
||||||
await readDir(projectDir, {
|
|
||||||
recursive: true,
|
|
||||||
})
|
|
||||||
).filter(isProjectDirectory)
|
|
||||||
|
|
||||||
const projectsWithMetadata = await Promise.all(
|
const projectsWithMetadata = await Promise.all(
|
||||||
readProjects.map(async (p) => ({
|
dirs
|
||||||
entrypointMetadata: await stat(p.name + sep() + PROJECT_ENTRYPOINT),
|
.filter(async (p) => {
|
||||||
|
const files = await readDir(await join(projectDir, p.name))
|
||||||
|
return files.some(d => d.name === PROJECT_ENTRYPOINT)
|
||||||
|
})
|
||||||
|
.map(async (p) => ({
|
||||||
|
entrypointMetadata: await stat(await join(projectDir, p.name, PROJECT_ENTRYPOINT)),
|
||||||
|
path: await join(projectDir, p.name),
|
||||||
...p,
|
...p,
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user