Skip to content

Commit

Permalink
docs(README): 添加 base 安全的路径解析
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Dec 1, 2023
1 parent 339be8c commit 7c08be3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
35. `renovate` 自动更新依赖
36. 自动版本更新并生成 `CHANGELOG`
37. 最快最小的 `dockerfile` 静态 `go` 服务
38. `base` 安全的路径解析

<br />
<br />
Expand Down Expand Up @@ -1232,6 +1233,24 @@ pnpm deps:fresh

具体可见 👉 [PierreZ/goStatic](https://github.com/PierreZ/goStatic)

<br />
<br />

38. base 安全的路径解析

`vite` 中,如果我们改了 `vite.config.ts` 中的 `base`,这导致资源路径和路由路径失效,使用 `safeResolve` 可以保证在开发环境和生产环境下都是统一的 `base`.

```html
<script setup lang="ts">
const path = safeResolve("你的路由路径")
</script>

<template>
<!-- 模板中应用也是允许的 -->
<img :src="safeResolve('/notFound/32.svg')"/>
</template>
```

<br />
<br />
<br />
Expand Down
1 change: 0 additions & 1 deletion src/composables/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO README 文档
/**
* base 安全的路径解析
* @param path 路径
Expand Down

0 comments on commit 7c08be3

Please sign in to comment.