swico 0.6.0-beta33 → 0.6.0-beta34
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/package.json +1 -1
- package/src/index.react.d.ts +1 -1
- package/src/index.react.js +2 -2
- package/src/task.js +2 -2
- package/src/template/react/{reac-hooks.js → react-hooks.js} +1 -1
- package/src/template/vue/$env/index.d.ts +1 -0
- package/src/template/vue/$env/index.js +62 -0
- package/src/template/vue/$env/routes.d.ts +6 -0
- package/src/template/vue/$env/routes.js +3 -0
- package/src/template/vue/Container.d.ts +2 -0
- package/src/template/vue/Container.js +4 -0
- package/src/template/vue/vue-hooks.js +1 -1
- package/src/utils/config.js +3 -3
- /package/src/template/react/{.env → $env}/config.d.ts +0 -0
- /package/src/template/react/{.env → $env}/config.js +0 -0
- /package/src/template/react/{.env → $env}/history.d.ts +0 -0
- /package/src/template/react/{.env → $env}/history.js +0 -0
- /package/src/template/react/{.env → $env}/index.d.ts +0 -0
- /package/src/template/react/{.env → $env}/index.js +0 -0
- /package/src/template/react/{.env → $env}/routes.d.ts +0 -0
- /package/src/template/react/{.env → $env}/routes.js +0 -0
- /package/src/template/react/{reac-hooks.d.ts → react-hooks.d.ts} +0 -0
- /package/src/template/vue/{.env → $env}/config.d.ts +0 -0
- /package/src/template/vue/{.env → $env}/config.js +0 -0
- /package/src/template/vue/{.env/Container.vue → Container.vue} +0 -0
package/package.json
CHANGED
package/src/index.react.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const Link: FC<{
|
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
}>;
|
|
12
12
|
export { Outlet } from 'react-router-dom';
|
|
13
|
-
export { useLocation } from './template/react/
|
|
13
|
+
export { useLocation } from './template/react/react-hooks';
|
|
14
14
|
export interface DefineSwicoConfigType {
|
|
15
15
|
(env: 'base', config: CustomConfigType['base']): any;
|
|
16
16
|
(env: 'dev', config: CustomConfigType['dev']): any;
|
package/src/index.react.js
CHANGED
|
@@ -13,8 +13,8 @@ var Link = function (_a) {
|
|
|
13
13
|
exports.Link = Link;
|
|
14
14
|
var react_router_dom_2 = require("react-router-dom");
|
|
15
15
|
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_dom_2.Outlet; } });
|
|
16
|
-
var
|
|
17
|
-
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return
|
|
16
|
+
var react_hooks_1 = require("./template/react/react-hooks");
|
|
17
|
+
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
|
|
18
18
|
var defineConfig = function (env, config) { return config; };
|
|
19
19
|
exports.defineConfig = defineConfig;
|
|
20
20
|
var defineGlobal = function (config) {
|
package/src/task.js
CHANGED
|
@@ -46,8 +46,8 @@ var copyVueFiles = function () { return __awaiter(void 0, void 0, void 0, functi
|
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
47
|
switch (_a.label) {
|
|
48
48
|
case 0:
|
|
49
|
-
filePath = path_1.default.resolve(__dirname, './template/vue
|
|
50
|
-
targetPath = path_1.default.resolve(__dirname, '../dist/src/template/vue
|
|
49
|
+
filePath = path_1.default.resolve(__dirname, './template/vue/Container.vue');
|
|
50
|
+
targetPath = path_1.default.resolve(__dirname, '../dist/src/template/vue/Container.vue');
|
|
51
51
|
return [4, fs_extra_1.default.copyFile(filePath, targetPath)];
|
|
52
52
|
case 1:
|
|
53
53
|
_a.sent();
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useLocation = void 0;
|
|
7
7
|
var react_router_dom_1 = require("react-router-dom");
|
|
8
|
-
var history_1 = require("
|
|
8
|
+
var history_1 = require("./$env/history");
|
|
9
9
|
var qs_1 = __importDefault(require("qs"));
|
|
10
10
|
var compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
|
|
11
11
|
var patternWithValuesParts = urlPatternWithValues.split('/');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
var vue_1 = require("vue");
|
|
8
|
+
var routes_1 = __importDefault(require("./routes"));
|
|
9
|
+
var vue_router_1 = require("vue-router");
|
|
10
|
+
var Container_1 = __importDefault(require("../Container"));
|
|
11
|
+
var config_1 = require("./config");
|
|
12
|
+
var Layout_1 = __importDefault(require("../../layout/Layout"));
|
|
13
|
+
var global_1 = __importDefault(require("../../global"));
|
|
14
|
+
var qs_1 = __importDefault(require("qs"));
|
|
15
|
+
var router = (0, vue_router_1.createRouter)({
|
|
16
|
+
history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
|
|
17
|
+
routes: routes_1.default
|
|
18
|
+
});
|
|
19
|
+
var app = (0, vue_1.createApp)(Container_1.default);
|
|
20
|
+
var Swico = { history: null };
|
|
21
|
+
Swico.history = {
|
|
22
|
+
push: function (options) {
|
|
23
|
+
if (typeof options === 'string') {
|
|
24
|
+
router.push(options);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
var query = options.query, name_1 = options.name, hash = options.hash, params = options.params, path = options.path;
|
|
28
|
+
router.push({ name: name_1, path: path, query: query, hash: hash, params: params });
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
replace: function (options) {
|
|
32
|
+
if (typeof options === 'string') {
|
|
33
|
+
router.replace(options);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
var query = options.query, name_2 = options.name, hash = options.hash, params = options.params, path = options.path;
|
|
37
|
+
router.replace({ name: name_2, path: path, query: query, hash: hash, params: params });
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
go: router.go,
|
|
41
|
+
back: router.back,
|
|
42
|
+
forward: router.forward,
|
|
43
|
+
get location() {
|
|
44
|
+
var lastIndexBase = config_1.routerBase[config_1.routerBase.length - 1];
|
|
45
|
+
var formatRouterBase = lastIndexBase === '/' ? config_1.routerBase.slice(0, config_1.routerBase.length - 1) : config_1.routerBase;
|
|
46
|
+
var _a = router.currentRoute.value, path = _a.path, params = _a.params, query = _a.query, name = _a.name, hash = _a.hash, fullPath = _a.fullPath;
|
|
47
|
+
return {
|
|
48
|
+
path: path,
|
|
49
|
+
pathname: formatRouterBase + path,
|
|
50
|
+
params: params,
|
|
51
|
+
query: query,
|
|
52
|
+
name: name,
|
|
53
|
+
hash: hash,
|
|
54
|
+
search: query ? qs_1.default.stringify(query) : ''
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
app.component('Layout', Layout_1.default);
|
|
59
|
+
app.use(router);
|
|
60
|
+
window.Swico = Swico;
|
|
61
|
+
(_a = global_1.default === null || global_1.default === void 0 ? void 0 : global_1.default.onInit) === null || _a === void 0 ? void 0 : _a.call(global_1.default, app, router);
|
|
62
|
+
app.mount('#root');
|
|
@@ -7,7 +7,7 @@ exports.useLocation = exports.getFormatRouterBase = void 0;
|
|
|
7
7
|
var vue_router_1 = require("vue-router");
|
|
8
8
|
var qs_1 = __importDefault(require("qs"));
|
|
9
9
|
var vue_1 = require("vue");
|
|
10
|
-
var config_1 = require("
|
|
10
|
+
var config_1 = require("./$env/config");
|
|
11
11
|
var getFormatRouterBase = function (routerBase) {
|
|
12
12
|
var lastIndexBase = routerBase[routerBase.length - 1];
|
|
13
13
|
return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
|
package/src/utils/config.js
CHANGED
|
@@ -288,7 +288,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
288
288
|
switch (_a.label) {
|
|
289
289
|
case 0:
|
|
290
290
|
copyTargetPath = path_1.default.resolve(projectPath, "./src/.swico".concat(envPath));
|
|
291
|
-
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType, "
|
|
291
|
+
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType, "/$env")), copyTargetPath, function (fileName) {
|
|
292
292
|
return !fileName.endsWith('.d.ts') &&
|
|
293
293
|
(templateType === 'vue'
|
|
294
294
|
? !['Container.js', 'vue-hooks.js'].includes(fileName)
|
|
@@ -305,7 +305,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
305
305
|
replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8');
|
|
306
306
|
hooksFilePath = path_1.default.resolve(projectPath, "./src/.swico/".concat(templateType, "-hooks.js"));
|
|
307
307
|
replaceHooksText = fs_extra_1.default.readFileSync(hooksFilePath, 'utf8');
|
|
308
|
-
replaceHooksText = replaceHooksText.replaceAll('
|
|
308
|
+
replaceHooksText = replaceHooksText.replaceAll('$env', ".".concat(env));
|
|
309
309
|
return [4, (0, tools_1.writeFile)(hooksFilePath, replaceHooksText)];
|
|
310
310
|
case 4:
|
|
311
311
|
_a.sent();
|
|
@@ -324,7 +324,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
324
324
|
return [3, 8];
|
|
325
325
|
case 8:
|
|
326
326
|
if (!(templateType === 'vue')) return [3, 10];
|
|
327
|
-
replaceIndexText = replaceIndexText.replace('"
|
|
327
|
+
replaceIndexText = replaceIndexText.replace('"../Container"', '"../Container.vue"');
|
|
328
328
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
|
|
329
329
|
case 9:
|
|
330
330
|
_a.sent();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|