提交
This commit is contained in:
1 parent
f1ef768c17
commit
3f56586b02
14 files changed
+172
-105
No files matched your search
BIN
Binary file not shown.
@@ -1 +0,0 @@
|
||||
35869
|
||||
+78
-15
@@ -10,7 +10,7 @@
|
||||
# 首次部署:
|
||||
# cd /root/zkxw-backend/backend
|
||||
# cp .env.test.example .env.test # 或从 .env.example 复制后按测试库填写
|
||||
# python3 -m venv .venv && ./.venv/bin/pip install -r requirements.txt
|
||||
# python3.9 -m venv .venv && ./.venv/bin/pip install -r requirements.txt
|
||||
# ./start-test.sh activate # source .venv/bin/activate
|
||||
# ./start-test.sh start
|
||||
# ============================================
|
||||
@@ -30,7 +30,9 @@ ENV_FILE="${ENV_FILE:-$BASE_DIR/.env.test}"
|
||||
VENV_DIR="${VENV_DIR:-$BASE_DIR/.venv}"
|
||||
ACTIVATE_SCRIPT="$VENV_DIR/bin/activate"
|
||||
PYTHON_BIN="${PYTHON_BIN:-$VENV_DIR/bin/python}"
|
||||
UVICORN_BIN="${UVICORN_BIN:-$VENV_DIR/bin/uvicorn}"
|
||||
MIN_PYTHON_MAJOR=3
|
||||
MIN_PYTHON_MINOR=9
|
||||
SYSTEM_PYTHON=""
|
||||
|
||||
LOG_DIR="$BASE_DIR/logs"
|
||||
LOG_FILE="$LOG_DIR/backend-test.log"
|
||||
@@ -73,6 +75,7 @@ show_help() {
|
||||
LOG_LEVEL=debug
|
||||
APP_MODULE=app.main:app
|
||||
VENV_DIR=./.venv
|
||||
PYTHON_FOR_VENV=python3.9
|
||||
ENV_FILE=./.env.test
|
||||
|
||||
测试部署目录(示例):
|
||||
@@ -91,23 +94,80 @@ ensure_dirs() {
|
||||
mkdir -p "$LOG_DIR"
|
||||
}
|
||||
|
||||
check_python() {
|
||||
if ! command -v python3 >/dev/null 2>&1; then
|
||||
log_error "未找到 python3,请安装 python3.9+"
|
||||
python_version_ge() {
|
||||
local ver="$1"
|
||||
local major="${ver%%.*}"
|
||||
local minor="${ver#*.}"
|
||||
if [ "$major" -gt "$MIN_PYTHON_MAJOR" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ "$major" -eq "$MIN_PYTHON_MAJOR" ] && [ "$minor" -ge "$MIN_PYTHON_MINOR" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
resolve_system_python() {
|
||||
local candidate ver
|
||||
|
||||
if [ -n "${PYTHON_FOR_VENV:-}" ] && command -v "$PYTHON_FOR_VENV" >/dev/null 2>&1; then
|
||||
ver="$("$PYTHON_FOR_VENV" -c 'import sys; print("{}.{}".format(sys.version_info[0], sys.version_info[1]))')"
|
||||
if python_version_ge "$ver"; then
|
||||
echo "$PYTHON_FOR_VENV"
|
||||
return 0
|
||||
fi
|
||||
log_error "PYTHON_FOR_VENV=$PYTHON_FOR_VENV 版本为 $ver,需要 >= ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local py_ver
|
||||
py_ver="$(python3 -c 'import sys; print("{}.{}".format(sys.version_info[0], sys.version_info[1]))')"
|
||||
log_info "系统 python3 版本: $py_ver"
|
||||
for candidate in python3.11 python3.10 python3.9 python3; do
|
||||
if command -v "$candidate" >/dev/null 2>&1; then
|
||||
ver="$("$candidate" -c 'import sys; print("{}.{}".format(sys.version_info[0], sys.version_info[1]))')"
|
||||
if python_version_ge "$ver"; then
|
||||
echo "$candidate"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
check_python() {
|
||||
if ! SYSTEM_PYTHON="$(resolve_system_python)"; then
|
||||
log_error "未找到 python${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+,请安装 python39 或设置 PYTHON_FOR_VENV=python3.9"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "系统 Python: $SYSTEM_PYTHON ($("$SYSTEM_PYTHON" --version 2>&1))"
|
||||
}
|
||||
|
||||
ensure_venv_python_version() {
|
||||
local ver
|
||||
ver="$("$PYTHON_BIN" -c 'import sys; print("{}.{}".format(sys.version_info[0], sys.version_info[1]))')"
|
||||
if python_version_ge "$ver"; then
|
||||
log_info "虚拟环境 Python: $ver ($VENV_DIR)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_error "虚拟环境 Python 版本过低: $ver(需要 >= ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR})"
|
||||
log_error "当前虚拟环境目录: $VENV_DIR"
|
||||
log_warn "请执行: rm -rf \"$VENV_DIR\" && $SYSTEM_PYTHON -m venv \"$VENV_DIR\" && \"$VENV_DIR/bin/pip\" install -r requirements.txt"
|
||||
exit 1
|
||||
}
|
||||
|
||||
has_uvicorn() {
|
||||
"$PYTHON_BIN" -c "import uvicorn" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
ensure_venv_and_runtime() {
|
||||
log_info "虚拟环境目录: $VENV_DIR"
|
||||
|
||||
if [ ! -d "$VENV_DIR" ]; then
|
||||
log_warn "未找到虚拟环境,开始自动创建: $VENV_DIR"
|
||||
if ! python3 -m venv "$VENV_DIR" >/dev/null 2>&1; then
|
||||
if ! "$SYSTEM_PYTHON" -m venv "$VENV_DIR" >/dev/null 2>&1; then
|
||||
log_error "自动创建 venv 失败,请先安装 python3-venv 或手动创建虚拟环境"
|
||||
log_warn "可尝试: yum install -y python3-venv 或 python3 -m ensurepip --upgrade"
|
||||
log_warn "可尝试: $SYSTEM_PYTHON -m venv \"$VENV_DIR\""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -117,20 +177,23 @@ ensure_venv_and_runtime() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_venv_python_version
|
||||
|
||||
if [ ! -x "$VENV_DIR/bin/pip" ]; then
|
||||
log_warn "虚拟环境 pip 不存在,尝试引导安装"
|
||||
"$PYTHON_BIN" -m ensurepip --upgrade >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ ! -x "$UVICORN_BIN" ]; then
|
||||
if ! has_uvicorn; then
|
||||
log_warn "未检测到 uvicorn,开始安装依赖 requirements.txt"
|
||||
if [ ! -x "$VENV_DIR/bin/pip" ]; then
|
||||
log_error "pip 仍不可用,请手动执行依赖初始化"
|
||||
exit 1
|
||||
fi
|
||||
"$VENV_DIR/bin/pip" install --upgrade pip
|
||||
"$VENV_DIR/bin/pip" install -r "$BASE_DIR/requirements.txt"
|
||||
if [ ! -x "$UVICORN_BIN" ]; then
|
||||
log_error "依赖安装后仍未找到 uvicorn: $UVICORN_BIN"
|
||||
if ! has_uvicorn; then
|
||||
log_error "依赖安装后仍无法 import uvicorn,请检查: $PYTHON_BIN -m pip install -r requirements.txt"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -183,7 +246,7 @@ start_server() {
|
||||
fi
|
||||
|
||||
export ENV_FILE
|
||||
nohup "$UVICORN_BIN" "$APP_MODULE" \
|
||||
nohup "$PYTHON_BIN" -m uvicorn "$APP_MODULE" \
|
||||
--host "$HOST" \
|
||||
--port "$PORT" \
|
||||
--workers "$WORKERS" \
|
||||
@@ -252,7 +315,7 @@ show_logs() {
|
||||
activate_venv() {
|
||||
if [ ! -f "$ACTIVATE_SCRIPT" ]; then
|
||||
log_error "虚拟环境激活脚本不存在: $ACTIVATE_SCRIPT"
|
||||
log_warn "可先执行: python3 -m venv .venv && ./.venv/bin/pip install -r requirements.txt"
|
||||
log_warn "可先执行: python3.9 -m venv .venv && ./.venv/bin/pip install -r requirements.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -4289,7 +4289,7 @@
|
||||
"label": "useSettingsPanel()",
|
||||
"file_type": "code",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L17"
|
||||
"source_location": "L16"
|
||||
},
|
||||
{
|
||||
"id": "components_core_layouts_art_settings_panel_composables_usesettingsconfig_ts",
|
||||
@@ -26713,7 +26713,7 @@
|
||||
},
|
||||
{
|
||||
"source": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_utils",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_usetheme",
|
||||
"relation": "imports_from",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
@@ -26722,7 +26722,7 @@
|
||||
},
|
||||
{
|
||||
"source": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_usetheme",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_useceremony",
|
||||
"relation": "imports_from",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
@@ -26731,7 +26731,7 @@
|
||||
},
|
||||
{
|
||||
"source": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_useceremony",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingsstate",
|
||||
"relation": "imports_from",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
@@ -26740,29 +26740,20 @@
|
||||
},
|
||||
{
|
||||
"source": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingsstate",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingshandlers",
|
||||
"relation": "imports_from",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L11",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
"source": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"target": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingshandlers",
|
||||
"relation": "imports_from",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L12",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
"source": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"target": "composables_usesettingspanel_usesettingspanel",
|
||||
"relation": "contains",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L17",
|
||||
"source_location": "L16",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
@@ -52356,7 +52347,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L22",
|
||||
"source_location": "L21",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
@@ -52366,7 +52357,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L23",
|
||||
"source_location": "L22",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
@@ -52376,7 +52367,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L24",
|
||||
"source_location": "L23",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
@@ -52386,7 +52377,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L25",
|
||||
"source_location": "L24",
|
||||
"weight": 1.0
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Graph Report - src (2026-06-16)
|
||||
# Graph Report - src (2026-06-17)
|
||||
|
||||
## Corpus Check
|
||||
- Large corpus: 782 files · ~515,267 words. Semantic extraction will be expensive (many Claude tokens). Consider running on a subfolder, or use --no-semantic to run AST-only.
|
||||
- Large corpus: 782 files · ~515,183 words. Semantic extraction will be expensive (many Claude tokens). Consider running on a subfolder, or use --no-semantic to run AST-only.
|
||||
|
||||
## Summary
|
||||
- 2589 nodes · 3596 edges · 47 communities detected
|
||||
|
||||
@@ -5515,7 +5515,7 @@
|
||||
"label": "useSettingsPanel()",
|
||||
"file_type": "code",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L17",
|
||||
"source_location": "L16",
|
||||
"id": "composables_usesettingspanel_usesettingspanel",
|
||||
"community": 7,
|
||||
"norm_label": "usesettingspanel()"
|
||||
@@ -34554,7 +34554,7 @@
|
||||
"relation": "contains",
|
||||
"confidence": "EXTRACTED",
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L17",
|
||||
"source_location": "L16",
|
||||
"weight": 1.0,
|
||||
"_src": "components_core_layouts_art_settings_panel_composables_usesettingspanel_ts",
|
||||
"_tgt": "composables_usesettingspanel_usesettingspanel",
|
||||
@@ -34567,7 +34567,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L22",
|
||||
"source_location": "L21",
|
||||
"weight": 1.0,
|
||||
"_src": "composables_usesettingspanel_usesettingspanel",
|
||||
"_tgt": "core_useceremony_useceremony",
|
||||
@@ -34579,7 +34579,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L23",
|
||||
"source_location": "L22",
|
||||
"weight": 1.0,
|
||||
"_src": "composables_usesettingspanel_usesettingspanel",
|
||||
"_tgt": "core_usetheme_usetheme",
|
||||
@@ -34591,7 +34591,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L24",
|
||||
"source_location": "L23",
|
||||
"weight": 1.0,
|
||||
"_src": "composables_usesettingspanel_usesettingspanel",
|
||||
"_tgt": "composables_usesettingsstate_usesettingsstate",
|
||||
@@ -34603,7 +34603,7 @@
|
||||
"confidence": "INFERRED",
|
||||
"confidence_score": 0.8,
|
||||
"source_file": "components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts",
|
||||
"source_location": "L25",
|
||||
"source_location": "L24",
|
||||
"weight": 1.0,
|
||||
"_src": "composables_usesettingspanel_usesettingspanel",
|
||||
"_tgt": "composables_usesettingshandlers_usesettingshandlers",
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/common/index.ts": 1781272556.3597305,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/directive/directive.d.ts": 1781272556.3601494,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/api/api.d.ts": 1781272556.3606477,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/import/components.d.ts": 1781607727.241396,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/import/auto-imports.d.ts": 1781607713.6896257,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/import/components.d.ts": 1781660856.5770836,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/import/auto-imports.d.ts": 1781660783.5185683,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/store/index.ts": 1781272556.364766,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/types/router/index.ts": 1781272556.3652694,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/locales/index.ts": 1781272556.3657222,
|
||||
@@ -144,7 +144,7 @@
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/banners/art-basic-banner/index.vue": 1781272556.4864144,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-global-component/index.vue": 1781272556.4869678,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/index.vue": 1781272556.4875474,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts": 1781272556.4890494,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts": 1781661158.6601012,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts": 1781272556.4908195,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts": 1781272556.491559,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts": 1781272556.4939222,
|
||||
@@ -515,7 +515,7 @@
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/worktab.ts": 1781351182.1456184,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/table.ts": 1781272559.2465377,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/menu.ts": 1781272559.2476027,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts": 1781272559.2570925,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts": 1781661154.8679287,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/user.ts": 1781365195.1555984,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/router/routesAlias.ts": 1781272559.2590332,
|
||||
"/Users/wuzilong/work/00code/zkxw/web-admin/src/router/index.ts": 1781272559.4304278,
|
||||
|
||||
+6
-51
@@ -3,9 +3,8 @@ import { useSettingStore } from '@/store/modules/setting'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useBreakpoints } from '@vueuse/core'
|
||||
import AppConfig from '@/config'
|
||||
import { SystemThemeEnum, MenuTypeEnum } from '@/enums/appEnum'
|
||||
import { SystemThemeEnum } from '@/enums/appEnum'
|
||||
import { mittBus } from '@/utils/sys'
|
||||
import { StorageConfig } from '@/utils'
|
||||
import { useTheme } from '@/hooks/core/useTheme'
|
||||
import { useCeremony } from '@/hooks/core/useCeremony'
|
||||
import { useSettingsState } from './useSettingsState'
|
||||
@@ -16,7 +15,7 @@ import { useSettingsHandlers } from './useSettingsHandlers'
|
||||
*/
|
||||
export function useSettingsPanel() {
|
||||
const settingStore = useSettingStore()
|
||||
const { systemThemeType, systemThemeMode, menuType } = storeToRefs(settingStore)
|
||||
const { systemThemeType, systemThemeMode } = storeToRefs(settingStore)
|
||||
|
||||
// Composables
|
||||
const { openFestival, cleanup } = useCeremony()
|
||||
@@ -27,30 +26,10 @@ export function useSettingsPanel() {
|
||||
// 响应式状态
|
||||
const showDrawer = ref(false)
|
||||
|
||||
// 使用 VueUse breakpoints 优化性能
|
||||
// 窄屏仅折叠侧栏,不再切换为「左侧菜单」布局(Web 端固定混合菜单)
|
||||
const breakpoints = useBreakpoints({ tablet: 1000 })
|
||||
const isMobile = breakpoints.smaller('tablet')
|
||||
|
||||
// 记录窗口宽度变化前的菜单类型
|
||||
const getStoredDesktopMenuType = (): MenuTypeEnum | undefined => {
|
||||
const storedMenuType = localStorage.getItem(StorageConfig.RESPONSIVE_MENU_TYPE_KEY)
|
||||
return Object.values(MenuTypeEnum).includes(storedMenuType as MenuTypeEnum)
|
||||
? (storedMenuType as MenuTypeEnum)
|
||||
: undefined
|
||||
}
|
||||
|
||||
const setStoredDesktopMenuType = (type: MenuTypeEnum) => {
|
||||
localStorage.setItem(StorageConfig.RESPONSIVE_MENU_TYPE_KEY, type)
|
||||
}
|
||||
|
||||
const clearStoredDesktopMenuType = () => {
|
||||
localStorage.removeItem(StorageConfig.RESPONSIVE_MENU_TYPE_KEY)
|
||||
}
|
||||
|
||||
const storedDesktopMenuType = getStoredDesktopMenuType()
|
||||
const beforeMenuType = ref<MenuTypeEnum | undefined>(storedDesktopMenuType)
|
||||
const hasChangedMenu = ref(Boolean(storedDesktopMenuType))
|
||||
|
||||
// 计算属性
|
||||
const systemThemeColor = computed(() => settingStore.systemThemeColor as string)
|
||||
|
||||
@@ -89,37 +68,12 @@ export function useSettingsPanel() {
|
||||
}
|
||||
}
|
||||
|
||||
// 响应式布局处理
|
||||
// 响应式布局:窄屏折叠侧栏,菜单类型保持混合(top-left)
|
||||
const useResponsiveLayout = () => {
|
||||
// 使用 watch 监听断点变化,性能更优
|
||||
const stopWatch = watch(
|
||||
isMobile,
|
||||
(mobile: boolean) => {
|
||||
if (mobile) {
|
||||
// 切换到移动端布局
|
||||
if (!hasChangedMenu.value) {
|
||||
beforeMenuType.value = menuType.value
|
||||
if (menuType.value !== MenuTypeEnum.LEFT) {
|
||||
setStoredDesktopMenuType(menuType.value)
|
||||
useSettingsState().switchMenuLayouts(MenuTypeEnum.LEFT)
|
||||
hasChangedMenu.value = true
|
||||
}
|
||||
}
|
||||
|
||||
settingStore.setMenuOpen(false)
|
||||
} else {
|
||||
// 恢复桌面端布局
|
||||
if (hasChangedMenu.value && beforeMenuType.value) {
|
||||
if (menuType.value === MenuTypeEnum.LEFT) {
|
||||
useSettingsState().switchMenuLayouts(beforeMenuType.value)
|
||||
}
|
||||
|
||||
clearStoredDesktopMenuType()
|
||||
hasChangedMenu.value = false
|
||||
}
|
||||
|
||||
settingStore.setMenuOpen(true)
|
||||
}
|
||||
settingStore.setMenuOpen(!mobile)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
@@ -194,6 +148,7 @@ export function useSettingsPanel() {
|
||||
let themeCleanup: (() => void) | null = null
|
||||
|
||||
const initializeSettings = () => {
|
||||
settingStore.enforceWebMenuLayout()
|
||||
mittBus.on('openSetting', openSetting)
|
||||
themeHandlers.initSystemColor()
|
||||
themeCleanup = themeHandlers.listenerSystemTheme()
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_web_admin_src_types_import_components_d_ts", "label": "components.d.ts", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/types/import/components.d.ts", "source_location": "L1"}], "edges": [], "raw_calls": []}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "label": "setting.ts", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L1"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "pinia", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L33", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "vue", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L34", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_types_store", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L35", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_config", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L36", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_enums_appenum", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L37", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_utils_ui", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L38", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_useceremony", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L39", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_utils", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L40", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_config_setting", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/store/modules/setting.ts", "source_location": "L41", "weight": 1.0}], "raw_calls": []}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "label": "useSettingsPanel.ts", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L1"}, {"id": "composables_usesettingspanel_usesettingspanel", "label": "useSettingsPanel()", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L16"}], "edges": [{"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "vue", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L1", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_store_modules_setting", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L2", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "pinia", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L3", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "core", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L4", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_config", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L5", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_enums_appenum", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L6", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_utils_sys", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L7", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_usetheme", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L8", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_hooks_core_useceremony", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L9", "weight": 1.0}, {"source": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingspanel_ts", "target": "users_wuzilong_work_00code_zkxw_web_admin_src_components_core_layouts_art_settings_panel_composables_usesettingsstate", "relation": "imports_from", "confidence": "EXTRACTED", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts", "source_location": "L10", "weight": 1.0}, {"sourLine truncated
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"nodes": [{"id": "users_wuzilong_work_00code_zkxw_web_admin_src_types_import_components_d_ts", "label": "components.d.ts", "file_type": "code", "source_file": "/Users/wuzilong/work/00code/zkxw/web-admin/src/types/import/components.d.ts", "source_location": "L1"}], "edges": [], "raw_calls": []}
|
||||
@@ -160,11 +160,21 @@ export const useSettingStore = defineStore(
|
||||
})
|
||||
|
||||
/**
|
||||
* 切换菜单布局
|
||||
* @param type 菜单类型
|
||||
* 切换菜单布局(Web 管理端固定混合菜单:一级顶栏 + 二级侧栏)
|
||||
*/
|
||||
const switchMenuLayouts = (type: MenuTypeEnum) => {
|
||||
menuType.value = type
|
||||
void type
|
||||
menuType.value = MenuTypeEnum.TOP_LEFT
|
||||
}
|
||||
|
||||
/** 持久化恢复后强制混合菜单,避免历史 localStorage 覆盖布局 */
|
||||
const enforceWebMenuLayout = () => {
|
||||
menuType.value = MenuTypeEnum.TOP_LEFT
|
||||
try {
|
||||
localStorage.removeItem(StorageConfig.RESPONSIVE_MENU_TYPE_KEY)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,6 +421,7 @@ export const useSettingStore = defineStore(
|
||||
getCustomRadius,
|
||||
isShowFireworks,
|
||||
switchMenuLayouts,
|
||||
enforceWebMenuLayout,
|
||||
setMenuOpenWidth,
|
||||
setGlopTheme,
|
||||
switchMenuStyles,
|
||||
@@ -444,7 +455,12 @@ export const useSettingStore = defineStore(
|
||||
{
|
||||
persist: {
|
||||
key: 'setting',
|
||||
storage: localStorage
|
||||
storage: localStorage,
|
||||
// 菜单布局由产品固定,不持久化用户切换记录
|
||||
omit: ['menuType'],
|
||||
afterRestore: (ctx) => {
|
||||
;(ctx.store as ReturnType<typeof useSettingStore>).enforceWebMenuLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
+42
-3
@@ -55,8 +55,9 @@ cd /root/zkxw-backend/backend
|
||||
cp .env.test.example .env.test
|
||||
# 编辑 .env.test:测试库、Redis DB、MinIO bucket、SECRET_KEY、CORS、API 加密等与前端一致
|
||||
|
||||
# 2) 虚拟环境与依赖
|
||||
python3 -m venv .venv
|
||||
# 2) 虚拟环境与依赖(须 python3.9+,勿用系统默认 python3.6)
|
||||
python3.9 -m venv .venv
|
||||
./.venv/bin/pip install --upgrade pip
|
||||
./.venv/bin/pip install -r requirements.txt
|
||||
|
||||
# 3) 赋予脚本执行权限
|
||||
@@ -340,10 +341,48 @@ sed -i 's/\r$//' start-test.sh start-prod.sh
|
||||
### 虚拟环境未找到
|
||||
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
python3.9 -m venv .venv
|
||||
./.venv/bin/pip install --upgrade pip
|
||||
./.venv/bin/pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Python 版本过低 / 依赖安装报 fastapi==0.109.0 找不到
|
||||
|
||||
**现象**:`系统 python3 版本: 3.6`,或 pip 版本 9.x,安装 fastapi 失败。
|
||||
|
||||
**原因**:系统默认 `python3` 为 3.6,而本项目需要 **Python 3.9+**。若曾用 3.6 创建过 `venv/` 或 `.venv/`,启动脚本会误用旧环境。
|
||||
|
||||
**处理**:
|
||||
|
||||
```bash
|
||||
cd /root/zkxw-backend/backend
|
||||
|
||||
# 确认可用版本
|
||||
python3.9 --version
|
||||
|
||||
# 检查是否误设了生产 venv 目录
|
||||
echo "VENV_DIR=${VENV_DIR:-<未设置>}"
|
||||
unset VENV_DIR # 若曾 export VENV_DIR=./venv,先取消
|
||||
|
||||
# 删除旧 venv,用 3.9 重建
|
||||
rm -rf .venv venv
|
||||
python3.9 -m venv .venv
|
||||
./.venv/bin/pip install --upgrade pip
|
||||
./.venv/bin/pip install -r requirements.txt
|
||||
|
||||
# 验证
|
||||
./.venv/bin/python --version # 应为 3.9.x
|
||||
./.venv/bin/python -c "import uvicorn; print('ok')"
|
||||
|
||||
./start-test.sh start
|
||||
```
|
||||
|
||||
若 shell 中曾 `export VENV_DIR=./venv`(生产用),测试启动前须 `unset VENV_DIR` 或显式指定:
|
||||
|
||||
```bash
|
||||
VENV_DIR=./.venv ./start-test.sh start
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. 仓库内相关文件索引
|
||||
|
||||
Reference in new issue
Block a user