mirror of
https://github.com/aljazceru/opencode.git
synced 2026-02-23 16:54:27 +01:00
wip: zen
This commit is contained in:
@@ -4,9 +4,11 @@ import { A, createAsync } from "@solidjs/router"
|
|||||||
import { createMemo, Match, Show, Switch } from "solid-js"
|
import { createMemo, Match, Show, Switch } from "solid-js"
|
||||||
import { createStore } from "solid-js/store"
|
import { createStore } from "solid-js/store"
|
||||||
import { github } from "~/lib/github"
|
import { github } from "~/lib/github"
|
||||||
|
import { queryIsLoggedIn } from "~/routes/workspace/common"
|
||||||
|
|
||||||
export function Header(props: { zen?: boolean }) {
|
export function Header(props: { zen?: boolean }) {
|
||||||
const githubData = createAsync(() => github())
|
const githubData = createAsync(() => github())
|
||||||
|
const isLoggedIn = createAsync(() => queryIsLoggedIn())
|
||||||
const starCount = createMemo(() =>
|
const starCount = createMemo(() =>
|
||||||
githubData()?.stars
|
githubData()?.stars
|
||||||
? new Intl.NumberFormat("en-US", {
|
? new Intl.NumberFormat("en-US", {
|
||||||
@@ -39,7 +41,7 @@ export function Header(props: { zen?: boolean }) {
|
|||||||
<li>
|
<li>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Match when={props.zen}>
|
<Match when={props.zen}>
|
||||||
<a href="/auth">Login</a>
|
<a href="/auth">{isLoggedIn() ? "Workspace" : "Login"}</a>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={!props.zen}>
|
<Match when={!props.zen}>
|
||||||
<A href="/zen">Zen</A>
|
<A href="/zen">Zen</A>
|
||||||
@@ -110,7 +112,7 @@ export function Header(props: { zen?: boolean }) {
|
|||||||
<li>
|
<li>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Match when={props.zen}>
|
<Match when={props.zen}>
|
||||||
<a href="/auth">Login</a>
|
<a href="/auth">{isLoggedIn() ? "Workspace" : "Login"}</a>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={!props.zen}>
|
<Match when={!props.zen}>
|
||||||
<A href="/zen">Zen</A>
|
<A href="/zen">Zen</A>
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ export function formatDateUTC(date: Date) {
|
|||||||
return date.toLocaleDateString("en-US", options)
|
return date.toLocaleDateString("en-US", options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const queryIsLoggedIn = query(async () => {
|
||||||
|
"use server"
|
||||||
|
return withActor(() => {
|
||||||
|
try {
|
||||||
|
Actor.assert("account")
|
||||||
|
return true
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, "isLoggedIn.get")
|
||||||
|
|
||||||
export const querySessionInfo = query(async (workspaceID: string) => {
|
export const querySessionInfo = query(async (workspaceID: string) => {
|
||||||
"use server"
|
"use server"
|
||||||
return withActor(() => {
|
return withActor(() => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import "./index.css"
|
import "./index.css"
|
||||||
|
import { createAsync } from "@solidjs/router"
|
||||||
import { Title, Meta, Link } from "@solidjs/meta"
|
import { Title, Meta, Link } from "@solidjs/meta"
|
||||||
import { HttpHeader } from "@solidjs/start"
|
import { HttpHeader } from "@solidjs/start"
|
||||||
import zenLogoLight from "../../asset/zen-ornate-light.svg"
|
import zenLogoLight from "../../asset/zen-ornate-light.svg"
|
||||||
@@ -15,8 +16,10 @@ import { Faq } from "~/component/faq"
|
|||||||
import { Legal } from "~/component/legal"
|
import { Legal } from "~/component/legal"
|
||||||
import { Footer } from "~/component/footer"
|
import { Footer } from "~/component/footer"
|
||||||
import { Header } from "~/component/header"
|
import { Header } from "~/component/header"
|
||||||
|
import { queryIsLoggedIn } from "~/routes/workspace/common"
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const isLoggedIn = createAsync(() => queryIsLoggedIn())
|
||||||
return (
|
return (
|
||||||
<main data-page="zen">
|
<main data-page="zen">
|
||||||
<HttpHeader name="Cache-Control" value="public, max-age=1, s-maxage=3600, stale-while-revalidate=86400" />
|
<HttpHeader name="Cache-Control" value="public, max-age=1, s-maxage=3600, stale-while-revalidate=86400" />
|
||||||
@@ -102,7 +105,7 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="/auth">
|
<a href="/auth">
|
||||||
<span>Get started with Zen </span>
|
<span>{isLoggedIn() ? "Go to workspace " : "Get started with Zen "}</span>
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path
|
<path
|
||||||
d="M6.5 12L17 12M13 16.5L17.5 12L13 7.5"
|
d="M6.5 12L17 12M13 16.5L17.5 12L13 7.5"
|
||||||
|
|||||||
Reference in New Issue
Block a user