viewlogic 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viewlogic-router.js +24 -8
- package/dist/viewlogic-router.js.map +2 -2
- package/dist/viewlogic-router.min.js +3 -3
- package/dist/viewlogic-router.min.js.map +3 -3
- package/package.json +1 -1
- package/src/core/RouteLoader.js +7 -4
- package/src/plugins/I18nManager.js +3 -2
- package/src/viewlogic-router.js +20 -4
package/package.json
CHANGED
package/src/core/RouteLoader.js
CHANGED
|
@@ -32,7 +32,7 @@ export class RouteLoader {
|
|
|
32
32
|
const module = await import(importPath);
|
|
33
33
|
script = module.default;
|
|
34
34
|
} else {
|
|
35
|
-
// 개발 모드:
|
|
35
|
+
// 개발 모드: basePath는 이미 origin이 포함되어 있음
|
|
36
36
|
const importPath = `${this.config.basePath}/logic/${routeName}.js`;
|
|
37
37
|
this.log('debug', `Loading development route: ${importPath}`);
|
|
38
38
|
const module = await import(importPath);
|
|
@@ -63,7 +63,8 @@ export class RouteLoader {
|
|
|
63
63
|
*/
|
|
64
64
|
async loadTemplate(routeName) {
|
|
65
65
|
try {
|
|
66
|
-
const
|
|
66
|
+
const templatePath = `${this.config.basePath}/views/${routeName}.html`;
|
|
67
|
+
const response = await fetch(templatePath);
|
|
67
68
|
if (!response.ok) throw new Error(`Template not found: ${response.status}`);
|
|
68
69
|
const template = await response.text();
|
|
69
70
|
this.log('debug', `Template '${routeName}' loaded successfully`);
|
|
@@ -80,7 +81,8 @@ export class RouteLoader {
|
|
|
80
81
|
*/
|
|
81
82
|
async loadStyle(routeName) {
|
|
82
83
|
try {
|
|
83
|
-
const
|
|
84
|
+
const stylePath = `${this.config.basePath}/styles/${routeName}.css`;
|
|
85
|
+
const response = await fetch(stylePath);
|
|
84
86
|
if (!response.ok) throw new Error(`Style not found: ${response.status}`);
|
|
85
87
|
const style = await response.text();
|
|
86
88
|
this.log('debug', `Style '${routeName}' loaded successfully`);
|
|
@@ -97,7 +99,8 @@ export class RouteLoader {
|
|
|
97
99
|
*/
|
|
98
100
|
async loadLayout(layoutName) {
|
|
99
101
|
try {
|
|
100
|
-
const
|
|
102
|
+
const layoutPath = `${this.config.basePath}/layouts/${layoutName}.html`;
|
|
103
|
+
const response = await fetch(layoutPath);
|
|
101
104
|
if (!response.ok) throw new Error(`Layout not found: ${response.status}`);
|
|
102
105
|
const layout = await response.text();
|
|
103
106
|
|
|
@@ -188,8 +188,9 @@ export class I18nManager {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
try {
|
|
191
|
-
// JSON 파일로 변경
|
|
192
|
-
const
|
|
191
|
+
// JSON 파일로 변경 - config의 i18nPath 사용
|
|
192
|
+
const i18nPath = `${this.router.config.i18nPath}/${language}.json`;
|
|
193
|
+
const response = await fetch(i18nPath);
|
|
193
194
|
if (!response.ok) {
|
|
194
195
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
195
196
|
}
|
package/src/viewlogic-router.js
CHANGED
|
@@ -38,8 +38,10 @@ export class ViewLogicRouter {
|
|
|
38
38
|
* 설정 빌드 (분리하여 가독성 향상)
|
|
39
39
|
*/
|
|
40
40
|
_buildConfig(options) {
|
|
41
|
+
const currentOrigin = window.location.origin;
|
|
42
|
+
|
|
41
43
|
const defaults = {
|
|
42
|
-
basePath:
|
|
44
|
+
basePath: `${currentOrigin}/src`,
|
|
43
45
|
mode: 'hash',
|
|
44
46
|
cacheMode: 'memory',
|
|
45
47
|
cacheTTL: 300000,
|
|
@@ -47,12 +49,13 @@ export class ViewLogicRouter {
|
|
|
47
49
|
useLayout: true,
|
|
48
50
|
defaultLayout: 'default',
|
|
49
51
|
environment: 'development',
|
|
50
|
-
routesPath:
|
|
52
|
+
routesPath: `${currentOrigin}/routes`,
|
|
51
53
|
enableErrorReporting: true,
|
|
52
54
|
useComponents: true,
|
|
53
55
|
componentNames: ['Button', 'Modal', 'Card', 'Toast', 'Input', 'Tabs', 'Checkbox', 'Alert', 'DynamicInclude', 'HtmlInclude'],
|
|
54
56
|
useI18n: true,
|
|
55
57
|
defaultLanguage: 'ko',
|
|
58
|
+
i18nPath: `${currentOrigin}/i18n`,
|
|
56
59
|
logLevel: 'info',
|
|
57
60
|
authEnabled: false,
|
|
58
61
|
loginRoute: 'login',
|
|
@@ -74,7 +77,20 @@ export class ViewLogicRouter {
|
|
|
74
77
|
logSecurityWarnings: true
|
|
75
78
|
};
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
const config = { ...defaults, ...options };
|
|
81
|
+
|
|
82
|
+
// 사용자가 제공한 basePath와 routesPath에 origin이 없으면 추가
|
|
83
|
+
if (options.basePath && !options.basePath.startsWith('http')) {
|
|
84
|
+
config.basePath = `${currentOrigin}${options.basePath}`;
|
|
85
|
+
}
|
|
86
|
+
if (options.routesPath && !options.routesPath.startsWith('http')) {
|
|
87
|
+
config.routesPath = `${currentOrigin}${options.routesPath}`;
|
|
88
|
+
}
|
|
89
|
+
if (options.i18nPath && !options.i18nPath.startsWith('http')) {
|
|
90
|
+
config.i18nPath = `${currentOrigin}${options.i18nPath}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return config;
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
|
|
@@ -114,7 +130,7 @@ export class ViewLogicRouter {
|
|
|
114
130
|
if (this.config.useComponents) {
|
|
115
131
|
this.componentLoader = new ComponentLoader(this, {
|
|
116
132
|
...this.config,
|
|
117
|
-
basePath: this.config.basePath
|
|
133
|
+
basePath: `${this.config.basePath}/components`,
|
|
118
134
|
cache: true,
|
|
119
135
|
componentNames: this.config.componentNames
|
|
120
136
|
});
|