Skip to content

Commit

Permalink
♻️ refactor(配置): 更新Angular环境配置,优化编辑器设置,修复格式化问题
Browse files Browse the repository at this point in the history
更新了ng-ui项目的Angular环境配置文件和代理配置,以支持开发环境的快速启动。
同时,对编辑器的默认格式化设置进行了优化,确保团队成员使用一致的代码风格。另外,还修复了http.Interceptor.ts文件中的一个格式化小问题。

此重构优化了开发环境配置和代码的可读性,不影响程序的功能性。
  • Loading branch information
vnobo committed Jul 4, 2024
1 parent ea88fc8 commit 9c3372a
Show file tree
Hide file tree
Showing 82 changed files with 2,466 additions and 390 deletions.
1 change: 1 addition & 0 deletions boot/platform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {
implementation("com.google.guava:guava:33.+")
implementation("com.github.f4b6a3:ulid-creator:5.+")

implementation("org.springframework.security:spring-security-rsocket")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
import org.springframework.security.config.annotation.rsocket.RSocketSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.rsocket.core.PayloadSocketAcceptorInterceptor;
import org.springframework.security.web.server.SecurityWebFilterChain;
import org.springframework.security.web.server.authentication.HttpBasicServerAuthenticationEntryPoint;
import org.springframework.security.web.server.authentication.logout.*;
Expand Down Expand Up @@ -56,10 +58,17 @@ public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}

@Bean
public PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
rsocket.authorizePayload(authorize -> authorize.anyRequest().permitAll().anyExchange().permitAll())
.simpleAuthentication(Customizer.withDefaults());
return rsocket.build();
}

@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange(exchange -> {
exchange.pathMatchers("/captcha/code", "/oauth2/qr/code").permitAll();
exchange.pathMatchers("/captcha/code", "/oauth2/qr/code","/command/v1/send").permitAll();
exchange.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll();
exchange.pathMatchers("/tenants/**", "/users/**", "/groups/**")
.hasAnyRole("SYSTEM_ADMINISTRATORS", "ADMINISTRATORS");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.platform.boot.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.ReactivePageableHandlerMethodArgumentResolver;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;

import java.net.URI;

/**
* @author <a href="https://github.com/vnobo">Alex bob</a>
*/
Expand All @@ -16,6 +22,16 @@
@EnableAsync
public class WebConfiguration implements WebFluxConfigurer {

@Value("${server.port:8080}")
private Integer serverPort;

@Bean
public RSocketRequester rSocketRequester(RSocketRequester.Builder requesterBuilder, RSocketMessageHandler handler) {
URI url = URI.create("http://localhost:" + serverPort + "/rsocket");
return requesterBuilder.setupData("CommandClient").setupRoute("connect.setup")
.rsocketConnector(connector -> connector.acceptor(handler.responder())).websocket(url);
}

@Override
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
ReactivePageableHandlerMethodArgumentResolver pageableResolver =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.platform.boot.relational.rsocket;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
* @author <a href="https://github.com/vnobo">Alex Bob</a>
*/
@Log4j2
@RestController
@RequestMapping("/command/v1")
@RequiredArgsConstructor
public class CommandController {

private final RSocketRequester rSocketRequester;

@PostMapping("send")
public Mono<MessageOut> send(@RequestBody CommandRequest command) {
var dataFlux = Mono.just(MessageIn.of(command.getType(), command.getCommand(), null));
return this.rSocketRequester.route("request.sender")
.data(dataFlux).retrieveMono(MessageOut.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.platform.boot.relational.rsocket;

import lombok.Data;

import java.io.Serializable;

/**
* @author <a href="https://github.com/vnobo">Alex Bob</a>
*/
@Data
public class CommandRequest implements Serializable {

private MessageType type;
private String command;
private String content;

}
42 changes: 42 additions & 0 deletions ng-ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
12 changes: 12 additions & 0 deletions ng-ui/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"trailingComma": "es5",
"bracketSameLine": true,
"printWidth": 120,
"endOfLine": "auto"
}
2 changes: 1 addition & 1 deletion ng-ui/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"url": "http://localhost:9876/debug.html"
}
]
}
}
4 changes: 2 additions & 2 deletions ng-ui/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
"editor.formatOnSave": true,
}
34 changes: 16 additions & 18 deletions ng-ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "sass"
"style": "scss"
}
},
"root": "projects/web",
Expand All @@ -20,9 +20,9 @@
"outputPath": "dist/web",
"index": "projects/web/src/index.html",
"browser": "projects/web/src/main.ts",
"polyfills": [],
"polyfills": ["@angular/localize/init", "zone.js"],
"tsConfig": "projects/web/tsconfig.app.json",
"inlineStyleLanguage": "sass",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
Expand All @@ -37,24 +37,20 @@
"styles": [
{
"input": "node_modules/bootstrap/dist/css/bootstrap.css",
"inject": false,
"bundleName": "bootstrap"
},
{
"input": "node_modules/bootstrap-icons/font/bootstrap-icons.css",
"inject": false,
"bundleName": "icons"
},
{
"input": "projects/web/src/styles.sass",
"inject": false,
"input": "projects/web/src/styles.scss",
"bundleName": "main"
}
],
"scripts": [
{
"input": "node_modules/bootstrap/dist/js/bootstrap.bundle.js",
"inject": false,
"bundleName": "bootstrap"
}
],
Expand Down Expand Up @@ -91,7 +87,13 @@
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
"sourceMap": true,
"fileReplacements": [
{
"replace": "projects/web/environments/environment.ts",
"with": "projects/web/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "production"
Expand All @@ -103,7 +105,8 @@
"buildTarget": "web:build:production"
},
"development": {
"buildTarget": "web:build:development"
"buildTarget": "web:build:development",
"proxyConfig": "proxy.conf.json"
}
},
"defaultConfiguration": "development"
Expand All @@ -114,7 +117,7 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [],
"polyfills": ["@angular/localize/init", "zone.js", "zone.js/testing"],
"tsConfig": "projects/web/tsconfig.spec.json",
"inlineStyleLanguage": "sass",
"assets": [
Expand All @@ -123,9 +126,7 @@
"input": "projects/web/public"
}
],
"styles": [
"projects/web/src/styles.sass"
],
"styles": ["projects/web/src/styles.sass"],
"scripts": []
}
}
Expand Down Expand Up @@ -156,10 +157,7 @@
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "projects/commons/tsconfig.spec.json",
"polyfills": [
"zone.js",
"zone.js/testing"
]
"polyfills": ["zone.js", "zone.js/testing"]
}
}
}
Expand Down
71 changes: 71 additions & 0 deletions ng-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9c3372a

Please sign in to comment.