Frank 4 месяцев назад
Родитель
Сommit
e8751d976e

+ 4 - 2
packages/console/app/src/component/header.tsx

@@ -4,9 +4,11 @@ import { A, createAsync } from "@solidjs/router"
 import { createMemo, Match, Show, Switch } from "solid-js"
 import { createStore } from "solid-js/store"
 import { github } from "~/lib/github"
+import { queryIsLoggedIn } from "~/routes/workspace/common"
 
 export function Header(props: { zen?: boolean }) {
   const githubData = createAsync(() => github())
+  const isLoggedIn = createAsync(() => queryIsLoggedIn())
   const starCount = createMemo(() =>
     githubData()?.stars
       ? new Intl.NumberFormat("en-US", {
@@ -39,7 +41,7 @@ export function Header(props: { zen?: boolean }) {
           <li>
             <Switch>
               <Match when={props.zen}>
-                <a href="/auth">Login</a>
+                <a href="/auth">{isLoggedIn() ? "Workspace" : "Login"}</a>
               </Match>
               <Match when={!props.zen}>
                 <A href="/zen">Zen</A>
@@ -110,7 +112,7 @@ export function Header(props: { zen?: boolean }) {
                 <li>
                   <Switch>
                     <Match when={props.zen}>
-                      <a href="/auth">Login</a>
+                      <a href="/auth">{isLoggedIn() ? "Workspace" : "Login"}</a>
                     </Match>
                     <Match when={!props.zen}>
                       <A href="/zen">Zen</A>

+ 12 - 0
packages/console/app/src/routes/workspace/common.tsx

@@ -30,6 +30,18 @@ export function formatDateUTC(date: Date) {
   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) => {
   "use server"
   return withActor(() => {

+ 4 - 1
packages/console/app/src/routes/zen/index.tsx

@@ -1,4 +1,5 @@
 import "./index.css"
+import { createAsync } from "@solidjs/router"
 import { Title, Meta, Link } from "@solidjs/meta"
 import { HttpHeader } from "@solidjs/start"
 import zenLogoLight from "../../asset/zen-ornate-light.svg"
@@ -15,8 +16,10 @@ import { Faq } from "~/component/faq"
 import { Legal } from "~/component/legal"
 import { Footer } from "~/component/footer"
 import { Header } from "~/component/header"
+import { queryIsLoggedIn } from "~/routes/workspace/common"
 
 export default function Home() {
+  const isLoggedIn = createAsync(() => queryIsLoggedIn())
   return (
     <main data-page="zen">
       <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>
               <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">
                   <path
                     d="M6.5 12L17 12M13 16.5L17.5 12L13 7.5"