diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/SecurityConfig.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/SecurityConfig.java index e1f399a4..a2d2f7fd 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/SecurityConfig.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/config/SecurityConfig.java @@ -46,7 +46,6 @@ public class SecurityConfig { .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(auth -> auth .requestMatchers("/auth/login", "/auth/register", "/auth/refresh").permitAll() - .requestMatchers("/init/**").permitAll() .requestMatchers("/uploads/**").permitAll() // 允许直接访问上传的文件 .requestMatchers("/doc.html", "/webjars/**", "/v3/api-docs/**", "/swagger-resources/**", "/swagger-ui/**", "/swagger-ui.html") diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/controller/InitController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/controller/InitController.java deleted file mode 100644 index 31ef9941..00000000 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/controller/InitController.java +++ /dev/null @@ -1,31 +0,0 @@ -package top.xyquan.ecomdmbbackend.modules.sys.init.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.xyquan.ecomdmbbackend.common.response.ApiResponse; -import top.xyquan.ecomdmbbackend.modules.sys.init.model.vo.InitStatusVO; -import top.xyquan.ecomdmbbackend.modules.sys.init.service.SysInitService; - -/** - * 系统初始化状态查询 API(无需登录,用于诊断首次部署状态) - */ -@Tag(name = "系统初始化", description = "首次部署初始化状态") -@RestController -@RequestMapping("/init") -public class InitController { - - private final SysInitService sysInitService; - - public InitController(SysInitService sysInitService) { - this.sysInitService = sysInitService; - } - - @Operation(summary = "获取初始化状态") - @GetMapping("/status") - public ApiResponse status() { - return ApiResponse.success(sysInitService.getStatus()); - } -} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/model/vo/InitStatusVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/model/vo/InitStatusVO.java deleted file mode 100644 index 1ee77bb0..00000000 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/model/vo/InitStatusVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package top.xyquan.ecomdmbbackend.modules.sys.init.model.vo; - -import lombok.Builder; -import lombok.Data; - -/** - * 初始化状态 - */ -@Data -@Builder -public class InitStatusVO { - - private boolean initialized; - - private String systemCompanyName; - - private String adminLoginCode; -} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/service/SysInitService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/service/SysInitService.java index ace4f9e6..b1728678 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/service/SysInitService.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/sys/init/service/SysInitService.java @@ -12,7 +12,6 @@ import top.xyquan.ecomdmbbackend.modules.org.company.service.CompanyService; import top.xyquan.ecomdmbbackend.modules.sys.init.config.SysInitProperties; import top.xyquan.ecomdmbbackend.modules.sys.init.mapper.SysInitMapper; import top.xyquan.ecomdmbbackend.modules.sys.init.model.po.SysInitPO; -import top.xyquan.ecomdmbbackend.modules.sys.init.model.vo.InitStatusVO; import top.xyquan.ecomdmbbackend.modules.sys.user.mapper.UserMapper; import top.xyquan.ecomdmbbackend.modules.sys.user.model.po.UserPO; @@ -94,17 +93,6 @@ public class SysInitService { log.info("系统初始化完成:系统公司=[{}],超管账号=[{}]", companyDTO.getName(), admin.getLoginCode()); } - public InitStatusVO getStatus() { - SysInitPO init = getOrCreateInitRow(); - boolean initialized = Boolean.TRUE.equals(init.getInitialized()) - || (init.getStep() != null && init.getStep() >= 3); - return InitStatusVO.builder() - .initialized(initialized) - .systemCompanyName(init.getCompanyName()) - .adminLoginCode(resolveAdminLoginCode(init)) - .build(); - } - private UserPO createSuperAdmin() { String loginCode = initProperties.getAdminLoginCode(); if (!StringUtils.hasText(loginCode)) { @@ -165,14 +153,4 @@ public class SysInitService { } return init; } - - private String resolveAdminLoginCode(SysInitPO init) { - if (init.getAdminId() != null) { - UserPO user = userMapper.selectById(init.getAdminId()); - if (user != null) { - return user.getLoginCode(); - } - } - return initProperties.getAdminLoginCode(); - } } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/system/license/apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/system/license/apis.ts index 28a3cf95..2ff4f00a 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/system/license/apis.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/system/license/apis.ts @@ -1,23 +1,11 @@ import type { LicenseDTO, LicenseVO } from './types'; -import { baseRequestClient, requestClient } from '#/api/request'; +import { requestClient } from '#/api/request'; -/** 初始化相关 API(无需登录) */ +/** 已登录用户的 License 管理 API */ -export async function getInitStatusApi() { - return baseRequestClient.get('/init/status'); -} - -export async function createInitAdminApi(data: LicenseDTO.InitAdmin) { - return baseRequestClient.post('/init/admin', data); -} - -export async function saveInitCompanyApi(data: LicenseDTO.InitCompany) { - return baseRequestClient.post('/init/company', data); -} - -export async function getInitFingerprintApi() { - return baseRequestClient.get('/init/fingerprint'); +export async function getLicenseInfoApi() { + return requestClient.get('/system/license'); } export async function activateLicenseApi(data: LicenseDTO.ActivateLicense) { @@ -27,20 +15,6 @@ export async function activateLicenseApi(data: LicenseDTO.ActivateLicense) { ); } -/** @deprecated 初始化向导用,后端若未实现可忽略 */ -export async function activateInitLicenseApi(data: LicenseDTO.ActivateLicense) { - return baseRequestClient.post( - '/init/activate', - data, - ); -} - -/** 已登录用户的 License 管理 API */ - -export async function getLicenseInfoApi() { - return requestClient.get('/system/license'); -} - export async function updateLicenseApi(data: LicenseDTO.ActivateLicense) { return requestClient.put('/system/license', data); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.dto.ts b/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.dto.ts index f1bd00fc..6d351044 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.dto.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.dto.ts @@ -2,19 +2,6 @@ * License 模块 — 请求 DTO */ export namespace LicenseDTO { - export interface InitAdmin { - loginCode: string; - phone?: string; - password: string; - realName: string; - } - - export interface InitCompany { - companyName: string; - contactPhone?: string; - contactEmail?: string; - } - export interface ActivateLicense { licenseKey: string; } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.vo.ts index 08358598..5ca9c328 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/system/license/types/types.vo.ts @@ -2,20 +2,11 @@ * License 模块 — 响应 VO */ export namespace LicenseVO { - /** 初始化状态 */ - export interface InitStatus { - initialized: boolean; - currentStep: number; - adminCreated: boolean; - companySaved: boolean; - licenseActivated: boolean; - } - /** 机器指纹 */ export interface Fingerprint { fingerprint: string; - machineId: string; - hostname: string; + machineId?: string; + hostname?: string; } /** License 摘要 */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/router/guard.ts b/ecom-dmb-frontend/apps/web-antd/src/router/guard.ts index a19ca0e7..a1ad6d88 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/router/guard.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/router/guard.ts @@ -5,45 +5,11 @@ import { preferences } from '@vben/preferences'; import { useAccessStore, useUserStore } from '@vben/stores'; import { startProgress, stopProgress } from '@vben/utils'; -import { getInitStatusApi } from '#/api/system/license'; -import { INIT_PATH, accessRoutes, coreRouteNames } from '#/router/routes'; +import { accessRoutes, coreRouteNames } from '#/router/routes'; import { useAuthStore } from '#/store'; import { generateAccess } from './access'; -/** 缓存初始化状态,避免每次路由切换都请求 */ -let initStatusCache: { checked: boolean; initialized: boolean } = { - checked: false, - initialized: true, -}; - -/** 初始化完成后清除缓存(激活成功后可由页面调用) */ -export function resetInitStatusCache() { - initStatusCache = { checked: false, initialized: true }; -} - -async function ensureInitialized(toPath: string): Promise { - if (toPath === INIT_PATH || toPath.startsWith(`${INIT_PATH}/`)) { - return true; - } - if (!initStatusCache.checked) { - try { - const status = await getInitStatusApi(); - initStatusCache = { - checked: true, - initialized: status.initialized, - }; - } catch { - // 后端不可达时不阻断(本地纯前端开发) - initStatusCache = { checked: true, initialized: true }; - } - } - if (!initStatusCache.initialized) { - return { path: INIT_PATH, replace: true }; - } - return true; -} - /** * 通用守卫配置 * @param router @@ -84,12 +50,6 @@ function setupAccessGuard(router: Router) { const userStore = useUserStore(); const authStore = useAuthStore(); - // 未初始化则强制进入初始化向导(Init 路由本身跳过) - const initCheck = await ensureInitialized(to.path); - if (initCheck !== true) { - return initCheck; - } - // 基本路由,这些路由不需要进入权限拦截 if (coreRouteNames.includes(to.name as string)) { if (to.path === LOGIN_PATH && accessStore.accessToken) { diff --git a/ecom-dmb-frontend/apps/web-antd/src/router/routes/core.ts b/ecom-dmb-frontend/apps/web-antd/src/router/routes/core.ts index e64bea0c..949b0b65 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/router/routes/core.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/router/routes/core.ts @@ -20,9 +20,6 @@ const fallbackNotFoundRoute: RouteRecordRaw = { path: '/:path(.*)*', }; -/** 系统初始化路径(未初始化时强制跳转) */ -export const INIT_PATH = '/init'; - /** 基本路由,这些路由是必须存在的 */ const coreRoutes: RouteRecordRaw[] = [ /** @@ -41,17 +38,6 @@ const coreRoutes: RouteRecordRaw[] = [ redirect: preferences.app.defaultHomePath, children: [], }, - { - name: 'Init', - path: INIT_PATH, - component: () => import('#/views/init/InitWizard.vue'), - meta: { - hideInBreadcrumb: true, - hideInMenu: true, - hideInTab: true, - title: '系统初始化', - }, - }, { component: AuthPageLayout, meta: { diff --git a/ecom-dmb-frontend/apps/web-antd/src/router/routes/index.ts b/ecom-dmb-frontend/apps/web-antd/src/router/routes/index.ts index 704b8e7f..b9a00b80 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/router/routes/index.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/router/routes/index.ts @@ -2,7 +2,7 @@ import type { RouteRecordRaw } from 'vue-router'; import { mergeRouteModules, traverseTreeValues } from '@vben/utils'; -import { coreRoutes, fallbackNotFoundRoute, INIT_PATH } from './core'; +import { coreRoutes, fallbackNotFoundRoute } from './core'; const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', { eager: true, @@ -41,4 +41,4 @@ const routes: RouteRecordRaw[] = [ /** 有权限校验的路由列表,包含动态路由 */ const accessRoutes = [...dynamicRoutes]; -export { accessRoutes, coreRouteNames, INIT_PATH, routes }; +export { accessRoutes, coreRouteNames, routes }; diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepAdmin.vue b/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepAdmin.vue deleted file mode 100644 index 75d98f34..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepAdmin.vue +++ /dev/null @@ -1,85 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepCompany.vue b/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepCompany.vue deleted file mode 100644 index 31aecb6b..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepCompany.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepLicense.vue b/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepLicense.vue deleted file mode 100644 index 772313e8..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitStepLicense.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitWizard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/init/InitWizard.vue deleted file mode 100644 index 3b15fc0d..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/init/InitWizard.vue +++ /dev/null @@ -1,91 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/init/components/FingerprintDisplay.vue b/ecom-dmb-frontend/apps/web-antd/src/views/system/license/FingerprintDisplay.vue similarity index 100% rename from ecom-dmb-frontend/apps/web-antd/src/views/init/components/FingerprintDisplay.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/system/license/FingerprintDisplay.vue diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/system/license/FingerprintInfo.vue b/ecom-dmb-frontend/apps/web-antd/src/views/system/license/FingerprintInfo.vue index 6602de4a..0c98d059 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/system/license/FingerprintInfo.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/system/license/FingerprintInfo.vue @@ -7,7 +7,7 @@ import { Card, Spin } from 'ant-design-vue'; import { getSystemFingerprintApi } from '#/api/system/license'; -import FingerprintDisplay from '#/views/init/components/FingerprintDisplay.vue'; +import FingerprintDisplay from './FingerprintDisplay.vue'; defineOptions({ name: 'FingerprintInfo' }); diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/system/license/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/system/license/index.vue index ceb92a8f..8f39b5d8 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/system/license/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/system/license/index.vue @@ -24,7 +24,7 @@ import { getSystemFingerprintApi, } from '#/api/system/license'; -import FingerprintDisplay from '#/views/init/components/FingerprintDisplay.vue'; +import FingerprintDisplay from './FingerprintDisplay.vue'; defineOptions({ name: 'SystemLicensePage' });