Merge branch 'feat-active-config' into dev

This commit is contained in:
moux1024 2025-09-29 15:23:48 +08:00
commit 78c7bec590
4 changed files with 32 additions and 2 deletions

View File

@ -14,6 +14,21 @@ echo "Build process started at $(date)" | tee $LOGFILE
# 获取当前分支名
current_branch=$(git rev-parse --abbrev-ref HEAD)
# 指定并加载环境变量文件dev 使用 .env.development
ENV_FILE=".env.development"
if [ -f "$ENV_FILE" ]; then
echo "Loading environment from $ENV_FILE" | tee -a $LOGFILE
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
else
echo "未找到 $ENV_FILE,继续使用当前环境变量" | tee -a $LOGFILE
fi
# 设置 NODE_ENV 为 development避免默认使用 production
export NODE_ENV="development"
# 打包之前,需要检查是否在 dev 分支,工作区是否干净,是否和远程分支一致
if [ "$(git branch --show-current)" != "$BRANCH_NAME" ]; then
echo "当前分支不是 dev 分支"

View File

@ -14,6 +14,21 @@ echo "Build process started at $(date)" | tee $LOGFILE
# 获取当前分支名
current_branch=$(git rev-parse --abbrev-ref HEAD)
# 指定并加载环境变量文件prod 使用 .env.production
ENV_FILE=".env.production"
if [ -f "$ENV_FILE" ]; then
echo "Loading environment from $ENV_FILE" | tee -a $LOGFILE
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
else
echo "未找到 $ENV_FILE,继续使用当前环境变量" | tee -a $LOGFILE
fi
# 设置 NODE_ENV 为 production
export NODE_ENV="production"
# 打包之前,需要检查是否在 prod 分支,工作区是否干净,是否和远程分支一致
if [ "$(git branch --show-current)" != "$BRANCH_NAME" ]; then
echo "当前分支不是 prod 分支"

View File

@ -17,7 +17,7 @@ export function useServerSetting<T = unknown>(code: string, defaultValue?: T) {
dispatch(setLoading({ code, loading: true }));
try {
const value = await fetchSettingByCode<T>(code, defaultValue as T | undefined);
dispatch(setValue<T>({ code, value: value as T }));
dispatch(setValue({ code, value: value }));
} catch (e: any) {
dispatch(setError({ code, error: e?.message || 'Load failed' }));
}

View File

@ -27,7 +27,7 @@ export const serverSettingSlice = createSlice({
const current = state.byCode[code] || {};
state.byCode[code] = { ...current, loading, error: loading ? undefined : current.error };
},
setValue<T>(state, action: PayloadAction<{ code: string; value: T }>) {
setValue(state, action: PayloadAction<{ code: string; value: any }>) {
const { code, value } = action.payload as { code: string; value: unknown };
const current = state.byCode[code] || {};
state.byCode[code] = { ...current, loading: false, error: undefined, value };