diff --git a/.gitignore b/.gitignore index 2d8ea4b..ff64658 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ out/ /logs/application.log /logs/ /.idea/ +/src/main/resources/static/ diff --git a/build.gradle b/build.gradle index 0be94ee..a577bb8 100644 --- a/build.gradle +++ b/build.gradle @@ -67,12 +67,12 @@ apply plugin: 'io.spring.dependency-management' apply plugin: 'java' -tasks.register('copyResources', Copy) { +/*tasks.register('copyResources', Copy) { from 'jambotron-ui/dist/jambotron-ui/browser' into 'src/main/resources/public' -} -processResources.dependsOn(copyResources) -compileJava.dependsOn(copyResources) +}*/ +//processResources.dependsOn(copyResources) +//compileJava.dependsOn(copyResources) //bootRun.dependsOn("flywayMigrate") //flyway { @@ -84,12 +84,18 @@ compileJava.dependsOn(copyResources) // locations = ['filesystem:src/main/resources/db.migration/'] //} -sourceSets { +/*sourceSets { main { resources { srcDir 'jambotron-ui/dist/jambotron-ui/browser' } } +}*/ + +tasks.register('copyAngularBuild', Copy) { + //dependsOn buildAngular + from 'jambotron-ui/dist/jambotron-ui' // Path to your Angular dist folder + into "src/main/resources/static" // Path INSIDE the WAR } tasks.named('test') { diff --git a/jambotron-ui/angular.json b/jambotron-ui/angular.json index 70ac9aa..2a6782c 100644 --- a/jambotron-ui/angular.json +++ b/jambotron-ui/angular.json @@ -15,9 +15,12 @@ "prefix": "app", "architect": { "build": { - "builder": "@angular/build:application", + "builder": "@angular-devkit/build-angular:browser", "options": { - "browser": "src/main.ts", + "outputPath": "dist/jambotron-ui", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": [ "zone.js" ], @@ -37,12 +40,8 @@ "styles": [ "@angular/material/prebuilt-themes/azure-blue.css", "src/styles.scss" - ], - "server": "src/main.server.ts", - "outputMode": "server", - "ssr": { - "entry": "src/server.ts" - } + ] + }, "configurations": { "production": { @@ -50,7 +49,7 @@ { "type": "initial", "maximumWarning": "500kB", - "maximumError": "1MB" + "maximumError": "5MB" }, { "type": "anyComponentStyle", @@ -69,7 +68,7 @@ "defaultConfiguration": "production" }, "serve": { - "builder": "@angular/build:dev-server", + "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { "buildTarget": "jambotron-ui:build:production" @@ -81,7 +80,7 @@ "defaultConfiguration": "development" }, "extract-i18n": { - "builder": "@angular/build:extract-i18n" + "builder": "@angular-devkit/build-angular:extract-i18n" }, "test": { "builder": "@angular/build:karma", diff --git a/jambotron-ui/package.json b/jambotron-ui/package.json index 27242fb..b46da5f 100644 --- a/jambotron-ui/package.json +++ b/jambotron-ui/package.json @@ -35,7 +35,7 @@ "zone.js": "~0.15.0" }, "devDependencies": { - "@angular/build": "^20.0.2", + "@angular-devkit/build-angular": "^20.0.2", "@angular/cli": "^20.0.2", "@angular/compiler-cli": "^20.0.0", "@types/express": "^5.0.1", diff --git a/jambotron-ui/src/app/app.module.ts b/jambotron-ui/src/app/app.module.ts index 421f0dd..772334d 100644 --- a/jambotron-ui/src/app/app.module.ts +++ b/jambotron-ui/src/app/app.module.ts @@ -13,7 +13,7 @@ import {AdminComponent} from './admin-module/admin.component/admin.component'; import {AdminWelcomeComponent} from './admin-module/admin-welcome.component/admin-welcome.component'; import {SettingsComponent} from './admin-module/settings.component/settings.component'; import {SystemComponent} from './admin-module/system.component/system.component'; -import {appRouting} from './app.routes'; +import {AppRoutingModule} from './app.routes'; import {App} from './app'; @NgModule({ @@ -21,7 +21,7 @@ import {App} from './app'; ], imports: [ - appRouting, + AppRoutingModule, MainComponent, BrowserModule, MatIconModule, diff --git a/jambotron-ui/src/app/app.routes.ts b/jambotron-ui/src/app/app.routes.ts index e97767a..cd547c9 100644 --- a/jambotron-ui/src/app/app.routes.ts +++ b/jambotron-ui/src/app/app.routes.ts @@ -16,5 +16,9 @@ export const routes: Routes = [ } ]; -export const appRouting = RouterModule.forRoot(routes); +@NgModule({ + imports: [RouterModule.forRoot(routes)],//, { useHash: true } + exports: [RouterModule], +}) +export class AppRoutingModule {} diff --git a/jambotron-ui/src/app/main-module/main.component/main.component.html b/jambotron-ui/src/app/main-module/main.component/main.component.html index f60d02d..82e7c14 100644 --- a/jambotron-ui/src/app/main-module/main.component/main.component.html +++ b/jambotron-ui/src/app/main-module/main.component/main.component.html @@ -22,7 +22,7 @@ } @if (showAdminBoard) { - diff --git a/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java b/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java index 260f19b..a637531 100644 --- a/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java +++ b/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java @@ -2,10 +2,13 @@ package com.jambotronGroup.jambotron.configuretions; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - +/* @Configuration + +@EnableWebMvc public class MvcConfig implements WebMvcConfigurer { @Value("${spring.resources.static-locations}") String resourceLocations; @@ -13,7 +16,10 @@ public class MvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { //registry.addResourceHandler("/public/**").addResourceLocations(resourceLocations); - // registry.addResourceHandler("/media/**").addResourceLocations("resources/main/public/media/"); + registry.addResourceHandler("/**").addResourceLocations("classpath:/resources/"); + + //registry. + registry.addResourceHandler("/media/**").addResourceLocations("resources/main/public/media/"); } -} +}*/ diff --git a/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java b/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java index 101b6d1..df66fd9 100644 --- a/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java +++ b/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java @@ -15,7 +15,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.Charset; /* - @ControllerAdvice public class NotFoundHandler { @Value("${spa.default-file}") diff --git a/src/main/java/com/jambotronGroup/jambotron/controllers/RedirectController.java b/src/main/java/com/jambotronGroup/jambotron/controllers/RedirectController.java new file mode 100644 index 0000000..db09ee0 --- /dev/null +++ b/src/main/java/com/jambotronGroup/jambotron/controllers/RedirectController.java @@ -0,0 +1,12 @@ +package com.jambotronGroup.jambotron.controllers; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/*@Controller +public class RedirectController { + @RequestMapping(value = "/{path:[^\\.]*}") + public String redirect() { + return "forward:/index.html"; + } +}*/ diff --git a/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java b/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java index 958da04..6f28a33 100644 --- a/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java +++ b/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java @@ -106,6 +106,7 @@ public class WebSecurityConfig {// extends WebSecurityConfigurerAdapter { auth.requestMatchers("/api/auth/**").permitAll() .requestMatchers("/*", "/home", "/resources/**").permitAll() .requestMatchers("/resources/public/media/**").permitAll() + .requestMatchers("/resources/public/browser/**").permitAll() .requestMatchers("/media/**").permitAll() .requestMatchers("/api/test/**").permitAll() .requestMatchers("/api/tutorials").permitAll() diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 66f0cf0..f9cbfd8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -29,10 +29,12 @@ spring.mvc.throw-exception-if-no-handler-found=true # Disable the default mappings #spring.resources.add-mappings=false -spring.resources.static-locations=classpath:/public -spring.resources.cache.period=31557600s # 1 year if you want -spa.default-file=classpath:/public/browser/index.html - +# UI(index.html) location +#spring.resources.static-locations=classpath:/public/browser/ +# +#spring.resources.cache.period=31557600s # 1 year if you want +#spa.default-file=classpath:/public/browser/index.html +# spring.docker.compose.file=../Docker/docker-compose.yml @@ -44,5 +46,7 @@ spring.flyway.password=postgrespw spring.flyway.url=jdbc:postgresql://localhost:5432/jambotronDB -spring.ai.zhipuai.base-url=https://open.bigmodel.cn/api/paas/v3 -spring.ai.zhipuai.api-key = 628447c8c65845a48a7226391464a2ea.Dw8ci6TiW0BRF5LI \ No newline at end of file + + +//spring.ai.zhipuai.base-url=https://open.bigmodel.cn/api/paas/v3 +//spring.ai.zhipuai.api-key = 628447c8c65845a48a7226391464a2ea.Dw8ci6TiW0BRF5LI \ No newline at end of file