refactor(sj_map_reduce): 重构打包时前端的处理
This commit is contained in:
parent
e27339661a
commit
1175e15be3
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,3 +32,4 @@ target/
|
||||
.flattened-pom.xml
|
||||
|
||||
data/
|
||||
rebel.xml
|
3
snail-job-server/.gitignore
vendored
3
snail-job-server/.gitignore
vendored
@ -30,3 +30,6 @@ target/
|
||||
|
||||
# Maven ignore
|
||||
.flattened-pom.xml
|
||||
|
||||
# Frontend
|
||||
/snail-job-server-ui/src/main/frontend/
|
@ -20,6 +20,7 @@
|
||||
<module>snail-job-server-retry-task</module>
|
||||
<module>snail-job-server-job-task</module>
|
||||
<module>snail-job-server-starter</module>
|
||||
<module>snail-job-server-ui</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
@ -53,6 +54,11 @@
|
||||
<artifactId>snail-job-server-job-task</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-server-ui</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-actor-typed_2.13</artifactId>
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.aizuda.snailjob.server.common.allocate.client;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.snailjob.server.common.ClientLoadBalance;
|
||||
import com.aizuda.snailjob.server.common.allocate.client.ClientLoadBalanceManager.AllocationAlgorithmEnum;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
@ -43,9 +42,15 @@ public class ClientLoadBalanceLRU implements ClientLoadBalance {
|
||||
}
|
||||
|
||||
// 删除已经下线的节点
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
for (String address : lruItem.keySet()) {
|
||||
if (!clientAllAddressSet.contains(address)) {
|
||||
lruItem.remove(address);
|
||||
delKeys.add(address);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(delKeys)) {
|
||||
for (String delKey : delKeys) {
|
||||
lruItem.remove(delKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,10 @@
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-server-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-server-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 52 KiB |
33
snail-job-server/snail-job-server-ui/README.md
Normal file
33
snail-job-server/snail-job-server-ui/README.md
Normal file
@ -0,0 +1,33 @@
|
||||
## 自定义前端指南
|
||||
|
||||
为了在项目中集成自定义前端界面,请按照以下步骤操作:
|
||||
|
||||
### 1. 创建前端目录
|
||||
|
||||
首先,在 [`snail-job-server-ui`]() 的 [`src/main`](src/main) 目录下创建一个名为 [`frontend`](src/main/frontend) 的新目录:
|
||||
|
||||
```
|
||||
snail-job-server-ui/
|
||||
└─ src/
|
||||
└─ main/
|
||||
└─ frontend/ # 新建的前端目录
|
||||
```
|
||||
|
||||
### 2. 拉取前端代码
|
||||
|
||||
使用 Git 命令拉取前端代码库到 frontend 目录中:
|
||||
|
||||
```bash
|
||||
cd src/main/frontend
|
||||
git clone https://gitee.com/opensnail/snail-job-admin.git
|
||||
```
|
||||
|
||||
> 注意:确保你在 [`frontend`](src/main/frontend) 目录中执行 `git clone` 命令,这样代码会被克隆到当前目录而不是创建一个新的子目录。
|
||||
|
||||
### 3. 自定义前端
|
||||
|
||||
在 [`frontend`](src/main/frontend) 目录中对前端代码进行必要的修改。你可以编辑文件、添加新文件或删除不必要的文件来满足你的自定义需求。
|
||||
|
||||
### 4. 打包程序
|
||||
|
||||
在 `Maven` 配置中找到 `skipFrontend` 选项,并确保其未被勾选,以便在打包时包含前端代码的修改,然后运行 `Maven` 打包命令来构建项目。
|
144
snail-job-server/snail-job-server-ui/pom.xml
Normal file
144
snail-job-server/snail-job-server-ui/pom.xml
Normal file
@ -0,0 +1,144 @@
|
||||
<?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>
|
||||
<parent>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-server</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>snail-job-server-ui</artifactId>
|
||||
<name>snail-job-server-ui</name>
|
||||
<description>snail-job-server-ui</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<node.version>v18.20.2</node.version>
|
||||
<pnpm.version>9.4.0</pnpm.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>none</mainClass> <!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
|
||||
<classifier>execute</classifier> <!-- 为了解决依赖模块找不到此模块中的类或属性 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven-clean-plugin.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src/main/frontend/</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
<includes>
|
||||
<include>dist/**</include>
|
||||
</includes>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<installDirectory>target</installDirectory>
|
||||
<workingDirectory>src/main/frontend</workingDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install node and pnpm</id>
|
||||
<goals>
|
||||
<goal>install-node-and-pnpm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<nodeVersion>${node.version}</nodeVersion>
|
||||
<pnpmVersion>${pnpm.version}</pnpmVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pnpm install</id>
|
||||
<goals>
|
||||
<goal>pnpm</goal>
|
||||
</goals>
|
||||
<phase>generate-resources</phase>
|
||||
<configuration>
|
||||
<arguments>install</arguments>
|
||||
<pnpmRegistryURL>https://registry.npmmirror.com</pnpmRegistryURL>
|
||||
<pnpmInheritsProxyConfigFromMaven>true</pnpmInheritsProxyConfigFromMaven>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pnpm build</id>
|
||||
<goals>
|
||||
<goal>pnpm</goal>
|
||||
</goals>
|
||||
<phase>generate-resources</phase>
|
||||
<configuration>
|
||||
<arguments>build</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/frontend/dist</directory>
|
||||
<targetPath>admin</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>skipFrontend</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
@ -0,0 +1,21 @@
|
||||
package com.aizuda.snailjob.server.ui.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.WebProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class SnailJobAdminServerUiAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public WebProperties webProperties() {
|
||||
WebProperties properties = new WebProperties();
|
||||
WebProperties.Resources resources = properties.getResources();
|
||||
resources.setStaticLocations(new String[]{"classpath:admin/"});
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.aizuda.snailjob.server.ui.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* 默认接口
|
||||
*
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-28 22:17
|
||||
*/
|
||||
@Controller
|
||||
public class WebController {
|
||||
|
||||
@GetMapping
|
||||
public String forwardIndex() {
|
||||
return "index";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
com.aizuda.snailjob.server.ui.config.SnailJobAdminServerUiAutoConfiguration
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue
Block a user