@vc-shell/create-vc-app 1.0.174 → 1.0.176
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/CHANGELOG.md +13 -0
- package/dist/index.js +102 -55
- package/dist/templates/base/package.json +5 -5
- package/dist/templates/base/src/modules/mocks.ts +50 -0
- package/dist/templates/base/vite.config.mts +1 -10
- package/dist/templates/modules/classic-module/composables/useDetails/index.ts +20 -0
- package/dist/templates/modules/classic-module/composables/useList/index.ts +25 -0
- package/dist/templates/{variants/dynamic/src/modules → modules}/dynamic-module/composables/useDetails/index.ts +3 -30
- package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/composables/useList/index.ts +2 -39
- package/dist/templates/variants/both/src/main.ts +2 -3
- package/dist/templates/variants/classic/src/main.ts +2 -3
- package/dist/templates/variants/dynamic/src/main.ts +2 -3
- package/package.json +2 -2
- package/dist/templates/variants/both/src/modules/classic-module/composables/useDetails/index.ts +0 -54
- package/dist/templates/variants/both/src/modules/classic-module/composables/useList/index.ts +0 -58
- package/dist/templates/variants/both/src/modules/dynamic-module/composables/useDetails/index.ts +0 -83
- package/dist/templates/variants/classic/src/modules/classic-module/components/index.ts +0 -1
- package/dist/templates/variants/classic/src/modules/classic-module/composables/index.ts +0 -2
- package/dist/templates/variants/classic/src/modules/classic-module/composables/useDetails/index.ts +0 -54
- package/dist/templates/variants/classic/src/modules/classic-module/composables/useList/index.ts +0 -58
- package/dist/templates/variants/classic/src/modules/classic-module/index.ts +0 -9
- package/dist/templates/variants/classic/src/modules/classic-module/locales/en.json +0 -46
- package/dist/templates/variants/classic/src/modules/classic-module/locales/index.ts +0 -2
- package/dist/templates/variants/classic/src/modules/classic-module/pages/details.vue +0 -86
- package/dist/templates/variants/classic/src/modules/classic-module/pages/index.ts +0 -2
- package/dist/templates/variants/classic/src/modules/classic-module/pages/list.vue +0 -270
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/components/DynamicItemsMobileGridView.vue +0 -39
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/components/index.ts +0 -3
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/composables/index.ts +0 -2
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/composables/useList/index.ts +0 -85
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/index.ts +0 -9
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/locales/en.json +0 -49
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/locales/index.ts +0 -2
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/pages/details.ts +0 -39
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/pages/index.ts +0 -4
- package/dist/templates/variants/dynamic/src/modules/dynamic-module/pages/list.ts +0 -65
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/components/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/composables/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/locales/en.json +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/locales/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/pages/details.vue +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/pages/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/classic-module/pages/list.vue +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/components/DynamicItemsMobileGridView.vue +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/components/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/composables/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/locales/en.json +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/locales/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/pages/details.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/pages/index.ts +0 -0
- /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/pages/list.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [1.0.176](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.175...v1.0.176) (2024-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## [1.0.175](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.174...v1.0.175) (2024-03-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **create-vc-app:** remove redundant and dupe code, decouple mocks, remove demo mode from configs ([2b3fd6b](https://github.com/VirtoCommerce/vc-shell/commit/2b3fd6b945c21b5a3f4a177a7e6a183662eb480d))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [1.0.174](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.173...v1.0.174) (2024-03-06)
|
|
2
15
|
|
|
3
16
|
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import $ from "prompts";
|
|
3
|
+
import x from "mri";
|
|
4
4
|
import o from "chalk";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { fileURLToPath as
|
|
8
|
-
import { cwd as
|
|
9
|
-
const
|
|
5
|
+
import s from "node:path";
|
|
6
|
+
import i from "node:fs";
|
|
7
|
+
import { fileURLToPath as C } from "node:url";
|
|
8
|
+
import { cwd as N, argv as D, exit as P } from "node:process";
|
|
9
|
+
const F = "@vc-shell/create-vc-app", z = "Application scaffolding", E = "1.0.176", M = "module", R = "./dist/index.js", A = [
|
|
10
|
+
"dist"
|
|
11
|
+
], O = {
|
|
12
|
+
build: "vite build && yarn postbuild",
|
|
13
|
+
postbuild: "shx cp -R src/templates dist/"
|
|
14
|
+
}, V = {
|
|
15
|
+
"@types/prompts": "^2.4.4",
|
|
16
|
+
"@vc-shell/ts-config": "^1.0.176",
|
|
17
|
+
copyfiles: "^2.4.1",
|
|
18
|
+
"cross-env": "^7.0.3",
|
|
19
|
+
shx: "^0.3.4",
|
|
20
|
+
typescript: "^5.3.3"
|
|
21
|
+
}, J = {
|
|
22
|
+
chalk: "^2.4.2",
|
|
23
|
+
mri: "^1.2.0",
|
|
24
|
+
prompts: "^2.4.2",
|
|
25
|
+
tslib: "^2.5.3",
|
|
26
|
+
vite: "^5.0.11",
|
|
27
|
+
"vite-plugin-dts": "^3.6.4"
|
|
28
|
+
}, L = {
|
|
29
|
+
access: "public",
|
|
30
|
+
registry: "https://registry.npmjs.org/"
|
|
31
|
+
}, T = "yarn@4.0.2", I = {
|
|
32
|
+
name: F,
|
|
33
|
+
description: z,
|
|
34
|
+
version: E,
|
|
35
|
+
type: M,
|
|
36
|
+
bin: R,
|
|
37
|
+
files: A,
|
|
38
|
+
scripts: O,
|
|
39
|
+
devDependencies: V,
|
|
40
|
+
dependencies: J,
|
|
41
|
+
publishConfig: L,
|
|
42
|
+
packageManager: T
|
|
43
|
+
}, k = {
|
|
10
44
|
_gitignore: ".gitignore",
|
|
11
45
|
"_yarnrc.yml": ".yarnrc.yml",
|
|
12
46
|
_browserslistrc: ".browserslistrc",
|
|
@@ -17,35 +51,35 @@ const P = {
|
|
|
17
51
|
_prettierignore: ".prettierignore",
|
|
18
52
|
_prettierrc: ".prettierrc",
|
|
19
53
|
"_eslintrc.js": ".eslintrc.js",
|
|
20
|
-
_github: "github",
|
|
54
|
+
_github: ".github",
|
|
21
55
|
_husky: ".husky",
|
|
22
56
|
_vscode: ".vscode",
|
|
23
57
|
_yarn: ".yarn"
|
|
24
58
|
};
|
|
25
|
-
function
|
|
59
|
+
function _(t) {
|
|
26
60
|
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t);
|
|
27
61
|
}
|
|
28
|
-
function
|
|
62
|
+
function f(t) {
|
|
29
63
|
return t.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
30
64
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
65
|
+
function U(t) {
|
|
66
|
+
i.existsSync(t);
|
|
33
67
|
}
|
|
34
|
-
function
|
|
35
|
-
const
|
|
36
|
-
return
|
|
68
|
+
function Y(t) {
|
|
69
|
+
const r = i.readdirSync(t);
|
|
70
|
+
return r.length === 0 || r.length === 1 && r[0] === ".git";
|
|
37
71
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
72
|
+
function u(t, r) {
|
|
73
|
+
i.statSync(t).isDirectory() ? q(t, r) : i.copyFileSync(t, r);
|
|
40
74
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
for (const n of
|
|
44
|
-
const
|
|
45
|
-
|
|
75
|
+
function q(t, r) {
|
|
76
|
+
i.mkdirSync(r, { recursive: !0 });
|
|
77
|
+
for (const n of i.readdirSync(t)) {
|
|
78
|
+
const y = s.resolve(t, n), m = s.resolve(r, n);
|
|
79
|
+
u(y, m);
|
|
46
80
|
}
|
|
47
81
|
}
|
|
48
|
-
const
|
|
82
|
+
const B = [
|
|
49
83
|
{
|
|
50
84
|
name: "classic",
|
|
51
85
|
display: "Classic modules boilerplate"
|
|
@@ -58,29 +92,36 @@ const O = [
|
|
|
58
92
|
name: "both",
|
|
59
93
|
display: "Classic modules + Dynamic modules boilerplate"
|
|
60
94
|
}
|
|
61
|
-
],
|
|
95
|
+
], G = {
|
|
62
96
|
both: "variants/both",
|
|
63
97
|
classic: "variants/classic",
|
|
64
98
|
dynamic: "variants/dynamic"
|
|
99
|
+
}, H = {
|
|
100
|
+
both: ["classic-module", "dynamic-module"],
|
|
101
|
+
classic: ["classic-module"],
|
|
102
|
+
dynamic: ["dynamic-module"]
|
|
65
103
|
};
|
|
66
|
-
async function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
async function K() {
|
|
105
|
+
console.log(` ${o.bold(o.green(`
|
|
106
|
+
create-vc-app version: ${I.version}
|
|
107
|
+
`))}`);
|
|
108
|
+
const t = N();
|
|
109
|
+
let n = x(D.slice(2))._[0];
|
|
110
|
+
const y = n || "vc-app", m = () => n === "." ? s.basename(s.resolve()) : n;
|
|
111
|
+
let v;
|
|
71
112
|
try {
|
|
72
|
-
|
|
113
|
+
v = await $(
|
|
73
114
|
[
|
|
74
115
|
{
|
|
75
116
|
name: "appName",
|
|
76
117
|
type: n ? null : "text",
|
|
77
118
|
message: o.reset("Project name:"),
|
|
78
|
-
initial:
|
|
79
|
-
onState: (e) => n =
|
|
80
|
-
format: (e) =>
|
|
119
|
+
initial: y,
|
|
120
|
+
onState: (e) => n = f(String(e.value).trim()) || y,
|
|
121
|
+
format: (e) => f(String(e).trim())
|
|
81
122
|
},
|
|
82
123
|
{
|
|
83
|
-
type: () => !
|
|
124
|
+
type: () => !i.existsSync(n) || Y(n) ? null : "confirm",
|
|
84
125
|
name: "overwrite",
|
|
85
126
|
message: () => (n === "." ? "Current directory" : `Target directory "${n}"`) + " is not empty. Remove existing files and continue?"
|
|
86
127
|
},
|
|
@@ -94,16 +135,16 @@ async function V() {
|
|
|
94
135
|
},
|
|
95
136
|
{
|
|
96
137
|
name: "packageName",
|
|
97
|
-
type: () =>
|
|
138
|
+
type: () => _(m()) ? null : "text",
|
|
98
139
|
message: o.reset("Package name:"),
|
|
99
|
-
initial: () =>
|
|
100
|
-
validate: (e) =>
|
|
140
|
+
initial: () => f(m()),
|
|
141
|
+
validate: (e) => _(e) || "Invalid package.json name"
|
|
101
142
|
},
|
|
102
143
|
{
|
|
103
144
|
type: "select",
|
|
104
145
|
name: "variant",
|
|
105
146
|
message: o.reset("Select module variant:"),
|
|
106
|
-
choices:
|
|
147
|
+
choices: B.map((e) => ({
|
|
107
148
|
title: e.display,
|
|
108
149
|
value: e.name
|
|
109
150
|
}))
|
|
@@ -116,32 +157,38 @@ async function V() {
|
|
|
116
157
|
}
|
|
117
158
|
);
|
|
118
159
|
} catch (e) {
|
|
119
|
-
console.log(e.message),
|
|
160
|
+
console.log(e.message), P(1);
|
|
120
161
|
}
|
|
121
|
-
const { packageName:
|
|
122
|
-
|
|
123
|
-
Scaffolding app in ${
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
p ?
|
|
127
|
-
},
|
|
128
|
-
const l =
|
|
129
|
-
for (const
|
|
130
|
-
|
|
162
|
+
const { packageName: w, variant: h } = v, c = s.join(t, n);
|
|
163
|
+
i.existsSync(c) ? U(c) : i.existsSync(c) || i.mkdirSync(c), console.log(`
|
|
164
|
+
Scaffolding app in ${c}...`);
|
|
165
|
+
const d = s.resolve(C(import.meta.url), "..", "templates"), b = (e, l, p) => {
|
|
166
|
+
const a = s.join(c, k[e] ?? e);
|
|
167
|
+
p ? i.writeFileSync(a, p) : u(s.join(d, l, e), a);
|
|
168
|
+
}, S = (e) => {
|
|
169
|
+
const l = s.resolve(d, e), p = i.readdirSync(l);
|
|
170
|
+
for (const a of p.filter((g) => g !== "package.json"))
|
|
171
|
+
b(a, e);
|
|
131
172
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
173
|
+
S("base"), S(G[h]), H[h].forEach((e) => {
|
|
174
|
+
const l = s.resolve(d, `modules/${e}`), p = i.readdirSync(l);
|
|
175
|
+
for (const a of p.filter((g) => g !== "package.json")) {
|
|
176
|
+
const g = s.join(c, "src", "modules", e, k[a] ?? a);
|
|
177
|
+
u(s.join(d, `modules/${e}`, a), g);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
const j = JSON.parse(i.readFileSync(s.join(d, "./base/package.json"), "utf-8"));
|
|
181
|
+
if (j.name = w || m(), b("package.json", "", JSON.stringify(j, null, 2) + `
|
|
135
182
|
`), console.log(`
|
|
136
183
|
Done. You can now run application:
|
|
137
|
-
`),
|
|
138
|
-
const e =
|
|
184
|
+
`), c !== t) {
|
|
185
|
+
const e = s.relative(t, c);
|
|
139
186
|
console.log(
|
|
140
187
|
` ${o.bold(o.green(`cd ${e.includes(" ") ? `"${e}"` : e}`))}`
|
|
141
188
|
);
|
|
142
189
|
}
|
|
143
190
|
console.log(` ${o.bold(o.green("yarn"))}`), console.log(` ${o.bold(o.green("yarn serve"))}`);
|
|
144
191
|
}
|
|
145
|
-
|
|
192
|
+
K().catch((t) => {
|
|
146
193
|
console.error(t);
|
|
147
194
|
});
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@types/node": "^20.10.5",
|
|
25
25
|
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
26
26
|
"@typescript-eslint/parser": "^6.16.0",
|
|
27
|
-
"@vc-shell/api-client-generator": "^1.0.
|
|
28
|
-
"@vc-shell/release-config": "^1.0.
|
|
29
|
-
"@vc-shell/ts-config": "^1.0.
|
|
27
|
+
"@vc-shell/api-client-generator": "^1.0.176",
|
|
28
|
+
"@vc-shell/release-config": "^1.0.176",
|
|
29
|
+
"@vc-shell/ts-config": "^1.0.176",
|
|
30
30
|
"@vitejs/plugin-vue": "^5.0.3",
|
|
31
31
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
32
32
|
"@vue/eslint-config-typescript": "^12.0.0",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@fortawesome/fontawesome-free": "^5.15.3",
|
|
59
|
-
"@vc-shell/config-generator": "^1.0.
|
|
60
|
-
"@vc-shell/framework": "^1.0.
|
|
59
|
+
"@vc-shell/config-generator": "^1.0.176",
|
|
60
|
+
"@vc-shell/framework": "^1.0.176",
|
|
61
61
|
"@vueuse/core": "^10.7.1",
|
|
62
62
|
"@vueuse/integrations": "^10.7.1",
|
|
63
63
|
"moment": "^2.30.1",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved */
|
|
2
|
+
import img1 from "/assets/1.jpeg";
|
|
3
|
+
import img2 from "/assets/2.jpg";
|
|
4
|
+
import img3 from "/assets/3.jpg";
|
|
5
|
+
|
|
6
|
+
export interface MockedItem {
|
|
7
|
+
imgSrc: string;
|
|
8
|
+
name: string;
|
|
9
|
+
createdDate: Date;
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const mockedItems: MockedItem[] = [
|
|
14
|
+
{
|
|
15
|
+
imgSrc: img1,
|
|
16
|
+
name: "Item 1",
|
|
17
|
+
createdDate: new Date(),
|
|
18
|
+
id: "item-id-1",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
imgSrc: img2,
|
|
22
|
+
name: "Item 2",
|
|
23
|
+
createdDate: new Date(),
|
|
24
|
+
id: "item-id-2",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
imgSrc: img3,
|
|
28
|
+
name: "Item 3",
|
|
29
|
+
createdDate: new Date(),
|
|
30
|
+
id: "item-id-3",
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export function loadMockItemsList() {
|
|
35
|
+
return new Promise((resolve: (value: MockedItem[]) => void) => {
|
|
36
|
+
setTimeout(() => resolve(mockedItems), 1000);
|
|
37
|
+
}).then((res) => {
|
|
38
|
+
return { results: res, totalCount: res.length };
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function loadMockItem(args?: { id: string }) {
|
|
43
|
+
return new Promise((resolve: (value: MockedItem) => void) => {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
const findMockedItem = mockedItems.find((x) => x.id === args?.id);
|
|
46
|
+
|
|
47
|
+
if (findMockedItem) resolve(findMockedItem);
|
|
48
|
+
}, 1000);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { getApplicationConfiguration } from "@vc-shell/config-generator";
|
|
2
2
|
import { VitePWA } from "vite-plugin-pwa";
|
|
3
3
|
|
|
4
|
-
// Remove it after you added APP_PLATFORM_URL to .env file. Demo mode works only with yarn serve
|
|
5
|
-
const isDemo = !process.env.APP_PLATFORM_URL;
|
|
6
|
-
|
|
7
|
-
const mode = process.env.APP_ENV as string;
|
|
8
|
-
|
|
9
4
|
export default getApplicationConfiguration({
|
|
10
|
-
define: {
|
|
11
|
-
// Set demo mode
|
|
12
|
-
__DEMO_MODE__: isDemo,
|
|
13
|
-
},
|
|
14
5
|
plugins: [
|
|
15
6
|
VitePWA({
|
|
16
7
|
includeAssets: ["favicon.ico", "apple-touch-icon.png"],
|
|
@@ -19,7 +10,7 @@ export default getApplicationConfiguration({
|
|
|
19
10
|
short_name: "App",
|
|
20
11
|
theme_color: "#319ED4",
|
|
21
12
|
display: "fullscreen",
|
|
22
|
-
start_url: "/",
|
|
13
|
+
start_url: "/apps/application",
|
|
23
14
|
icons: [
|
|
24
15
|
{
|
|
25
16
|
src: "./img/icons/pwa-192x192.png",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Ref, computed, ref } from "vue";
|
|
2
|
+
import { useAsync, useLoading } from "@vc-shell/framework";
|
|
3
|
+
import { MockedItem, loadMockItem } from "../../../mocks";
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
const item = ref({}) as Ref<MockedItem>;
|
|
7
|
+
|
|
8
|
+
// Example mocked method for 'fetching' list data
|
|
9
|
+
const { loading: itemLoading, action: getItem } = useAsync<{ id: string }>(async (payload) => {
|
|
10
|
+
item.value = await loadMockItem(payload);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const loading = useLoading(itemLoading);
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
item: computed(() => item.value),
|
|
17
|
+
loading: computed(() => loading.value),
|
|
18
|
+
getItem,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Ref, computed, ref } from "vue";
|
|
2
|
+
import { useAsync, useLoading } from "@vc-shell/framework";
|
|
3
|
+
import { type MockedItem, loadMockItemsList } from "../../../mocks";
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
const data = ref([]) as Ref<MockedItem[]>;
|
|
7
|
+
const dataRes = ref();
|
|
8
|
+
|
|
9
|
+
// Example mocked method for 'fetching' list data
|
|
10
|
+
const { loading: itemLoading, action: getItems } = useAsync(async (payload) => {
|
|
11
|
+
dataRes.value = await loadMockItemsList();
|
|
12
|
+
data.value = dataRes.value.results;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const loading = useLoading(itemLoading);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
data: computed(() => data.value),
|
|
19
|
+
loading: computed(() => loading.value),
|
|
20
|
+
totalCount: computed(() => dataRes.value?.totalCount),
|
|
21
|
+
pages: computed(() => Math.ceil(dataRes.value?.totalCount / 20)),
|
|
22
|
+
currentPage: 0 / Math.max(1, 20) + 1,
|
|
23
|
+
getItems,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/* eslint-disable import/no-unresolved */
|
|
2
1
|
import { computed, ref, Ref } from "vue";
|
|
3
|
-
import img1 from "/assets/1.jpeg";
|
|
4
|
-
import img2 from "/assets/2.jpg";
|
|
5
|
-
import img3 from "/assets/3.jpg";
|
|
6
2
|
import { DetailsBaseBladeScope, DynamicBladeForm, IBladeToolbar, useDetailsFactory } from "@vc-shell/framework";
|
|
3
|
+
import { loadMockItem, type MockedItem } from "../../../mocks";
|
|
7
4
|
|
|
8
5
|
export interface DynamicItemScope extends DetailsBaseBladeScope {
|
|
9
6
|
toolbarOverrides: {
|
|
@@ -16,33 +13,9 @@ export default (args: {
|
|
|
16
13
|
emit: InstanceType<typeof DynamicBladeForm>["$emit"];
|
|
17
14
|
mounted: Ref<boolean>;
|
|
18
15
|
}) => {
|
|
19
|
-
const factory = useDetailsFactory<
|
|
16
|
+
const factory = useDetailsFactory<MockedItem>({
|
|
20
17
|
load: async (payload) => {
|
|
21
|
-
return await
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
const findMockedItem = [
|
|
24
|
-
{
|
|
25
|
-
imgSrc: img1,
|
|
26
|
-
name: "Item 1",
|
|
27
|
-
createdDate: new Date(),
|
|
28
|
-
id: "item-id-1",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
imgSrc: img2,
|
|
32
|
-
name: "Item 2",
|
|
33
|
-
createdDate: new Date(),
|
|
34
|
-
id: "item-id-2",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
imgSrc: img3,
|
|
38
|
-
name: "Item 3",
|
|
39
|
-
createdDate: new Date(),
|
|
40
|
-
id: "item-id-3",
|
|
41
|
-
},
|
|
42
|
-
].find((x) => x.id === payload?.id);
|
|
43
|
-
resolve(findMockedItem);
|
|
44
|
-
}, 1000);
|
|
45
|
-
});
|
|
18
|
+
return await loadMockItem(payload);
|
|
46
19
|
},
|
|
47
20
|
saveChanges: () => {
|
|
48
21
|
throw new Error("Function not implemented.");
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
/* eslint-disable import/no-unresolved */
|
|
2
1
|
import { computed, ref, Ref } from "vue";
|
|
3
|
-
import img1 from "/assets/1.jpeg";
|
|
4
|
-
import img2 from "/assets/2.jpg";
|
|
5
|
-
import img3 from "/assets/3.jpg";
|
|
6
2
|
import { DynamicBladeList, ListBaseBladeScope, useBladeNavigation, useListFactory } from "@vc-shell/framework";
|
|
7
|
-
|
|
8
|
-
interface MockedItem {
|
|
9
|
-
imgSrc: string;
|
|
10
|
-
name: string;
|
|
11
|
-
createdDate: Date;
|
|
12
|
-
id: string;
|
|
13
|
-
}
|
|
3
|
+
import { loadMockItemsList } from "../../../mocks";
|
|
14
4
|
|
|
15
5
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
16
6
|
export interface DynamicItemsScope extends ListBaseBladeScope {}
|
|
@@ -22,34 +12,7 @@ export default (args: {
|
|
|
22
12
|
}) => {
|
|
23
13
|
const factory = useListFactory({
|
|
24
14
|
load: async () => {
|
|
25
|
-
return await
|
|
26
|
-
setTimeout(
|
|
27
|
-
() =>
|
|
28
|
-
resolve([
|
|
29
|
-
{
|
|
30
|
-
imgSrc: img1,
|
|
31
|
-
name: "Item 1",
|
|
32
|
-
createdDate: new Date(),
|
|
33
|
-
id: "item-id-1",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
imgSrc: img2,
|
|
37
|
-
name: "Item 2",
|
|
38
|
-
createdDate: new Date(),
|
|
39
|
-
id: "item-id-2",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
imgSrc: img3,
|
|
43
|
-
name: "Item 3",
|
|
44
|
-
createdDate: new Date(),
|
|
45
|
-
id: "item-id-3",
|
|
46
|
-
},
|
|
47
|
-
]),
|
|
48
|
-
1000,
|
|
49
|
-
);
|
|
50
|
-
}).then((res) => {
|
|
51
|
-
return { results: res, totalCount: res.length };
|
|
52
|
-
});
|
|
15
|
+
return await loadMockItemsList();
|
|
53
16
|
},
|
|
54
17
|
remove: () => {
|
|
55
18
|
throw new Error("Function not implemented.");
|
|
@@ -14,9 +14,8 @@ import "roboto-fontface/css/roboto/roboto-fontface.css";
|
|
|
14
14
|
import "@vc-shell/framework/dist/index.css";
|
|
15
15
|
|
|
16
16
|
async function startApp() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// await loadUser();
|
|
17
|
+
const { loadUser } = useUser();
|
|
18
|
+
await loadUser();
|
|
20
19
|
|
|
21
20
|
const { currentLocale, setLocale } = useLanguages();
|
|
22
21
|
|
|
@@ -13,9 +13,8 @@ import "roboto-fontface/css/roboto/roboto-fontface.css";
|
|
|
13
13
|
import "@vc-shell/framework/dist/index.css";
|
|
14
14
|
|
|
15
15
|
async function startApp() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// await loadUser();
|
|
16
|
+
const { loadUser } = useUser();
|
|
17
|
+
await loadUser();
|
|
19
18
|
|
|
20
19
|
const { currentLocale, setLocale } = useLanguages();
|
|
21
20
|
|
|
@@ -13,9 +13,8 @@ import "roboto-fontface/css/roboto/roboto-fontface.css";
|
|
|
13
13
|
import "@vc-shell/framework/dist/index.css";
|
|
14
14
|
|
|
15
15
|
async function startApp() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// await loadUser();
|
|
16
|
+
const { loadUser } = useUser();
|
|
17
|
+
await loadUser();
|
|
19
18
|
|
|
20
19
|
const { currentLocale, setLocale } = useLanguages();
|
|
21
20
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/create-vc-app",
|
|
3
3
|
"description": "Application scaffolding",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.176",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dist/index.js",
|
|
7
7
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/prompts": "^2.4.4",
|
|
16
|
-
"@vc-shell/ts-config": "^1.0.
|
|
16
|
+
"@vc-shell/ts-config": "^1.0.176",
|
|
17
17
|
"copyfiles": "^2.4.1",
|
|
18
18
|
"cross-env": "^7.0.3",
|
|
19
19
|
"shx": "^0.3.4",
|
package/dist/templates/variants/both/src/modules/classic-module/composables/useDetails/index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-unresolved */
|
|
2
|
-
import { Ref, computed, ref } from "vue";
|
|
3
|
-
import img1 from "/assets/1.jpeg";
|
|
4
|
-
import img2 from "/assets/2.jpg";
|
|
5
|
-
import img3 from "/assets/3.jpg";
|
|
6
|
-
import { useAsync, useLoading } from "@vc-shell/framework";
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
const item = ref({}) as Ref<{
|
|
10
|
-
imgSrc: string;
|
|
11
|
-
name: string;
|
|
12
|
-
createdDate: Date;
|
|
13
|
-
id: string;
|
|
14
|
-
}>;
|
|
15
|
-
|
|
16
|
-
// Example mocked method for 'fetching' list data
|
|
17
|
-
const { loading: itemLoading, action: getItem } = useAsync<{ id: string }>(async (payload) => {
|
|
18
|
-
item.value = await new Promise((resolve) => {
|
|
19
|
-
setTimeout(() => {
|
|
20
|
-
const findMockedItem = [
|
|
21
|
-
{
|
|
22
|
-
imgSrc: img1,
|
|
23
|
-
name: "Item 1",
|
|
24
|
-
createdDate: new Date(),
|
|
25
|
-
id: "item-id-1",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
imgSrc: img2,
|
|
29
|
-
name: "Item 2",
|
|
30
|
-
createdDate: new Date(),
|
|
31
|
-
id: "item-id-2",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
imgSrc: img3,
|
|
35
|
-
name: "Item 3",
|
|
36
|
-
createdDate: new Date(),
|
|
37
|
-
id: "item-id-3",
|
|
38
|
-
},
|
|
39
|
-
].find((x) => x.id === payload?.id);
|
|
40
|
-
if (findMockedItem) {
|
|
41
|
-
resolve(findMockedItem);
|
|
42
|
-
}
|
|
43
|
-
}, 1000);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const loading = useLoading(itemLoading);
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
item: computed(() => item.value),
|
|
51
|
-
loading: computed(() => loading.value),
|
|
52
|
-
getItem,
|
|
53
|
-
};
|
|
54
|
-
};
|
package/dist/templates/variants/both/src/modules/classic-module/composables/useList/index.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-unresolved */
|
|
2
|
-
import { Ref, computed, ref } from "vue";
|
|
3
|
-
import img1 from "/assets/1.jpeg";
|
|
4
|
-
import img2 from "/assets/2.jpg";
|
|
5
|
-
import img3 from "/assets/3.jpg";
|
|
6
|
-
import { useAsync, useLoading } from "@vc-shell/framework";
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
const data = ref([]) as Ref<
|
|
10
|
-
{
|
|
11
|
-
imgSrc: string;
|
|
12
|
-
name: string;
|
|
13
|
-
createdDate: Date;
|
|
14
|
-
id: string;
|
|
15
|
-
}[]
|
|
16
|
-
>;
|
|
17
|
-
|
|
18
|
-
// Example mocked method for 'fetching' list data
|
|
19
|
-
const { loading: itemLoading, action: getItems } = useAsync(async (payload) => {
|
|
20
|
-
data.value = await new Promise((resolve) => {
|
|
21
|
-
setTimeout(
|
|
22
|
-
() =>
|
|
23
|
-
resolve([
|
|
24
|
-
{
|
|
25
|
-
imgSrc: img1,
|
|
26
|
-
name: "Item 1",
|
|
27
|
-
createdDate: new Date(),
|
|
28
|
-
id: "item-id-1",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
imgSrc: img2,
|
|
32
|
-
name: "Item 2",
|
|
33
|
-
createdDate: new Date(),
|
|
34
|
-
id: "item-id-2",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
imgSrc: img3,
|
|
38
|
-
name: "Item 3",
|
|
39
|
-
createdDate: new Date(),
|
|
40
|
-
id: "item-id-3",
|
|
41
|
-
},
|
|
42
|
-
]),
|
|
43
|
-
1000,
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const loading = useLoading(itemLoading);
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
data: computed(() => data.value),
|
|
52
|
-
loading: computed(() => loading.value),
|
|
53
|
-
totalCount: computed(() => data.value.length),
|
|
54
|
-
pages: computed(() => Math.ceil(data.value.length / 20)),
|
|
55
|
-
currentPage: 0 / Math.max(1, 20) + 1,
|
|
56
|
-
getItems,
|
|
57
|
-
};
|
|
58
|
-
};
|