|
1 | | -import { |
2 | | - generateApp, |
3 | | - parseRequiredBlocks, |
4 | | - genSFCWithDefaultPlugin, |
5 | | - type IAppSchema |
6 | | -} from '@opentiny/tiny-engine-dsl-vue' |
| 1 | +import { generateApp, type IAppSchema } from '@opentiny/tiny-engine-dsl-vue' |
| 2 | +import * as dslVue from '@opentiny/tiny-engine-dsl-vue' |
| 3 | +import { getMergeMeta } from '@opentiny/tiny-engine-meta-register' |
7 | 4 | import defaultPrettierConfig from '../../js/config-files/prettierrc' |
8 | 5 |
|
9 | 6 | // 应用出码默认配置 |
10 | 7 | const defaultOptions = { |
11 | 8 | pluginConfig: { |
| 9 | + template: {}, |
| 10 | + block: {}, |
| 11 | + page: {}, |
| 12 | + dataSource: {}, |
| 13 | + dependencies: {}, |
| 14 | + globalState: {}, |
| 15 | + i18n: {}, |
| 16 | + router: {}, |
| 17 | + utils: {}, |
12 | 18 | formatCode: { |
13 | 19 | // 默认格式化配置 |
14 | 20 | ...defaultPrettierConfig |
15 | | - } |
| 21 | + }, |
| 22 | + parseSchema: {} |
16 | 23 | } |
17 | 24 | } |
18 | 25 |
|
19 | 26 | // 应用出码 |
20 | 27 | const generateAppCode = async (appSchema: IAppSchema, options = {}) => { |
21 | | - const instance = generateApp({ ...defaultOptions, ...options }) |
| 28 | + const enableTailwindCSS = getMergeMeta('engine.config')?.enableTailwindCSS |
| 29 | + const instance = generateApp({ |
| 30 | + ...defaultOptions, |
| 31 | + pluginConfig: { |
| 32 | + ...defaultOptions.pluginConfig, |
| 33 | + template: { ...defaultOptions.pluginConfig.template, enableTailwindCSS } |
| 34 | + }, |
| 35 | + ...options |
| 36 | + }) |
22 | 37 |
|
23 | 38 | return instance.generate(appSchema) |
24 | 39 | } |
25 | 40 |
|
26 | 41 | // 页面出码 |
| 42 | +const { parseRequiredBlocks, genSFCWithDefaultPlugin } = dslVue as any |
| 43 | + |
27 | 44 | const generatePageCode = (...args: any[]) => { |
28 | 45 | return genSFCWithDefaultPlugin(...args) |
29 | 46 | } |
@@ -53,10 +70,14 @@ const getAllNestedBlocksSchema = async (pageSchema: any, fetchBlockSchemaApi: an |
53 | 70 | const schemaList = await Promise.allSettled(promiseList) |
54 | 71 | const extraList: any[] = [] |
55 | 72 |
|
56 | | - schemaList.forEach((item: { value: any[]; status: string }) => { |
57 | | - const blockItem = item.value?.[0] |
| 73 | + schemaList.forEach((item) => { |
| 74 | + if (item.status !== 'fulfilled') { |
| 75 | + return |
| 76 | + } |
| 77 | + |
| 78 | + const blockItem = (item.value as any[])?.[0] |
58 | 79 |
|
59 | | - if (item.status !== 'fulfilled' || !blockItem) { |
| 80 | + if (!blockItem) { |
60 | 81 | return |
61 | 82 | } |
62 | 83 |
|
|
0 commit comments