Skip to content

Commit

Permalink
fix: 修复路径错误
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanEichDisciple committed Aug 22, 2024
1 parent 1960fd9 commit 76630e5
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_BASE=''
VITE_BASE_URL=http://localhost:3000/api/v1
VITE_BASE_URL=/api/v1
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_BASE=/hospital
VITE_BASE_URL=http://localhost:3000/api/v1
VITE_BASE_URL=/hospital/api/v1
11 changes: 6 additions & 5 deletions src/lib/components/Nav.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import { page } from '$app/stores';
import { base } from '$app/paths';
import * as Menubar from '$lib/components/ui/menubar';
import * as Avatar from '$lib/components/ui/avatar';
import { Button } from '$lib/components/ui/button';
Expand All @@ -20,17 +21,17 @@

<Menubar.Root>
<Menubar.Menu>
<Menubar.Item href="/" active={activeUrl === '/'}><Button variant="link">首页</Button></Menubar.Item>
<Menubar.Item href="{base}/" active={activeUrl === '/'}><Button variant="link">首页</Button></Menubar.Item>
</Menubar.Menu>

{#if $page.data.user?.role?.name === 'Admin'}
<Menubar.Menu>
<Menubar.Item href="/user"><Button variant="link">用户管理</Button></Menubar.Item>
<Menubar.Item href="{base}/user"><Button variant="link">用户管理</Button></Menubar.Item>
</Menubar.Menu>
{/if}

<Menubar.Menu>
<Menubar.Item href="/about"><Button variant="link">关于</Button></Menubar.Item>
<Menubar.Item href="{base}/about"><Button variant="link">关于</Button></Menubar.Item>
</Menubar.Menu>
</Menubar.Root>

Expand All @@ -43,7 +44,7 @@
</Avatar.Root>
</DropdownMenu.Trigger>
{:else}
<Button variant="link" href="/login">登录</Button>
<Button variant="link" href="{base}/login">登录</Button>
{/if}
<DropdownMenu.Content class="w-56">
{#if $page.data.user}
Expand All @@ -54,7 +55,7 @@
<User class="mr-2 h-4 w-4" />
<span>Profile</span>
</DropdownMenu.Item>
<DropdownMenu.Item href="/settings">
<DropdownMenu.Item href="{base}/settings">
<Settings class="mr-2 h-4 w-4" />
<span>设置</span>
</DropdownMenu.Item>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/(admin)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import { goto } from '$app/navigation';
import { navigating } from '$app/stores';
import { base } from '$app/paths';
import Nav from '$lib/components/Nav.svelte';
import PreloadingIndicator from '$lib/components/PreloadingIndicator.svelte';
Expand All @@ -13,7 +14,7 @@
}
});
if (response.ok) {
goto('/login');
goto(`${base}/login`);
} else {
// 退出失败,你可以在这里处理错误
}
Expand Down
3 changes: 2 additions & 1 deletion src/routes/(admin)/user/data-table-actions.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { base } from '$app/paths';
import Ellipsis from 'lucide-svelte/icons/ellipsis';
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
import { Button } from '$lib/components/ui/button';
Expand All @@ -9,7 +10,7 @@
function handleEdit() {
// 跳转到用户详情页面
goto(`/user/${id}`);
goto(`${base}/user/${id}`);
}
function handleDelete() {
Expand Down
5 changes: 3 additions & 2 deletions src/routes/(auth)/forgot/form.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { base } from '$app/paths';
import { superForm } from 'sveltekit-superforms';
import { zodClient } from 'sveltekit-superforms/adapters';
import { formSchema } from './schema';
Expand Down Expand Up @@ -28,11 +29,11 @@
<Form.Button type="submit" color="purpleToBlue" class="w-full">发送</Form.Button>

<div class="flex items-center justify-end">
<a href="/register" class="text-sm font-medium hover:underline">注册</a>
<a href="{base}/register" class="text-sm font-medium hover:underline">注册</a>
</div>

<p class="text-md text-center">
<span class="text-gray-500">已有账号?</span>
<a href="/login" class="font-medium hover:underline">登录</a>
<a href="{base}/login" class="font-medium hover:underline">登录</a>
</p>
</form>
5 changes: 3 additions & 2 deletions src/routes/(auth)/login/form.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { base } from '$app/paths';
import { superForm } from 'sveltekit-superforms';
import { zodClient } from 'sveltekit-superforms/adapters';
import { formSchema } from './schema';
Expand Down Expand Up @@ -37,11 +38,11 @@

<div class="flex items-center justify-between">
<Checkbox>记住我</Checkbox>
<a href="/forgot" class="text-sm font-medium hover:underline">忘记密码</a>
<a href="{base}/forgot" class="text-sm font-medium hover:underline">忘记密码</a>
</div>

<p class="text-md text-center">
<span class="text-gray-500">没有账号?</span>
<a href="/register" class="font-medium hover:underline">注册</a>
<a href="{base}/register" class="font-medium hover:underline">注册</a>
</p>
</form>
5 changes: 3 additions & 2 deletions src/routes/(auth)/register/form.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { base } from '$app/paths';
import { superForm } from 'sveltekit-superforms';
import { zodClient } from 'sveltekit-superforms/adapters';
import { formSchema } from './schema';
Expand Down Expand Up @@ -61,11 +62,11 @@
<Form.Button type="submit" color="purpleToBlue" class="w-full">注册</Form.Button>

<div class="flex items-center justify-end">
<a href="/forgot" class="text-sm font-medium hover:underline">忘记密码</a>
<a href="{base}/forgot" class="text-sm font-medium hover:underline">忘记密码</a>
</div>

<p class="text-md text-center text-gray-500">
<span>已有账号?</span>
<a href="/login" class="font-medium hover:underline">登录</a>
<a href="{base}/login" class="font-medium hover:underline">登录</a>
</p>
</form>
4 changes: 2 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
});
onDestroy(() => {
//解绑地图的点击事件
map?.off('click', () => handleMapClick());
map?.off('click', () => handleMapClick);
//销毁地图,并清空地图容器
map?.destroy();
//地图对象赋值为null
Expand All @@ -292,7 +292,7 @@
<div id="map" class="h-dvh"></div>
<!-- 某个医院的详情弹框 -->
<HospitalDetail {hospital} bind:domRef={popupDetail} on:closeDetail={() => (popupDetail = null)} />
<HospitalDetail {hospital} bind:domRef={popupDetail} on:closeDetail={() => (popupDetail = undefined)} />
<HospitalList {hospitalList} />
Expand Down
5 changes: 3 additions & 2 deletions src/routes/index/avatar.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import { page } from '$app/stores';
import { base } from '$app/paths';
import * as Avatar from '$lib/components/ui/avatar';
import * as Popover from '$lib/components/ui/popover';
import { Button } from '$lib/components/ui/button/index.js';
Expand All @@ -8,7 +9,7 @@
let className = undefined;
const user = $page.data?.user;
const src = user?.photo || '/defavatar.png';
const src = user?.photo || `${base}/defavatar.png`;
</script>
<div class={cn('h-12 w-12', className)} {...$$restProps}>
Expand All @@ -25,7 +26,7 @@
<LogOut class="mr-2 h-4 w-4" />
</div>
{:else}
<Button variant="link" href="/login" class="w-full">登录</Button>
<Button variant="link" href="{base}/login" class="w-full">登录</Button>
{/if}
</Popover.Content>
</Popover.Root>
Expand Down
1 change: 1 addition & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default defineConfig(({ mode }) => {
plugins: [sveltekit()],
server: {
proxy: {
'/api/': 'http://localhost:3000',
'/_AMapService/': {
target: 'https://restapi.amap.com/',
changeOrigin: true,
Expand Down

0 comments on commit 76630e5

Please sign in to comment.