feat: add Vue 3 admin frontend and integrate with backend like mediabot

This commit is contained in:
mediabot-pt
2026-06-29 11:14:37 +08:00
parent 25cd9873ae
commit 6f56cde229
17 changed files with 729 additions and 11 deletions

View File

@@ -0,0 +1,39 @@
package com.par.api.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
import java.io.IOException;
/**
* SPA 路由回退:所有非 API 非静态资源请求返回 index.html
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/")
.resourceChain(true)
.addResolver(new PathResourceResolver() {
@Override
protected Resource getResource(String resourcePath, Resource location) throws IOException {
Resource resource = location.createRelative(resourcePath);
if (resource.exists() && resource.isReadable()) {
return resource;
}
// API 路径不处理
if (resourcePath.startsWith("api/")) {
return null;
}
// 回退到 index.html(支持前端路由)
return new ClassPathResource("static/index.html");
}
});
}
}