-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,502 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[private] | ||
@default: | ||
just --list --justfile {{justfile()}} | ||
|
||
# Show git status with color | ||
status: | ||
git add -u && git diff --color=always --staged --stat | tee | ||
|
||
# Pull current branch with rebase and autostash | ||
pull: | ||
git pull --rebase --autostash origin `git branch --show-current` | ||
|
||
# Install TikZ dependencies | ||
prepare-tikz: | ||
apk add texlive icu-data-full texmf-dist-latexextra texmf-dist-langchinese texmf-dist-pictures | ||
apk add -X http://mirrors.aliyun.com/alpine/edge/testing pdf2svg | ||
|
||
# Convert TikZ files to SVG | ||
tikz: | ||
time node ./site/dist/scripts/tikz2svg.js ./notes/courses/cs221/assets/*.tikz | ||
|
||
# Optimize SVG files | ||
svgo: | ||
pnpm svgo ./notes/courses/cs221/assets/*.svg | ||
|
||
hello name: | ||
@echo "Hello, {{name}} !" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
tags: | ||
- Frontend | ||
- React | ||
--- | ||
|
||
# Frontend | ||
|
||
# FAQ | ||
|
||
## 静态前端配置 | ||
|
||
> 加载 Bootstrap 配置 - 例如 API 地址 | ||
1. 构建时根据 branch 加载配置 | ||
|
||
```ts | ||
import { defineConfig, loadEnv, type PluginOption } from 'vite'; | ||
export default defineConfig(({ mode, command }) => { | ||
const env = {}; | ||
console.log(`Vite ${command} mode=${mode} branch=${process.env.CI_COMMIT_BRANCH || ''}`); | ||
Object.assign(env, loadEnv(mode, process.cwd(), '')); | ||
|
||
// 加载 .env.branch 覆盖 | ||
if (process.env.CI_COMMIT_BRANCH) { | ||
Object.assign(env, loadEnv(process.env.CI_COMMIT_BRANCH, process.cwd(), '')); | ||
} | ||
process.env = Object.assign(process.env, env); | ||
|
||
return defineConfig({}); | ||
}); | ||
``` | ||
|
||
1. 部署时通过覆盖 json 配置 | ||
- 请求 `${location.origin}/config.json` 获取配置 | ||
- 允许配置不存在 | ||
- 部署时可以将 /config.json 重定向 | ||
- 部署时可以将 `/app/public/config.json` 内容进行替换 | ||
1. 回滚到 `${location.origin}/api` 作为默认 API 地址 | ||
1. 通过请求 API 获取配置 | ||
- SaaS 场景 | ||
- 允许用户输入租户 ID/名字 | ||
- 服务端判断 referer/url 判断返回的配置信息 |
Oops, something went wrong.