独立静态前端项目,当前实现登录页和首页数据看板。
入口配置在 js/config.js:
window.VISITOR_LOGIN_CONFIG = {
frontendMode: "standalone",
deploymentMode: "standalone",
defaultServerIp: "",
apiBaseUrl: "http://localhost:9098",
deploymentConfigPath: "/api/deployment/config",
defaultBackendPort: "9098",
loginPath: "/api/login",
captchaPath: "/captchaImage"
};
frontendMode: "standalone":前端单机版标识,显示 IP 输入框,登录时使用用户输入的后端 IP。frontendMode: "cluster":前端集群版标识,隐藏 IP 输入框,登录时使用 apiBaseUrl。deploymentMode:兼容旧字段;未配置 frontendMode 时才读取。requireServerIp:可选强制覆盖项;配置后优先级高于 frontendMode。apiBaseUrl:集群版使用的后端地址;为空时使用当前前端域名。deploymentConfigPath:后端部署配置接口。页面会读取后端部署标识,但登录页展示由 frontendMode 决定。defaultBackendPort:用户只输入 IP 时自动补充的后端端口。loginPath:登录接口,默认对接后端 POST /api/login。captchaPath:验证码接口,默认对接后端 GET /captchaImage。单机版示例:
window.VISITOR_LOGIN_CONFIG = {
frontendMode: "standalone",
defaultBackendPort: "9098",
loginPath: "/api/login",
captchaPath: "/captchaImage"
};
集群版示例:
window.VISITOR_LOGIN_CONFIG = {
frontendMode: "cluster",
apiBaseUrl: "http://localhost:9098",
deploymentConfigPath: "/api/deployment/config",
loginPath: "/api/login",
captchaPath: "/captchaImage"
};
登录页会写入以下本地标识,供其它前端页面读取:
visitor_admin_frontend_mode:standalone 或 clustervisitor_admin_require_server_ip:是否需要输入 IPvisitor_admin_backend_deployment_mode:后端返回的部署模式visitor_admin_middle_platform_enabled:后端集群模式下是否对接中台后端对应配置在 ruoyi-admin/src/main/resources/application-*.yml:
ruoyi:
deploymentMode: standalone # standalone单机版 cluster集群版
middlePlatformEnabled: false # 集群版是否对接中台
npm run dev
npm run build
npm run dev:启动本地静态服务。npm run build:复制静态资源到 dist。index.html:登录页,登录成功后跳转 pages/dashboard.html。pages/dashboard.html:首页数据看板,当前使用 js/dashboard.js 内的静态数据,后续接口接入时替换数据加载逻辑。GET /system/user/profile、PUT /system/user/profilePUT /system/user/profile/updatePwdPOST /logoutvisitor-admin-ui/
index.html # 登录入口
pages/ # 业务页面 HTML
css/ # 页面样式
js/ # 页面脚本和配置
assets/ # 图片等静态资源
scripts/ # 构建脚本
logs/ # 本地服务日志
dist/ # npm run build 输出
本地 server.js 会兼容旧业务页路径,例如 /dashboard.html 会回退读取 pages/dashboard.html。修改 server.js 后需要重启 dev server 才能让兼容逻辑生效。