博客的前端以jar包形式导入到后台服务

This commit is contained in:
Acyco 2023-12-10 22:49:37 +08:00 committed by xiaozzzi
parent 8839af682b
commit 853c6866f6
10 changed files with 114 additions and 6 deletions

View File

@ -17,6 +17,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>com.blossom</groupId>
<artifactId>blossom-web</artifactId>
<version>1.10.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>com.blossom</groupId> <groupId>com.blossom</groupId>

View File

@ -12,9 +12,7 @@ import org.springframework.core.env.Environment;
import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer; import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
@ -82,7 +80,24 @@ public class WebConfigurer implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(userTypeInterceptor()).addPathPatterns("/**"); registry.addInterceptor(userTypeInterceptor())
.addPathPatterns("/**")
.excludePathPatterns(
"/blog/**",
"/assets/**"
);
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/blog/").setViewName("/blog/index.html");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/blog/**").addResourceLocations("classpath:/META-INF/resources/webjars/blossom-web/");
registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/META-INF/resources/webjars/blossom-web/assets/");
} }
@Bean @Bean

View File

@ -51,6 +51,7 @@ project:
- /sentinel/** - /sentinel/**
- /editor/** - /editor/**
- /blog/** - /blog/**
- /assets/**
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ Cache/Redis ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ Cache/Redis ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
cache: # 缓存 cache: # 缓存
names-config: # 缓存键超时时间配置 names-config: # 缓存键超时时间配置
@ -76,3 +77,6 @@ project:
domain: "http://localhost:9999/pic/" domain: "http://localhost:9999/pic/"
# 请以 / 开头, / 结尾, 简短的路径在文章中有更好的显示效果, 过长一定程度会使文章内容混乱 # 请以 / 开头, / 结尾, 简短的路径在文章中有更好的显示效果, 过长一定程度会使文章内容混乱
default-path: "/home/bl/img/" default-path: "/home/bl/img/"
server:
servlet:
context-path: /dev

View File

@ -49,6 +49,8 @@ project:
multi-place-login: true # 客户端是否允许多地登录 multi-place-login: true # 客户端是否允许多地登录
white-list: # 白名单 white-list: # 白名单
- /sentinel/** - /sentinel/**
- /blog/**
- /assets/**
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ Cache/Redis ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ Cache/Redis ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
cache: # 缓存 cache: # 缓存
names-config: # 缓存键超时时间配置 names-config: # 缓存键超时时间配置

1
blossom-web/.env Normal file
View File

@ -0,0 +1 @@
VITE_BLOSSOM_BASE_URI=/

View File

@ -0,0 +1 @@
VITE_BLOSSOM_BASE_URI=/dev

View File

@ -9,6 +9,7 @@ lerna-debug.log*
stats.html stats.html
node_modules node_modules
target
.DS_Store .DS_Store
dist dist
dist-ssr dist-ssr

73
blossom-web/pom.xml Normal file
View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blossom</groupId>
<artifactId>blossom-web</artifactId>
<version>1.10.0-SNAPSHOT</version>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub MetaCode Apache Maven Packages</name>
<url>https://maven.pkg.github.com/metacode-project/metacode-maven-packages</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>1.14.0</version>
<configuration>
<installDirectory>target</installDirectory>
<nodeVersion>v16.13.1</nodeVersion>
<yarnVersion>v1.22.19</yarnVersion>
</configuration>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
</execution>
<execution>
<id>yarn config set registry</id>
<goals>
<goal>yarn</goal>
</goals>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>yarn build</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>dist</directory>
<targetPath>META-INF/resources/webjars/blossom-web</targetPath>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -34,7 +34,7 @@ const blossom = {
*/ */
DOMAIN: { DOMAIN: {
// 将该值填写为你的后台访问地址, 与 blossom 客户端登录页面填写的地址相同 // 将该值填写为你的后台访问地址, 与 blossom 客户端登录页面填写的地址相同
PRD: 'https://www.wangyunf.com/bl/', PRD: import.meta.env.VITE_BLOSSOM_BASE_URI,
// 将该值填写你开放为博客的用户ID // 将该值填写你开放为博客的用户ID
USER_ID: 1 USER_ID: 1
}, },

View File

@ -16,6 +16,12 @@ export default defineConfig({
base: './', base: './',
server: { server: {
host: "0.0.0.0", host: "0.0.0.0",
// 开发环境代理
proxy: {
'/dev': {
target:'http://127.0.0.1:9999/',
},
},
port: 5174, port: 5174,
//vue3 vite配置热更新不用手动刷新 //vue3 vite配置热更新不用手动刷新
hmr: true hmr: true