
--- client/views/pages/AppRouter.js
+++ client/views/pages/AppRouter.js
... | ... | @@ -21,14 +21,14 @@ |
21 | 21 |
/* 메인화면 */ |
22 | 22 |
{ path: '/', name: '/', component: Main}, |
23 | 23 |
{ path: '/main2.page', name: '/main2', component: Main2}, |
24 |
- { path: '/ChuljangList.page', name: 'ChuljangList', component: ChuljangList }, |
|
25 |
- { path: '/HyugaList.page', name: 'HyugaList', component: HyugaList }, |
|
26 |
- { path: '/HyugaInsert.page', name: 'HyugaInsert', component: HyugaInsert }, |
|
27 |
- { path: '/ProjectList.page', name: 'ProjectList', component: ProjectList }, |
|
28 |
- { path: '/DeptList.page', name: 'DeptList', component: DeptList }, |
|
29 |
- { path: '/EmployeeList.page', name: 'EmployeeList', component: EmployeeList }, |
|
30 |
- { path: '/NoticeList.page', name: 'NoticeList', component: NoticeList }, |
|
31 |
- { path: '/PubHoliyday.page', name: 'PubHoliyday', component: PubHoliyday }, |
|
24 |
+ { path: '/ChuljangList', name: 'ChuljangList', component: ChuljangList }, |
|
25 |
+ { path: '/HyugaList', name: 'HyugaList', component: HyugaList }, |
|
26 |
+ { path: '/HyugaInsert', name: 'HyugaInsert', component: HyugaInsert }, |
|
27 |
+ { path: '/ProjectList', name: 'ProjectList', component: ProjectList }, |
|
28 |
+ { path: '/DeptList', name: 'DeptList', component: DeptList }, |
|
29 |
+ { path: '/EmployeeList', name: 'EmployeeList', component: EmployeeList }, |
|
30 |
+ { path: '/NoticeList', name: 'NoticeList', component: NoticeList }, |
|
31 |
+ { path: '/PubHoliyday', name: 'PubHoliyday', component: PubHoliyday }, |
|
32 | 32 |
]; |
33 | 33 |
|
34 | 34 |
const AppRouter = createRouter({ |
--- server/modules/web/Server.js
+++ server/modules/web/Server.js
... | ... | @@ -9,6 +9,9 @@ |
9 | 9 |
const express = require('express'); |
10 | 10 |
const webServer = express(); |
11 | 11 |
|
12 |
+const FS = require("fs"); |
|
13 |
+const Transform = require("stream").Transform; |
|
14 |
+ |
|
12 | 15 |
|
13 | 16 |
/** |
14 | 17 |
* @author : 최정우 |
... | ... | @@ -51,9 +54,29 @@ |
51 | 54 |
* @since : 2022.09.20 |
52 | 55 |
* @dscription : 화면요청 URL 처리 |
53 | 56 |
*/ |
54 |
-webServer.get('*.page', function (request, response, next) { |
|
55 |
- //기능구현예정 |
|
56 |
-}) |
|
57 |
+webServer.get('/:pageName', function (request, response, next) { |
|
58 |
+ const pageName = request.params.pageName; // 'ChuljangList' 등의 동적 페이지 이름 추출 |
|
59 |
+ |
|
60 |
+ // index.html을 스트리밍하여 페이지에 맞는 URL을 동적으로 설정 |
|
61 |
+ const StreamTransform = new Transform(); |
|
62 |
+ StreamTransform._transform = function (data, encoding, done) { |
|
63 |
+ let fileContent = data.toString(); |
|
64 |
+ |
|
65 |
+ // 특정 페이지에 맞는 URL을 변경하는 부분 |
|
66 |
+ let replaceBeforeContent = `<script id="app-start-vue-page">const APP_USER_HTTP_REQUEST_URL = '/';</script>`; |
|
67 |
+ let replaceAfterContent = `<script id="app-start-vue-page">const APP_USER_HTTP_REQUEST_URL = '/${pageName}';</script>`; |
|
68 |
+ |
|
69 |
+ // 파일 내용에서 URL을 변경 |
|
70 |
+ fileContent = fileContent.replace(replaceBeforeContent, replaceAfterContent); |
|
71 |
+ this.push(fileContent); |
|
72 |
+ done(); |
|
73 |
+ }; |
|
74 |
+ |
|
75 |
+ // index.html 파일을 스트리밍하여 반환 |
|
76 |
+ FS.createReadStream(`${BASE_DIR}/client/views/index.html`) |
|
77 |
+ .pipe(StreamTransform) |
|
78 |
+ .pipe(response); |
|
79 |
+}); |
|
57 | 80 |
|
58 | 81 |
/** |
59 | 82 |
* @author : 최정우 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?