@farris/cli 2.1.3 → 2.1.4
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/lib/commands/generate/api.js +63 -63
- package/lib/commands/generate/component.js +7 -7
- package/lib/commands/generate/view.js +29 -29
- package/lib/common/constant.js +1 -1
- package/lib/common/constant.js.map +1 -1
- package/package.json +1 -1
- package/templates/workspace/app/farris.config.mjs +13 -13
- package/templates/workspace/app/index.html +12 -12
- package/templates/workspace/app/package.json +22 -22
- package/templates/workspace/app/src/App.tsx +11 -11
- package/templates/workspace/app/src/main.ts +11 -11
- package/templates/workspace/app/src/router/index.ts +16 -16
- package/templates/workspace/app/src/views/home/composables/use-home.ts +7 -7
- package/templates/workspace/app/src/views/home/home.component.tsx +15 -15
- package/templates/workspace/app/src/views/home/index.ts +4 -4
- package/templates/workspace/app/tsconfig.json +21 -21
- package/templates/workspace/root/README.md +28 -28
- package/templates/workspace/root/package.json +13 -13
- package/templates/workspace/root/pnpm-workspace.yaml +12 -12
|
@@ -68,75 +68,75 @@ export async function generateApi(rawName, options = {}) {
|
|
|
68
68
|
// 1. 若需要且不存在,初始化标准 http-client.ts
|
|
69
69
|
if (!hasHttpClient && options.initClient) {
|
|
70
70
|
transaction.prepareWrite(httpClientPath);
|
|
71
|
-
const clientContent = `/**
|
|
72
|
-
* Farris 标准 HTTP 请求客户端封装
|
|
73
|
-
*/
|
|
74
|
-
export interface RequestOptions extends RequestInit {
|
|
75
|
-
params?: Record<string, any>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function request<T = any>(url: string, options: RequestOptions = {}): Promise<T> {
|
|
79
|
-
const { params, ...customConfig } = options;
|
|
80
|
-
|
|
81
|
-
let requestUrl = url;
|
|
82
|
-
if (params && Object.keys(params).length > 0) {
|
|
83
|
-
const searchParams = new URLSearchParams();
|
|
84
|
-
Object.entries(params).forEach(([key, val]) => {
|
|
85
|
-
if (val !== undefined && val !== null) {
|
|
86
|
-
searchParams.append(key, String(val));
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
requestUrl += (url.includes('?') ? '&' : '?') + searchParams.toString();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const headers = {
|
|
93
|
-
'Content-Type': 'application/json',
|
|
94
|
-
...(customConfig.headers || {})
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const response = await fetch(requestUrl, {
|
|
98
|
-
...customConfig,
|
|
99
|
-
headers
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
if (!response.ok) {
|
|
103
|
-
const errorText = await response.text().catch(() => response.statusText);
|
|
104
|
-
throw new Error(\`HTTP Error \${response.status}: \${errorText}\`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return response.json();
|
|
108
|
-
}
|
|
71
|
+
const clientContent = `/**
|
|
72
|
+
* Farris 标准 HTTP 请求客户端封装
|
|
73
|
+
*/
|
|
74
|
+
export interface RequestOptions extends RequestInit {
|
|
75
|
+
params?: Record<string, any>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function request<T = any>(url: string, options: RequestOptions = {}): Promise<T> {
|
|
79
|
+
const { params, ...customConfig } = options;
|
|
80
|
+
|
|
81
|
+
let requestUrl = url;
|
|
82
|
+
if (params && Object.keys(params).length > 0) {
|
|
83
|
+
const searchParams = new URLSearchParams();
|
|
84
|
+
Object.entries(params).forEach(([key, val]) => {
|
|
85
|
+
if (val !== undefined && val !== null) {
|
|
86
|
+
searchParams.append(key, String(val));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
requestUrl += (url.includes('?') ? '&' : '?') + searchParams.toString();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const headers = {
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
...(customConfig.headers || {})
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const response = await fetch(requestUrl, {
|
|
98
|
+
...customConfig,
|
|
99
|
+
headers
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
const errorText = await response.text().catch(() => response.statusText);
|
|
104
|
+
throw new Error(\`HTTP Error \${response.status}: \${errorText}\`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return response.json();
|
|
108
|
+
}
|
|
109
109
|
`;
|
|
110
110
|
writeFileSync(httpClientPath, clientContent, 'utf-8');
|
|
111
111
|
filesCreated.push(httpClientPath);
|
|
112
112
|
}
|
|
113
113
|
// 2. 生成 API 文件: src/api/<name>.api.ts
|
|
114
114
|
transaction.prepareWrite(targetApiFile);
|
|
115
|
-
const apiFunctionContent = `import { request } from ${JSON.stringify(clientPath)};
|
|
116
|
-
|
|
117
|
-
export interface ${pascalName}Item {
|
|
118
|
-
id: string | number;
|
|
119
|
-
[key: string]: any;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface ${pascalName}Params {
|
|
123
|
-
[key: string]: any;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface ${pascalName}Response {
|
|
127
|
-
data: ${pascalName}Item[];
|
|
128
|
-
total?: number;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 获取 ${pascalName} 数据
|
|
133
|
-
*/
|
|
134
|
-
export async function get${pascalName}List(params?: ${pascalName}Params): Promise<${pascalName}Response> {
|
|
135
|
-
return request<${pascalName}Response>(${JSON.stringify(endpoint)}, {
|
|
136
|
-
method: ${JSON.stringify(method.toUpperCase())},
|
|
137
|
-
params
|
|
138
|
-
});
|
|
139
|
-
}
|
|
115
|
+
const apiFunctionContent = `import { request } from ${JSON.stringify(clientPath)};
|
|
116
|
+
|
|
117
|
+
export interface ${pascalName}Item {
|
|
118
|
+
id: string | number;
|
|
119
|
+
[key: string]: any;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ${pascalName}Params {
|
|
123
|
+
[key: string]: any;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ${pascalName}Response {
|
|
127
|
+
data: ${pascalName}Item[];
|
|
128
|
+
total?: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 获取 ${pascalName} 数据
|
|
133
|
+
*/
|
|
134
|
+
export async function get${pascalName}List(params?: ${pascalName}Params): Promise<${pascalName}Response> {
|
|
135
|
+
return request<${pascalName}Response>(${JSON.stringify(endpoint)}, {
|
|
136
|
+
method: ${JSON.stringify(method.toUpperCase())},
|
|
137
|
+
params
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
140
|
`;
|
|
141
141
|
writeFileSync(targetApiFile, apiFunctionContent, 'utf-8');
|
|
142
142
|
filesCreated.push(targetApiFile);
|
|
@@ -91,13 +91,13 @@ export async function generateComponent(rawName, options = {}) {
|
|
|
91
91
|
if (withProps) {
|
|
92
92
|
const propsPath = join(compDir, `${name}.props.ts`);
|
|
93
93
|
transaction.prepareWrite(propsPath);
|
|
94
|
-
const propsContent = `import type { ExtractPropTypes } from 'vue';
|
|
95
|
-
|
|
96
|
-
export const ${camelName}Props = {
|
|
97
|
-
// 定义组件 Props
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type ${pascalName}Props = ExtractPropTypes<typeof ${camelName}Props>;
|
|
94
|
+
const propsContent = `import type { ExtractPropTypes } from 'vue';
|
|
95
|
+
|
|
96
|
+
export const ${camelName}Props = {
|
|
97
|
+
// 定义组件 Props
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type ${pascalName}Props = ExtractPropTypes<typeof ${camelName}Props>;
|
|
101
101
|
`;
|
|
102
102
|
writeFileSync(propsPath, propsContent, 'utf-8');
|
|
103
103
|
filesCreated.push(propsPath);
|
|
@@ -61,13 +61,13 @@ export async function generateView(rawName, options = {}) {
|
|
|
61
61
|
// 1. 生成 composable: src/views/<name>/composables/use-<name>.ts
|
|
62
62
|
const composablePath = join(composablesDir, `use-${name}.ts`);
|
|
63
63
|
transaction.prepareWrite(composablePath);
|
|
64
|
-
const composableContent = `export function use${pascalName}() {
|
|
65
|
-
const title = ${JSON.stringify(title)};
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
title
|
|
69
|
-
};
|
|
70
|
-
}
|
|
64
|
+
const composableContent = `export function use${pascalName}() {
|
|
65
|
+
const title = ${JSON.stringify(title)};
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
title
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
71
|
`;
|
|
72
72
|
writeFileSync(composablePath, composableContent, 'utf-8');
|
|
73
73
|
filesCreated.push(composablePath);
|
|
@@ -75,13 +75,13 @@ export async function generateView(rawName, options = {}) {
|
|
|
75
75
|
if (withProps) {
|
|
76
76
|
const propsPath = join(viewDir, `${name}.props.ts`);
|
|
77
77
|
transaction.prepareWrite(propsPath);
|
|
78
|
-
const propsContent = `import type { ExtractPropTypes } from 'vue';
|
|
79
|
-
|
|
80
|
-
export const ${camelName}ViewProps = {
|
|
81
|
-
// 定义页面 Props
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type ${pascalName}ViewProps = ExtractPropTypes<typeof ${camelName}ViewProps>;
|
|
78
|
+
const propsContent = `import type { ExtractPropTypes } from 'vue';
|
|
79
|
+
|
|
80
|
+
export const ${camelName}ViewProps = {
|
|
81
|
+
// 定义页面 Props
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type ${pascalName}ViewProps = ExtractPropTypes<typeof ${camelName}ViewProps>;
|
|
85
85
|
`;
|
|
86
86
|
writeFileSync(propsPath, propsContent, 'utf-8');
|
|
87
87
|
filesCreated.push(propsPath);
|
|
@@ -89,21 +89,21 @@ export type ${pascalName}ViewProps = ExtractPropTypes<typeof ${camelName}ViewPro
|
|
|
89
89
|
// 3. 生成 component: src/views/<name>/<name>.component.tsx
|
|
90
90
|
const componentPath = join(viewDir, `${name}.component.tsx`);
|
|
91
91
|
transaction.prepareWrite(componentPath);
|
|
92
|
-
const componentContent = `import { defineComponent } from 'vue';
|
|
93
|
-
import { use${pascalName} } from './composables/use-${name}';
|
|
94
|
-
|
|
95
|
-
export default defineComponent({
|
|
96
|
-
name: '${pascalName}View',
|
|
97
|
-
setup() {
|
|
98
|
-
const { title } = use${pascalName}();
|
|
99
|
-
|
|
100
|
-
return () => (
|
|
101
|
-
<div class="f-page-${name}">
|
|
102
|
-
<h2>{title}</h2>
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
92
|
+
const componentContent = `import { defineComponent } from 'vue';
|
|
93
|
+
import { use${pascalName} } from './composables/use-${name}';
|
|
94
|
+
|
|
95
|
+
export default defineComponent({
|
|
96
|
+
name: '${pascalName}View',
|
|
97
|
+
setup() {
|
|
98
|
+
const { title } = use${pascalName}();
|
|
99
|
+
|
|
100
|
+
return () => (
|
|
101
|
+
<div class="f-page-${name}">
|
|
102
|
+
<h2>{title}</h2>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
107
|
`;
|
|
108
108
|
writeFileSync(componentPath, componentContent, 'utf-8');
|
|
109
109
|
filesCreated.push(componentPath);
|
package/lib/common/constant.js
CHANGED
|
@@ -26,7 +26,7 @@ export const SCHEMA_VERSION = 1;
|
|
|
26
26
|
export const CLI_VERSION = getVersion();
|
|
27
27
|
// Catalog Dependency Versions Baseline
|
|
28
28
|
export const DEFAULT_CATALOG_VERSIONS = {
|
|
29
|
-
'@farris/ui-vue': '1.8.3',
|
|
29
|
+
'@farris/ui-vue': '1.8.5-beta.3',
|
|
30
30
|
'@farris/cli': CLI_VERSION,
|
|
31
31
|
'typescript': '5.7.3',
|
|
32
32
|
'vite': '5.4.19',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/common/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO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AAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;AAExC,uCAAuC;AACvC,MAAM,CAAC,MAAM,wBAAwB,GAA2B;IAC5D,gBAAgB,EAAE,cAAc;IAChC,aAAa,EAAE,WAAW;IAC1B,YAAY,EAAE,OAAO;IACrB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,YAAY,EAAE,OAAO;IACrB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACnB,CAAC;AAEF,mBAAmB;AACnB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,iBAAiB;CAC1B,CAAC;AAEF,aAAa;AACb,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAChB,6CAAW,CAAA;IACX,yDAAiB,CAAA;IACjB,6DAAmB,CAAA;IACnB,yDAAiB,CAAA;IACjB,+CAAY,CAAA;AAChB,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB;AAED,0BAA0B;AAC1B,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACvB,sCAAmB,CAAA;IACnB,kCAAe,CAAA;IACf,oDAAiC,CAAA;IACjC,gEAA6C,CAAA;IAC7C,4DAAyC,CAAA;IACzC,8EAA2D,CAAA;IAC3D,0DAAuC,CAAA;IACvC,oDAAiC,CAAA;AACrC,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { fileURLToPath, URL } from 'node:url';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
base: '<%= base %>',
|
|
5
|
-
routerMode: '<%= routerMode %>',
|
|
6
|
-
format: '<%= format %>',
|
|
7
|
-
minify: true,
|
|
8
|
-
externalDependencies: false,
|
|
9
|
-
alias: [
|
|
10
|
-
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }
|
|
11
|
-
],
|
|
12
|
-
viteConfig: {}
|
|
13
|
-
};
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
base: '<%= base %>',
|
|
5
|
+
routerMode: '<%= routerMode %>',
|
|
6
|
+
format: '<%= format %>',
|
|
7
|
+
minify: true,
|
|
8
|
+
externalDependencies: false,
|
|
9
|
+
alias: [
|
|
10
|
+
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }
|
|
11
|
+
],
|
|
12
|
+
viteConfig: {}
|
|
13
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title><%= title %></title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"></div>
|
|
10
|
-
<script type="module" src="/src/main.ts"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title><%= title %></title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= appName %>",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "farris-cli dev",
|
|
8
|
-
"build": "farris-cli build",
|
|
9
|
-
"preview": "farris-cli preview",
|
|
10
|
-
"typecheck": "vue-tsc --noEmit"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@farris/ui-vue": "catalog:",
|
|
14
|
-
"vue": "catalog:"<%= routerDependency %>
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@farris/cli": "catalog:",
|
|
18
|
-
"typescript": "catalog:",
|
|
19
|
-
"vite": "catalog:",
|
|
20
|
-
"vue-tsc": "catalog:"<%= sassDevDependency %>
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= appName %>",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "farris-cli dev",
|
|
8
|
+
"build": "farris-cli build",
|
|
9
|
+
"preview": "farris-cli preview",
|
|
10
|
+
"typecheck": "vue-tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@farris/ui-vue": "catalog:",
|
|
14
|
+
"vue": "catalog:"<%= routerDependency %>
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@farris/cli": "catalog:",
|
|
18
|
+
"typescript": "catalog:",
|
|
19
|
+
"vite": "catalog:",
|
|
20
|
+
"vue-tsc": "catalog:"<%= sassDevDependency %>
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';<%= appRouterImport %>
|
|
2
|
-
|
|
3
|
-
export default defineComponent({
|
|
4
|
-
name: 'App',
|
|
5
|
-
setup() {
|
|
6
|
-
return () => (
|
|
7
|
-
<%= appTemplateBody %>
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
|
|
1
|
+
import { defineComponent } from 'vue';<%= appRouterImport %>
|
|
2
|
+
|
|
3
|
+
export default defineComponent({
|
|
4
|
+
name: 'App',
|
|
5
|
+
setup() {
|
|
6
|
+
return () => (
|
|
7
|
+
<%= appTemplateBody %>
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createApp } from 'vue';
|
|
2
|
-
import FarrisUI from '@farris/ui-vue';
|
|
3
|
-
import '@farris/ui-vue/index.css'; <%= styleImport %> <%= routerImport %> <%= i18nImport %>
|
|
4
|
-
import App from './App';
|
|
5
|
-
|
|
6
|
-
const app = createApp(App);
|
|
7
|
-
|
|
8
|
-
app.use(FarrisUI); <%= routerUse %> <%= i18nUse %>
|
|
9
|
-
|
|
10
|
-
app.mount('#app');
|
|
11
|
-
|
|
1
|
+
import { createApp } from 'vue';
|
|
2
|
+
import FarrisUI from '@farris/ui-vue';
|
|
3
|
+
import '@farris/ui-vue/index.css'; <%= styleImport %> <%= routerImport %> <%= i18nImport %>
|
|
4
|
+
import App from './App';
|
|
5
|
+
|
|
6
|
+
const app = createApp(App);
|
|
7
|
+
|
|
8
|
+
app.use(FarrisUI); <%= routerUse %> <%= i18nUse %>
|
|
9
|
+
|
|
10
|
+
app.mount('#app');
|
|
11
|
+
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createRouter, <%= routerHistoryFunction %>, type RouteRecordRaw } from 'vue-router';
|
|
2
|
-
|
|
3
|
-
export const routes: RouteRecordRaw[] = [
|
|
4
|
-
{
|
|
5
|
-
path: '/',
|
|
6
|
-
name: 'Home',
|
|
7
|
-
component: () => import('../views/home')
|
|
8
|
-
}
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
const router = createRouter({
|
|
12
|
-
history: <%= routerHistoryCall %>,
|
|
13
|
-
routes
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export default router;
|
|
1
|
+
import { createRouter, <%= routerHistoryFunction %>, type RouteRecordRaw } from 'vue-router';
|
|
2
|
+
|
|
3
|
+
export const routes: RouteRecordRaw[] = [
|
|
4
|
+
{
|
|
5
|
+
path: '/',
|
|
6
|
+
name: 'Home',
|
|
7
|
+
component: () => import('../views/home')
|
|
8
|
+
}
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const router = createRouter({
|
|
12
|
+
history: <%= routerHistoryCall %>,
|
|
13
|
+
routes
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default router;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function useHome() {
|
|
2
|
-
const title = '<%= title %>';
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
title
|
|
6
|
-
};
|
|
7
|
-
}
|
|
1
|
+
export function useHome() {
|
|
2
|
+
const title = '<%= title %>';
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
title
|
|
6
|
+
};
|
|
7
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';
|
|
2
|
-
import { useHome } from './composables/use-home';
|
|
3
|
-
|
|
4
|
-
export default defineComponent({
|
|
5
|
-
name: 'HomeView',
|
|
6
|
-
setup() {
|
|
7
|
-
const { title } = useHome();
|
|
8
|
-
|
|
9
|
-
return () => (
|
|
10
|
-
<div class="f-page-home">
|
|
11
|
-
<h2>{title}</h2>
|
|
12
|
-
</div>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
1
|
+
import { defineComponent } from 'vue';
|
|
2
|
+
import { useHome } from './composables/use-home';
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
name: 'HomeView',
|
|
6
|
+
setup() {
|
|
7
|
+
const { title } = useHome();
|
|
8
|
+
|
|
9
|
+
return () => (
|
|
10
|
+
<div class="f-page-home">
|
|
11
|
+
<h2>{title}</h2>
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import HomeComponent from './home.component';
|
|
2
|
-
|
|
3
|
-
export { HomeComponent };
|
|
4
|
-
export default HomeComponent;
|
|
1
|
+
import HomeComponent from './home.component';
|
|
2
|
+
|
|
3
|
+
export { HomeComponent };
|
|
4
|
+
export default HomeComponent;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "Node",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"jsx": "preserve",
|
|
9
|
-
"jsxImportSource": "vue",
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"isolatedModules": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"lib": ["ESNext", "DOM"],
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"types": ["vite/client"],
|
|
16
|
-
"paths": {
|
|
17
|
-
"@/*": ["./src/*"]
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"jsxImportSource": "vue",
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"lib": ["ESNext", "DOM"],
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"types": ["vite/client"],
|
|
16
|
+
"paths": {
|
|
17
|
+
"@/*": ["./src/*"]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
|
|
21
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# <%= title %>
|
|
2
|
-
|
|
3
|
-
基于 Farris Vue 的前端工程 Workspace。
|
|
4
|
-
|
|
5
|
-
## 目录结构
|
|
6
|
-
|
|
7
|
-
```text
|
|
8
|
-
├── packages/
|
|
9
|
-
│ └── <%= appDir %>/ # 应用源码
|
|
10
|
-
├── pnpm-workspace.yaml # pnpm workspace 配置及 Catalog 依赖版本
|
|
11
|
-
└── package.json # 根工程脚本
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## 快速上手
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# 安装依赖
|
|
18
|
-
pnpm install
|
|
19
|
-
|
|
20
|
-
# 启动开发服务器
|
|
21
|
-
pnpm --filter "<%= appName %>" dev
|
|
22
|
-
|
|
23
|
-
# 执行全量类型检查
|
|
24
|
-
pnpm typecheck
|
|
25
|
-
|
|
26
|
-
# 构建生产产物
|
|
27
|
-
pnpm build
|
|
28
|
-
```
|
|
1
|
+
# <%= title %>
|
|
2
|
+
|
|
3
|
+
基于 Farris Vue 的前端工程 Workspace。
|
|
4
|
+
|
|
5
|
+
## 目录结构
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
├── packages/
|
|
9
|
+
│ └── <%= appDir %>/ # 应用源码
|
|
10
|
+
├── pnpm-workspace.yaml # pnpm workspace 配置及 Catalog 依赖版本
|
|
11
|
+
└── package.json # 根工程脚本
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 快速上手
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# 安装依赖
|
|
18
|
+
pnpm install
|
|
19
|
+
|
|
20
|
+
# 启动开发服务器
|
|
21
|
+
pnpm --filter "<%= appName %>" dev
|
|
22
|
+
|
|
23
|
+
# 执行全量类型检查
|
|
24
|
+
pnpm typecheck
|
|
25
|
+
|
|
26
|
+
# 构建生产产物
|
|
27
|
+
pnpm build
|
|
28
|
+
```
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": true,
|
|
3
|
-
"packageManager": "pnpm@<%= pnpmVersion %>",
|
|
4
|
-
"engines": {
|
|
5
|
-
"node": "^18.0.0 || >=20.0.0",
|
|
6
|
-
"pnpm": ">=9.0.0 <10.0.0"
|
|
7
|
-
},
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "pnpm --recursive --if-present run build",
|
|
10
|
-
"dev": "pnpm --recursive --if-present run dev",
|
|
11
|
-
"typecheck": "pnpm --recursive --if-present run typecheck"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"packageManager": "pnpm@<%= pnpmVersion %>",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": "^18.0.0 || >=20.0.0",
|
|
6
|
+
"pnpm": ">=9.0.0 <10.0.0"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "pnpm --recursive --if-present run build",
|
|
10
|
+
"dev": "pnpm --recursive --if-present run dev",
|
|
11
|
+
"typecheck": "pnpm --recursive --if-present run typecheck"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
packages:
|
|
2
|
-
- "packages/*"
|
|
3
|
-
|
|
4
|
-
catalog:
|
|
5
|
-
"@farris/ui-vue": "<%= farrisUiVueVersion %>"
|
|
6
|
-
"@farris/cli": "<%= farrisCliVersion %>"
|
|
7
|
-
"typescript": "<%= typescriptVersion %>"
|
|
8
|
-
"vite": "<%= viteVersion %>"
|
|
9
|
-
"vue": "<%= vueVersion %>"
|
|
10
|
-
"vue-router": "<%= vueRouterVersion %>"
|
|
11
|
-
"vue-tsc": "<%= vueTscVersion %>"
|
|
12
|
-
"sass": "<%= sassVersion %>"
|
|
1
|
+
packages:
|
|
2
|
+
- "packages/*"
|
|
3
|
+
|
|
4
|
+
catalog:
|
|
5
|
+
"@farris/ui-vue": "<%= farrisUiVueVersion %>"
|
|
6
|
+
"@farris/cli": "<%= farrisCliVersion %>"
|
|
7
|
+
"typescript": "<%= typescriptVersion %>"
|
|
8
|
+
"vite": "<%= viteVersion %>"
|
|
9
|
+
"vue": "<%= vueVersion %>"
|
|
10
|
+
"vue-router": "<%= vueRouterVersion %>"
|
|
11
|
+
"vue-tsc": "<%= vueTscVersion %>"
|
|
12
|
+
"sass": "<%= sassVersion %>"
|