diff --git a/admin.html b/admin.html new file mode 100644 index 00000000..ea275476 --- /dev/null +++ b/admin.html @@ -0,0 +1,14 @@ + + +
+ + + + ++
{makeHighlight(content.desc, style.highlightAnim)}
diff --git a/src/mainPage/shared/auth/store.js b/src/mainPage/shared/auth/store.js index 133d016a..c57bb7b7 100644 --- a/src/mainPage/shared/auth/store.js +++ b/src/mainPage/shared/auth/store.js @@ -1,5 +1,6 @@ import { create } from "zustand"; import tokenSaver from "@common/dataFetch/tokenSaver.js"; +import { SERVICE_TOKEN_ID } from "@common/constants.js"; const userStore = create(() => ({ isLogin: false, @@ -23,8 +24,8 @@ export function logout() { } export function initLoginState() { - tokenSaver.init(); - const token = tokenSaver.get(); + tokenSaver.init(SERVICE_TOKEN_ID); + const token = tokenSaver.get(SERVICE_TOKEN_ID); const userName = parseTokenToUserName(token); if (token === null) userStore.setState(() => ({ isLogin: false, userName: "" })); diff --git a/src/mainPage/shared/realtimeEvent/getEventDateState.js b/src/mainPage/shared/realtimeEvent/getEventDateState.js index 7ad0d42c..c0b1b9ef 100644 --- a/src/mainPage/shared/realtimeEvent/getEventDateState.js +++ b/src/mainPage/shared/realtimeEvent/getEventDateState.js @@ -6,4 +6,4 @@ export default function getEventDateState(currrentTimeDate, eventTimeDate) { if (currentTime < eventTime) return "default"; if (currentTime < eventEndTime) return "active"; return "ended"; -} \ No newline at end of file +} diff --git a/src/mainPage/shared/scroll/constants.js b/src/mainPage/shared/scroll/constants.js index 8c87183b..c8b8bc20 100644 --- a/src/mainPage/shared/scroll/constants.js +++ b/src/mainPage/shared/scroll/constants.js @@ -3,4 +3,4 @@ export const OTHER_SECTION = 0; export const INTERACTION_SECTION = 1; export const DETAIL_SECTION = 2; export const COMMENT_SECTION = 3; -export const FCFS_SECTION = 4; \ No newline at end of file +export const FCFS_SECTION = 4; diff --git a/vite-devRouter.js b/vite-devRouter.js new file mode 100644 index 00000000..ab85f5f9 --- /dev/null +++ b/vite-devRouter.js @@ -0,0 +1,33 @@ +// from monument gallery +export default function devRouter(rawRouteList) { + // 문자열로 된 route list를 정규표현식으로 변환하고, 정규표현식이 아닌 것들을 제거합니다. + const routeList = rawRouteList + .map(([route, html]) => { + if (typeof route === "string") { + route = new RegExp(`^${route.replace(/\*/g, ".*").replace(/\?/g, ".")}/?$`); + } + return [route, html]; + }) + .filter(([route]) => route instanceof RegExp); + + // 요청한 패스가 설정된 라우팅 경로에 맞는지 확인합니다. + function foundRoute(path) { + for (let [route, html] of routeList) { + if (route.test(path)) return html; + } + return null; + } + + return { + name: "route-server", + configureServer(server) { + server.middlewares.use((req, res, next) => { + const htmlPath = foundRoute(req.originalUrl); + if (htmlPath === null) return next(); + req.url = htmlPath; + req.originalUrl = htmlPath; + next(); + }); + }, + }; +} \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 81964c96..34fa7ca0 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,12 +1,23 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; -import { resolve } from "path"; +import devRouter from "./vite-devRouter.js"; +import { resolve } from "node:path"; +import { fileURLToPath } from "node:url"; import svgr from "vite-plugin-svgr"; +const __dirname = fileURLToPath(new URL('.', import.meta.url)); + // https://vitejs.dev/config/ export default defineConfig({ base: "./", - plugins: [react(), svgr()], + plugins: [ + devRouter([ + ["/admin", "/admin.html"], + ["/admin/*", "/admin.html"], + ]), + react(), + svgr() + ], resolve: { alias: [ { find: "@", replacement: resolve(__dirname, "src") },