diff --git a/.vscode/setting.json b/.vscode/settings.json similarity index 100% rename from .vscode/setting.json rename to .vscode/settings.json diff --git a/astro.config.mjs b/astro.config.mjs index d610c8e..a0d7f85 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,6 +2,7 @@ import { defineConfig } from 'astro/config'; import mdx from '@astrojs/mdx'; import react from '@astrojs/react'; import sitemap from '@astrojs/sitemap'; +import baseSSL from '@vitejs/plugin-basic-ssl'; import pkgs from './package.json'; import tailwindcss from '@tailwindcss/vite'; const isDev = process.env.NODE_ENV === 'development'; diff --git a/package.json b/package.json index d9b66f7..ce5fc33 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.5", "description": "", "main": "index.js", - "basename": "/user/home", + "basename": "/root/home", "scripts": { "dev": "astro dev", "build": "astro build", @@ -20,6 +20,7 @@ "@astrojs/react": "^4.4.0", "@astrojs/sitemap": "^3.6.0", "@floating-ui/dom": "^1.7.4", + "@kevisual/context": "^0.0.4", "@kevisual/query": "0.0.29", "@kevisual/query-login": "^0.0.6", "@kevisual/registry": "^0.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 06b88e0..50cb4ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@floating-ui/dom': specifier: ^1.7.4 version: 1.7.4 + '@kevisual/context': + specifier: ^0.0.4 + version: 0.0.4 '@kevisual/query': specifier: 0.0.29 version: 0.0.29(ws@8.18.0)(zod@3.25.76) @@ -676,6 +679,9 @@ packages: '@kevisual/cache@0.0.2': resolution: {integrity: sha512-2Cl5KF2Gi27uLfhO6CdTMFnRzx9vYnqevAo7d9ab3rOaqTgF8tLeAXglXyRbaWW3WUbHU2XaOb4r98uUsqIQQw==} + '@kevisual/context@0.0.4': + resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==} + '@kevisual/query-login@0.0.6': resolution: {integrity: sha512-ZdX+sxeQaM3PV9fZXofMlxFz1RmpYIkoi47exzUgw6DADjEryBAQKRXe2/oL20NsBTV8owqaagRqffAVjq5c5g==} peerDependencies: @@ -3294,6 +3300,8 @@ snapshots: - tslib - typescript + '@kevisual/context@0.0.4': {} + '@kevisual/query-login@0.0.6(@kevisual/query@0.0.29(ws@8.18.0)(zod@3.25.76))(rollup@4.52.5)(tslib@2.8.1)(typescript@5.8.3)': dependencies: '@kevisual/cache': 0.0.2(rollup@4.52.5)(tslib@2.8.1)(typescript@5.8.3) diff --git a/public/test-import.js b/public/test-import.js new file mode 100644 index 0000000..b5eda67 --- /dev/null +++ b/public/test-import.js @@ -0,0 +1,13 @@ +export const test = () => { + return new Date().toDateString(); +} + +const app = useContextKey('app') + +app.route({ + path: 'test-import', + description: 'test dynamic import module', +}).define(async(ctx)=>{ + + ctx.body = 'test-import' +}).addTo(app); \ No newline at end of file diff --git a/src/apps/ai/app.ts b/src/apps/ai/app.ts new file mode 100644 index 0000000..7587313 --- /dev/null +++ b/src/apps/ai/app.ts @@ -0,0 +1,4 @@ +import { QueryRouterServer } from '@kevisual/router/browser' +import { useContextKey } from '@kevisual/context' +const app = useContextKey('app', new QueryRouterServer()) +export { app } \ No newline at end of file diff --git a/src/apps/ai/index.ts b/src/apps/ai/index.ts new file mode 100644 index 0000000..543b992 --- /dev/null +++ b/src/apps/ai/index.ts @@ -0,0 +1,6 @@ +import { app } from './app' + +import './routes/login' + + +export { app } \ No newline at end of file diff --git a/src/apps/ai/routes/login/index.ts b/src/apps/ai/routes/login/index.ts new file mode 100644 index 0000000..3bcd799 --- /dev/null +++ b/src/apps/ai/routes/login/index.ts @@ -0,0 +1,14 @@ +import { app } from '../../app' + +app.route({ + path: 'login', + description: '登录应用,参数 username 是用户名,password 是密码', + +}).define(async (ctx) => { + const { username, password } = ctx.query; + + ctx.body = { + message: `User ${username} logged in successfully.`, + } +} +).addTo(app) \ No newline at end of file diff --git a/src/apps/web-command/index.tsx b/src/apps/web-command/index.tsx new file mode 100644 index 0000000..a544e16 --- /dev/null +++ b/src/apps/web-command/index.tsx @@ -0,0 +1,42 @@ +import { app } from '../ai'; +import { useEffect, useState } from 'react'; + +const getAppRoutes = () => { + const appRoutes = app.routes.map((route) => { + return { + path: route.path, + key: route.key, + description: route.description, + metadata: route.metadata, + } + }); + return appRoutes; +} + +const fetchTest = async () => { + const url = 'http://localhost:51015/api/router'; + const response = await fetch(url); + const data = await response.json(); + console.log('Fetch Test Data:', data); +} +const dynamicImport = async () => { + const module = await import('http://localhost:4321/test-import.js'); + console.log('Dynamically Imported Module:', module); + console.log('Test Function Output:', module.test()); + +} +export const App = () => { + const [appRoutes, setAppRoutes] = useState(getAppRoutes()); + useEffect(() => { + setAppRoutes(getAppRoutes()); + }, []); + return
Web Command App + +
 {
+
+      await dynamicImport()
+      setAppRoutes(getAppRoutes());
+    }
+    }>{JSON.stringify(appRoutes, null, 2)}
+
; +} \ No newline at end of file diff --git a/src/components/html.astro b/src/components/html.astro index ea5e9d4..5500568 100644 --- a/src/components/html.astro +++ b/src/components/html.astro @@ -1,5 +1,6 @@ --- import '../styles/global.css'; +import '../styles/theme.css'; export interface Props { title?: string; description?: string; diff --git a/src/content.config.ts b/src/content.config.ts index 41dcb49..bb890c3 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -9,7 +9,7 @@ const docs = defineCollection({ title: z.string().optional(), description: z.string().optional(), // pubDate: z.coerce.date(), - // updatedDate: z.coerce.date().optional(), + // updatedAt: z.coerce.date().optional(), }), }); diff --git a/src/data/docs/home.md b/src/data/docs/home.md index bcb24e0..0faa449 100644 --- a/src/data/docs/home.md +++ b/src/data/docs/home.md @@ -1,3 +1,10 @@ +--- +title: 'home' +tags: ['首页', '工作台'] +createdAt: 2025-10-27 18:35 +updatedAt: 2025-10-27 18:35 +--- + # 首页描述 所有的页面的登录入口在当前页面, @@ -11,6 +18,5 @@ - 命令执行 - 历史记录 -## 任务管理 +## 使用场景 -- [ ] 登录功能 \ No newline at end of file diff --git a/src/layouts/blank.astro b/src/layouts/blank.astro index 4a4daa9..5500568 100644 --- a/src/layouts/blank.astro +++ b/src/layouts/blank.astro @@ -1,24 +1,47 @@ --- import '../styles/global.css'; import '../styles/theme.css'; +export interface Props { + title?: string; + description?: string; + lang?: string; + charset?: string; +} + +const { title = 'Light Code', description = 'A lightweight code editor', lang = 'zh-CN', charset = 'UTF-8' } = Astro.props; --- - + + - - - AI Pages - + + + + {title} + + + + + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index 44de5cf..328f039 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,46 +1,10 @@ --- -console.log('Hello from index.astro'); -import '../styles/global.css'; +import Html from '@/components/html.astro'; +import { App } from '@/apps/web-command'; --- - - - Home - - -

Welcome to my website!

-
-
- - - - + +
+ +
+