mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
build: custom base path not work
This commit is contained in:
@@ -29,7 +29,7 @@ public class ViewController {
|
|||||||
@GetMapping({"/api/search", "/api/search.data"})
|
@GetMapping({"/api/search", "/api/search.data"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String handleSearch(HttpServletRequest request, HttpServletResponse response) {
|
public String handleSearch(HttpServletRequest request, HttpServletResponse response) {
|
||||||
String fullPath = request.getRequestURI();
|
String fullPath = request.getRequestURI().replace(request.getContextPath(), "");
|
||||||
String relativePath = fullPath.substring(1);
|
String relativePath = fullPath.substring(1);
|
||||||
return renderFileData(relativePath, response);
|
return renderFileData(relativePath, response);
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ public class ViewController {
|
|||||||
@GetMapping({"/ui/docs/*.data", "/ui/*.data"})
|
@GetMapping({"/ui/docs/*.data", "/ui/*.data"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String handleDataFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
public String handleDataFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
String fullPath = request.getRequestURI();
|
String fullPath = request.getRequestURI().replace(request.getContextPath(), "");
|
||||||
String relativePath = fullPath.substring(4);
|
String relativePath = fullPath.substring(4);
|
||||||
return renderFileData(relativePath, response);
|
return renderFileData(relativePath, response);
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public class ViewController {
|
|||||||
|
|
||||||
@GetMapping("/ui/**")
|
@GetMapping("/ui/**")
|
||||||
public String handleHtmlView(HttpServletRequest request) {
|
public String handleHtmlView(HttpServletRequest request) {
|
||||||
String fullPath = request.getRequestURI();
|
String fullPath = request.getRequestURI().replace(request.getContextPath(), "");
|
||||||
if ("/ui".equals(fullPath) || "/ui/".equals(fullPath)) {
|
if ("/ui".equals(fullPath) || "/ui/".equals(fullPath)) {
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-2
@@ -1,4 +1,4 @@
|
|||||||
import { existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
import { existsSync, mkdirSync, readdirSync, rmSync, statSync } from "node:fs";
|
||||||
import { cp } from "node:fs/promises";
|
import { cp } from "node:fs/promises";
|
||||||
import { join, resolve } from "node:path";
|
import { join, resolve } from "node:path";
|
||||||
|
|
||||||
@@ -9,6 +9,31 @@ const TEMPLATES_DIR = join(BASE_DIR, "templates");
|
|||||||
const BUILD_DIR = resolve("build/client");
|
const BUILD_DIR = resolve("build/client");
|
||||||
const BUILD_ASSERTS_DIR = join(BUILD_DIR, "assets");
|
const BUILD_ASSERTS_DIR = join(BUILD_DIR, "assets");
|
||||||
|
|
||||||
|
function findUiDirectory(baseDir, maxDepth = 5) {
|
||||||
|
function search(currentDir, depth) {
|
||||||
|
if (depth > maxDepth) return null;
|
||||||
|
|
||||||
|
const entries = readdirSync(currentDir);
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
const fullPath = join(currentDir, entry);
|
||||||
|
|
||||||
|
if (!statSync(fullPath).isDirectory()) continue;
|
||||||
|
|
||||||
|
if (entry === "ui") {
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const found = search(fullPath, depth + 1);
|
||||||
|
if (found) return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return search(baseDir, 0);
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
if (!existsSync(BUILD_DIR)) {
|
if (!existsSync(BUILD_DIR)) {
|
||||||
console.error(`Error: ${BUILD_DIR} does not exist`);
|
console.error(`Error: ${BUILD_DIR} does not exist`);
|
||||||
@@ -32,7 +57,13 @@ async function main() {
|
|||||||
console.error("Error copying assets:", err);
|
console.error("Error copying assets:", err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
await cp(join(BUILD_DIR, "ui"), TEMPLATES_DIR, { recursive: true });
|
|
||||||
|
const uiDir = findUiDirectory(BUILD_DIR);
|
||||||
|
if (!uiDir) {
|
||||||
|
console.error(`Error: ui directory not found in ${BUILD_DIR}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
await cp(uiDir, join(TEMPLATES_DIR), { recursive: true });
|
||||||
console.log("SpringBoot resources updated successfully");
|
console.log("SpringBoot resources updated successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { env } from "node:process";
|
||||||
import { reactRouter } from "@react-router/dev/vite";
|
import { reactRouter } from "@react-router/dev/vite";
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
import mdx from "fumadocs-mdx/vite";
|
import mdx from "fumadocs-mdx/vite";
|
||||||
@@ -7,6 +8,7 @@ import tsconfigPaths from "vite-tsconfig-paths";
|
|||||||
import * as MdxConfig from "./source.config";
|
import * as MdxConfig from "./source.config";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
base: `${env.VITE_APP_API_URL}/`,
|
||||||
plugins: [
|
plugins: [
|
||||||
mdx(MdxConfig),
|
mdx(MdxConfig),
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
|
|||||||
Reference in New Issue
Block a user