From 8261ddd0bcbfc3a50f843e086831cf6fb7582c92 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Fri, 30 Jan 2026 17:34:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=BA=20CodePod=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E5=92=8C=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 11 +++++------ pnpm-lock.yaml | 10 +++++----- src/apps/ai-editor/sidebar.tsx | 17 +++++++++++++++-- src/apps/ai-editor/store/menu.ts | 8 +++++++- src/components/html/blank.astro | 2 +- src/styles/theme.css | 4 ++-- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 4d430ec..0c95912 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,15 @@ { - "name": "@kevisual/ai-pages", + "name": "@kevisual/codepod", "version": "0.0.3", "description": "", "main": "index.js", - "basename": "/root/ai-pages", + "basename": "/root/codepod", "scripts": { "dev": "astro dev", "build": "astro build", "preview": "astro preview", - "pub": "ev deploy ./dist -k ai-pages -v 0.0.3 -u", - "git:submodule": "git submodule update --init --recursive", - "sn": "pnpm dlx shadcn@latest add " + "pub": "ev deploy ./dist -k codepod -v 0.0.3 -u -y y", + "ui": "pnpm dlx shadcn@latest add " }, "keywords": [], "author": "abearxiong (https://www.xiongxiao.me)", @@ -66,7 +65,7 @@ "access": "public" }, "devDependencies": { - "@kevisual/api": "^0.0.34", + "@kevisual/api": "^0.0.35", "@kevisual/query": "^0.0.38", "@kevisual/router": "^0.0.63", "@kevisual/store": "^0.0.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 584e362..088d295 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -142,8 +142,8 @@ importers: version: 5.0.10(@types/react@19.2.10)(react@19.2.4)(use-sync-external-store@1.6.0(react@19.2.4)) devDependencies: '@kevisual/api': - specifier: ^0.0.34 - version: 0.0.34 + specifier: ^0.0.35 + version: 0.0.35 '@kevisual/query': specifier: ^0.0.38 version: 0.0.38 @@ -865,8 +865,8 @@ packages: '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} - '@kevisual/api@0.0.34': - resolution: {integrity: sha512-v04L5jtrp6+LCZjhEmudEdd5zo3uBntWkiPUbIw3w/72KLaqa26lmsDEc7VVDMXz9lOilbUzG7vX8eJjTEOZNQ==} + '@kevisual/api@0.0.35': + resolution: {integrity: sha512-NbaOasecbG+O9Ju2/LWC2eWeqcPc5yZYXXyT4vHpU2W5SoPzBf7H3W7+i3py/JcEXF6adcHZVofftCYpecmGMQ==} '@kevisual/cache@0.0.5': resolution: {integrity: sha512-fgtUYGUUq/DY0KFV4CkWszNqvQUaA8XvMTUjoR9ZXRpau5IIDolD/Wen2TFsZ7G3Rfy+lef5dnaiZVDkZwdVKg==} @@ -3939,7 +3939,7 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@kevisual/api@0.0.34': + '@kevisual/api@0.0.35': dependencies: '@kevisual/js-filter': 0.0.5 '@kevisual/load': 0.0.6 diff --git a/src/apps/ai-editor/sidebar.tsx b/src/apps/ai-editor/sidebar.tsx index e9ad53a..6051a67 100644 --- a/src/apps/ai-editor/sidebar.tsx +++ b/src/apps/ai-editor/sidebar.tsx @@ -409,10 +409,23 @@ const RootContextMenu: React.FC<{ children: React.ReactNode }> = ({ children }) export const Sidebar: React.FC = () => { const { menu, isLoading } = useMenuStore(); + const [folder, setFolder] = useState(''); + const [mount, setMount] = useState(false); useEffect(() => { const folder = getFolder(); - init('', folder); + setFolder(folder); + + setMount(true); }, []); + useEffect(() => { + if (mount) { + if (!folder.endsWith('/')) { + toast.error('文件夹路径必须以 / 结尾'); + return; + } + init('', folder); + } + }, [mount, folder]); const rootItems = useMemo(() => { const _menu = menu.filter((item) => { @@ -431,7 +444,7 @@ export const Sidebar: React.FC = () => {

文件

{isLoading && } -
+
{menu.length === 0 && !isLoading ? (
暂无文件
) : ( diff --git a/src/apps/ai-editor/store/menu.ts b/src/apps/ai-editor/store/menu.ts index 9451c54..ddac7fc 100644 --- a/src/apps/ai-editor/store/menu.ts +++ b/src/apps/ai-editor/store/menu.ts @@ -251,8 +251,14 @@ export const init = async (resource: string = '', prefix: string = '') => { export const getCurrentContent = async (currentPath: string): Promise => { if (!currentPath) return null; const loadingToast = toast.loading('正在加载文件内容...'); - const res = await queryResources.fetchFile(currentPath); + const res = await queryResources.fetchFile(currentPath, {}); + toast.dismiss(loadingToast); + if (res instanceof Response) { + const text = await res.text(); + toast.success('文件内容加载成功'); + return text; + } if (res.code === 200) { return res.data || ''; } else { diff --git a/src/components/html/blank.astro b/src/components/html/blank.astro index f6e3109..fb7083a 100644 --- a/src/components/html/blank.astro +++ b/src/components/html/blank.astro @@ -6,7 +6,7 @@ - AI Pages + CodePod