@varlet/cli 2.0.0-alpha.1664332224687 → 2.0.0-alpha.1664527888620
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/README.en-US.md +110 -288
- package/README.md +102 -277
- package/package.json +6 -6
- package/site/components/code-example/CodeExample.vue +6 -6
- package/site/components/utils/components.ts +2 -2
- package/site/mobile/App.vue +7 -6
- package/site/pc/Layout.vue +6 -11
- package/site/pc/components/AppHeader.vue +11 -11
- package/site/pc/components/AppSidebar.vue +1 -2
- package/site/pc/pages/index/index.vue +6 -6
- package/site/useProgress.ts +1 -1
- package/site/utils.ts +6 -0
- package/template/generators/config/default/base/package.json +1 -1
- package/template/generators/config/i18n/base/package.json +1 -1
- package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +1 -1
- package/varlet.default.config.js +1 -1
package/README.en-US.md
CHANGED
|
@@ -4,30 +4,27 @@ The out-of-the-box `Vue3 component library` rapid prototyping tool provides a se
|
|
|
4
4
|
|
|
5
5
|
### Feature
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
7
|
+
- 📦 Out-of-the-box component library development environment
|
|
8
|
+
- 📦 An out-of-the-box component library compilation tool that supports exporting `esm`, `cjs`, `umd` module codes
|
|
9
|
+
- 🛠️ Configuration file-based component library documentation site, support Baidu statistics and theme customization
|
|
10
|
+
- 🛠️ Supports both `sfc` and `tsx` styles for writing component libraries
|
|
11
|
+
- 📦 Out-of-the-box code inspection tool
|
|
12
|
+
- 📦 Out-of-the-box unit testing tools
|
|
13
|
+
- 📦 Out-of-the-box code publishing tool, publishes to both `npm` and `github`, and automatically generates changelogs
|
|
14
|
+
- 💪 Support for `Typescript`
|
|
15
|
+
- 💪 Support `Dark Mode`
|
|
16
|
+
- 🌍 Support `Internationalization`
|
|
17
|
+
- 🚀 Based on `pnpm`
|
|
17
18
|
|
|
18
19
|
### Quickstart
|
|
19
20
|
|
|
20
|
-
`@varlet/cli` has built-in `
|
|
21
|
-
|
|
21
|
+
`@varlet/cli` has built-in `sfc` and `tsx` style component library project templates, which can be generated directly by the `gen` command.
|
|
22
|
+
It is convenient for you to directly enter the component library development.
|
|
22
23
|
|
|
23
24
|
```shell
|
|
24
25
|
# Install command line tools
|
|
25
26
|
pnpm add @varlet/cli -g
|
|
26
|
-
|
|
27
|
-
varlet-cli gen projectName
|
|
28
|
-
cd projectName
|
|
29
|
-
pnpm install
|
|
30
|
-
pnpm dev
|
|
27
|
+
varlet-cli gen
|
|
31
28
|
```
|
|
32
29
|
|
|
33
30
|
Then by simply modifying some basic information of the component library template,
|
|
@@ -37,175 +34,62 @@ you can start the development of the component library
|
|
|
37
34
|
|
|
38
35
|
### Configuration file
|
|
39
36
|
|
|
40
|
-
The `varlet.config.js` in the project root directory is used to manage the specific details of the entire component library project
|
|
37
|
+
The `varlet.config.js` in the project root directory is used to manage the specific details of the entire component library project.
|
|
38
|
+
The default configuration can be viewed [varlet.default.config.js](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/varlet.default.config.js)。
|
|
39
|
+
Also refer to `@varlet/ui` [varlet.config.js](https://github.com/varletjs/varlet/blob/dev/packages/varlet-ui/varlet.config.js)
|
|
41
40
|
|
|
42
41
|
| Parameter | Description | Type | Default |
|
|
43
|
-
|
|
|
42
|
+
| -- | -------------- | -------- | ---------- |
|
|
43
|
+
| `name` | The full name of the component library, which will be used as the package name | _string_ | `Varlet` |
|
|
44
|
+
| `namespace` | Component library namespace, which will be used as a component prefix | _string_ | `var` |
|
|
44
45
|
| `host` | Development server host | _number_ | `localhost` |
|
|
45
46
|
| `port` | Development server port | _number_ | `8080` |
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Some external dependencies may need to be compatible with module syntax to achieve the purpose of compiling correctly to `commonjs` and `esmodule`. For example, the wording of `esmodule` of `dayjs` is
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
import dayjs from 'dayjs/esm'
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
In order to build `commonjs`, the writing method is
|
|
47
|
+
| `title` | The title of the component library in the documentation | _string_ | `VARLET` |
|
|
48
|
+
| `logo` | The logo of the component library in the documentation | _string_ | `-` |
|
|
49
|
+
| `defaultLanguage` | Documentation default language | _string_ | `zh-CN` |
|
|
50
|
+
| `useMobile` | Whether to show the preview of the right mobile phone | _boolean_ | `false` |
|
|
51
|
+
| `lightTheme` | Light Mode Documentation Theme | _Record<string, any>_ | `-` |
|
|
52
|
+
| `darkTheme` | Dark Mode Documentation Theme | _Record<string, any>_ | `-` |
|
|
53
|
+
| `highlight` | Documentation snippet style related | _{ style: string }_ | `-` |
|
|
54
|
+
| `analysis` | Document statistics related | _{ baidu: string }_ | `-` |
|
|
55
|
+
| `pc` | PC-side document structure configuration | _Record<string, any>_ | `-` |
|
|
56
|
+
| `mobile` | Mobile side document structure configuration | _Record<string, any>_ | `-` |
|
|
57
|
+
| `moduleCompatible` | Module Compatible Configurations | _Record<string, string>_ | `-` |
|
|
58
|
+
|
|
59
|
+
### Custom pages
|
|
60
|
+
|
|
61
|
+
If you want to insert other pages into the component library, you can create a `pages` folder in the project root directory to write a vue component to generate other pages.
|
|
62
|
+
The directory structure is as follows:
|
|
69
63
|
|
|
70
64
|
```js
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
| Variable |
|
|
92
|
-
| ----- |
|
|
93
|
-
| `color-body` |
|
|
94
|
-
| `color-bar` |
|
|
95
|
-
| `color-sub-bar` |
|
|
96
|
-
| `color-text` |
|
|
97
|
-
| `color-sub-text` |
|
|
98
|
-
| `color-border` |
|
|
99
|
-
| `color-shadow` |
|
|
100
|
-
| `color-introduce-border` |
|
|
101
|
-
| `color-primary` |
|
|
102
|
-
| `color-link` |
|
|
103
|
-
| `color-type` |
|
|
104
|
-
| `color-progress` |
|
|
105
|
-
| `color-progress-track` |
|
|
106
|
-
| `color-side-bar` |
|
|
107
|
-
| `color-side-bar-active-background` |
|
|
108
|
-
| `color-app-bar` |
|
|
109
|
-
| `color-nav-button-hover-background` |
|
|
110
|
-
| `color-mobile-cell-hover` |
|
|
111
|
-
| `color-pc-language-active` |
|
|
112
|
-
| `color-pc-language-active-background` |
|
|
113
|
-
| `color-mobile-language-active` |
|
|
114
|
-
| `color-mobile-language-active-background` |
|
|
115
|
-
| `color-hl-background` |
|
|
116
|
-
| `color-hl-code` |
|
|
117
|
-
| `color-hl-border` |
|
|
118
|
-
| `color-hl-group-a` |
|
|
119
|
-
| `color-hl-group-b` |
|
|
120
|
-
| `color-hl-group-c` |
|
|
121
|
-
| `color-hl-group-d` |
|
|
122
|
-
| `color-hl-group-e` |
|
|
123
|
-
| `color-hl-group-f` |
|
|
124
|
-
| `color-hl-group-g` |
|
|
125
|
-
| `color-hl-group-h` |
|
|
126
|
-
| `color-hl-group-i` |
|
|
127
|
-
|
|
128
|
-
#### SiteHighlight
|
|
129
|
-
|
|
130
|
-
Code snippets are highlighted, based on [highlight.js](https://highlightjs.org/)
|
|
131
|
-
|
|
132
|
-
| Parameter | Description | Type | Default |
|
|
133
|
-
| ----- | -------------- | -------- | ---------- |
|
|
134
|
-
| `style` | highlight css link | _string_ | `-` |
|
|
65
|
+
|-- varlet-ui
|
|
66
|
+
|-- src
|
|
67
|
+
|-- docs
|
|
68
|
+
|-- pages
|
|
69
|
+
|-- sponsor
|
|
70
|
+
|-- index.vue
|
|
71
|
+
|-- contributor
|
|
72
|
+
|-- locale
|
|
73
|
+
|-- en-US.ts
|
|
74
|
+
|-- index.vue
|
|
75
|
+
|-- changelog
|
|
76
|
+
|-- locale
|
|
77
|
+
|-- zh-CN.ts
|
|
78
|
+
|-- en-US.ts
|
|
79
|
+
|-- index.vue
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The resulting route is as follows:
|
|
135
84
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
| ----- | -------------- | -------- | ---------- |
|
|
142
|
-
| `baidu` | Baidu statistics script address | _string_ | `-` |
|
|
143
|
-
|
|
144
|
-
#### SitePC, SiteMobile
|
|
145
|
-
|
|
146
|
-
The document structure is partly related, and the example configuration is as follows
|
|
147
|
-
|
|
148
|
-
```js
|
|
149
|
-
module.exports = {
|
|
150
|
-
defaultLanguage: 'en-US',
|
|
151
|
-
pc: {
|
|
152
|
-
redirect: '/home',
|
|
153
|
-
title: {
|
|
154
|
-
'en-US': 'A components library',
|
|
155
|
-
},
|
|
156
|
-
header: {
|
|
157
|
-
darkMode: null,
|
|
158
|
-
i18n: null,
|
|
159
|
-
github: 'https://github.com/varletjs/varlet',
|
|
160
|
-
},
|
|
161
|
-
menu: [
|
|
162
|
-
{
|
|
163
|
-
text: {
|
|
164
|
-
'en-US': 'Develop Guide',
|
|
165
|
-
},
|
|
166
|
-
// Sidebar menu directory
|
|
167
|
-
type: 1,
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
text: {
|
|
171
|
-
'en-US': 'Basic Intro',
|
|
172
|
-
},
|
|
173
|
-
doc: 'home',
|
|
174
|
-
// Index the md document in the root directory of the project
|
|
175
|
-
type: 3,
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
text: {
|
|
179
|
-
'en-US': 'Basic Component',
|
|
180
|
-
},
|
|
181
|
-
type: 1,
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
text: {
|
|
185
|
-
'en-US': 'Button',
|
|
186
|
-
},
|
|
187
|
-
doc: 'button',
|
|
188
|
-
// Md document in the root directory of the index component
|
|
189
|
-
type: 2,
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
mobile: {
|
|
194
|
-
redirect: '/home',
|
|
195
|
-
title: {
|
|
196
|
-
'en-US': 'A components library',
|
|
197
|
-
},
|
|
198
|
-
header: {
|
|
199
|
-
darkMode: null,
|
|
200
|
-
i18n: null,
|
|
201
|
-
playground: null,
|
|
202
|
-
github: 'https://github.com/varletjs/varlet',
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
}
|
|
85
|
+
```text
|
|
86
|
+
/zh-CN/sponsor
|
|
87
|
+
/en-US/contributor
|
|
88
|
+
/zh-CN/changelog
|
|
89
|
+
/en-US/changelog
|
|
206
90
|
```
|
|
207
91
|
|
|
208
|
-
### Commands
|
|
92
|
+
### Commands related
|
|
209
93
|
|
|
210
94
|
#### Start the development server
|
|
211
95
|
|
|
@@ -270,133 +154,71 @@ varlet-cli release
|
|
|
270
154
|
```
|
|
271
155
|
|
|
272
156
|
#### Generate a project template
|
|
157
|
+
|
|
273
158
|
```shell
|
|
274
|
-
varlet-cli gen
|
|
159
|
+
varlet-cli gen
|
|
160
|
+
|
|
161
|
+
# Options
|
|
162
|
+
-n
|
|
163
|
+
--name
|
|
164
|
+
project name
|
|
165
|
+
-s
|
|
166
|
+
--sfc
|
|
167
|
+
Generate sfc-style project templates
|
|
168
|
+
-t
|
|
169
|
+
--tsx
|
|
170
|
+
Generate tsx-style project templates
|
|
171
|
+
-l
|
|
172
|
+
--locale
|
|
173
|
+
Need to support internationalization
|
|
275
174
|
```
|
|
276
175
|
|
|
277
|
-
|
|
176
|
+
#### Create a component template file
|
|
278
177
|
|
|
279
|
-
|
|
178
|
+
```shell
|
|
179
|
+
varlet-cli create
|
|
280
180
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
181
|
+
# Options
|
|
182
|
+
-n
|
|
183
|
+
--name
|
|
184
|
+
project name
|
|
185
|
+
-s
|
|
186
|
+
--sfc
|
|
187
|
+
Generate sfc-style component
|
|
188
|
+
-t
|
|
189
|
+
--tsx
|
|
190
|
+
Generate tsx-style component
|
|
191
|
+
-l
|
|
192
|
+
--locale
|
|
193
|
+
Need to support internationalization
|
|
288
194
|
```
|
|
289
195
|
|
|
290
|
-
|
|
196
|
+
### Note before release
|
|
291
197
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
module.exports = {
|
|
295
|
-
presets: [
|
|
296
|
-
[
|
|
297
|
-
'@varlet/cli/preset',
|
|
298
|
-
{
|
|
299
|
-
loose: process.env.NODE_ENV === 'compile',
|
|
300
|
-
},
|
|
301
|
-
],
|
|
302
|
-
],
|
|
303
|
-
}
|
|
304
|
-
```
|
|
198
|
+
- 1.`npm` repository registry must set to `npm` official mirror
|
|
199
|
+
- 2.Execute `npm login` to log in
|
|
305
200
|
|
|
306
|
-
###
|
|
307
|
-
|
|
308
|
-
#### git-hook
|
|
309
|
-
|
|
310
|
-
`simple-git-hooks`, `lint-staged` cooperate with `eslint`, `stylelint`, `varlet-cli commit-lint` to check before commit,
|
|
311
|
-
`package.json` configuration is as follows
|
|
312
|
-
|
|
313
|
-
```json
|
|
314
|
-
{
|
|
315
|
-
"simple-git-hooks": {
|
|
316
|
-
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
317
|
-
"commit-msg": "npx --no-install varlet-cli commit-lint $1"
|
|
318
|
-
},
|
|
319
|
-
"lint-staged": {
|
|
320
|
-
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
321
|
-
"*.{ts,tsx,js,vue}": "eslint --fix",
|
|
322
|
-
"*.{vue,css,less}": "stylelint --fix"
|
|
323
|
-
},
|
|
324
|
-
"eslintConfig": {
|
|
325
|
-
"root": true,
|
|
326
|
-
"ignorePatterns": [
|
|
327
|
-
"es/**",
|
|
328
|
-
"umd/**",
|
|
329
|
-
"site/**",
|
|
330
|
-
"public/**",
|
|
331
|
-
"src/*/__tests__/**",
|
|
332
|
-
".varlet/**"
|
|
333
|
-
],
|
|
334
|
-
"extends": [
|
|
335
|
-
"@varlet"
|
|
336
|
-
]
|
|
337
|
-
},
|
|
338
|
-
"stylelint": {
|
|
339
|
-
"extends": [
|
|
340
|
-
"@varlet/stylelint-config"
|
|
341
|
-
],
|
|
342
|
-
"ignoreFiles": [
|
|
343
|
-
"es/**",
|
|
344
|
-
"umd/**",
|
|
345
|
-
"site/**",
|
|
346
|
-
"coverage/**",
|
|
347
|
-
"public/**",
|
|
348
|
-
"highlight/**"
|
|
349
|
-
]
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
```
|
|
201
|
+
### Module Compatible
|
|
353
202
|
|
|
354
|
-
|
|
203
|
+
Some external dependencies may need to be compatible with module syntax to achieve the purpose of compiling correctly to `commonjs` and `esmodule`. For example, the wording of `esmodule` of `dayjs` is
|
|
355
204
|
|
|
356
|
-
```
|
|
357
|
-
|
|
205
|
+
```js
|
|
206
|
+
import dayjs from 'dayjs/esm'
|
|
358
207
|
```
|
|
359
208
|
|
|
360
|
-
|
|
209
|
+
In order to build `commonjs`, the writing method is
|
|
361
210
|
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
coverage/**
|
|
365
|
-
es/**
|
|
366
|
-
umd/**
|
|
367
|
-
site/**
|
|
368
|
-
public/**
|
|
369
|
-
src/*/__tests__/**
|
|
370
|
-
*.md
|
|
211
|
+
```js
|
|
212
|
+
import * as dayjs from 'dayjs'
|
|
371
213
|
```
|
|
372
214
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
{
|
|
379
|
-
|
|
380
|
-
"strict": true,
|
|
381
|
-
"downlevelIteration": true,
|
|
382
|
-
"declaration": true,
|
|
383
|
-
"skipLibCheck": true,
|
|
384
|
-
"esModuleInterop": true,
|
|
385
|
-
"allowJs": true,
|
|
386
|
-
"lib": ["esnext", "dom"],
|
|
387
|
-
"allowSyntheticDefaultImports": true,
|
|
388
|
-
"jsx": "preserve"
|
|
215
|
+
In the project, we embrace the first way of writing the `esmodule` module, and make the following configuration for adaptation
|
|
216
|
+
|
|
217
|
+
```js
|
|
218
|
+
// varlet.config.js
|
|
219
|
+
module.exports = {
|
|
220
|
+
moduleCompatible: {
|
|
221
|
+
"import dayjs from 'dayjs/esm'\n": "import * as dayjs from 'dayjs'\n"
|
|
389
222
|
}
|
|
390
223
|
}
|
|
391
224
|
```
|
|
392
|
-
|
|
393
|
-
#### Note before release
|
|
394
|
-
|
|
395
|
-
- 1.The registry of npm must set to the official npm mirror
|
|
396
|
-
- 2.The npm must execute the login command for user login
|
|
397
|
-
|
|
398
|
-
### Contributors
|
|
399
|
-
|
|
400
|
-
<a href="https://github.com/varletjs/varlet/graphs/contributors">
|
|
401
|
-
<img src="https://contrib.rocks/image?repo=haoziqaq/varlet" />
|
|
402
|
-
</a>
|
package/README.md
CHANGED
|
@@ -3,31 +3,27 @@
|
|
|
3
3
|
开箱即用的 `Vue3组件库` 快速成型工具,提供了一系列命令和工具去解决组件库开发上的问题
|
|
4
4
|
|
|
5
5
|
### 特性
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
6
|
+
- 📦 开箱即用的组件库开发环境
|
|
7
|
+
- 📦 开箱即用的组件库编译工具,支持导出 `esm`, `cjs`, `umd` 三种模块代码
|
|
8
|
+
- 🛠️ 基于配置文件的组件库文档站点,支持百度统计和主题定制
|
|
9
|
+
- 🛠️ 支持 `sfc` 和 `tsx` 两种风格的组件库编写风格
|
|
10
|
+
- 📦 开箱即用的代码检查工具
|
|
11
|
+
- 📦 开箱即用的单元测试工具
|
|
12
|
+
- 📦 开箱即用的代码发布工具,同时发布到 `npm` 和 `github`, 并自动生成更新日志
|
|
13
|
+
- 💪 支持 `Typescript`
|
|
14
|
+
- 💪 支持 `暗黑模式`
|
|
15
|
+
- 🌍 支持 `国际化`
|
|
16
|
+
- 🚀 基于 `pnpm`
|
|
17
17
|
|
|
18
18
|
### 快速开始
|
|
19
19
|
|
|
20
|
-
`@varlet/cli` 内置了
|
|
21
|
-
|
|
20
|
+
`@varlet/cli` 内置了 `sfc` 和 `tsx` 两种风格的组件库项目模板,可以通过 `gen` 命令直接生成。
|
|
21
|
+
方便您直接进入组件库开发。
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
# 安装命令行工具
|
|
25
25
|
pnpm add @varlet/cli -g
|
|
26
|
-
|
|
27
|
-
varlet-cli gen 项目名
|
|
28
|
-
cd 项目名
|
|
29
|
-
pnpm install
|
|
30
|
-
pnpm dev
|
|
26
|
+
varlet-cli gen
|
|
31
27
|
```
|
|
32
28
|
|
|
33
29
|
然后通过简单修改一些组件库模板的基础信息,就可以开始组件库的开发了
|
|
@@ -36,169 +32,59 @@ pnpm dev
|
|
|
36
32
|
|
|
37
33
|
### 配置文件
|
|
38
34
|
|
|
39
|
-
项目根目录下的 `varlet.config.js`
|
|
35
|
+
项目根目录下的 `varlet.config.js` 用来管理整个组件库项目的具体细节。
|
|
36
|
+
默认配置可查阅 [varlet.default.config.js](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/varlet.default.config.js)。
|
|
37
|
+
也可以参考 `@varlet/ui` 的 [varlet.config.js](https://github.com/varletjs/varlet/blob/dev/packages/varlet-ui/varlet.config.js)
|
|
40
38
|
|
|
41
39
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
42
40
|
| ----- | -------------- | -------- | ---------- |
|
|
41
|
+
| `name` | 组件库全名,会作为包名 | _string_ | `Varlet` |
|
|
42
|
+
| `namespace` | 组件库命名空间, 会作为组件前缀 | _string_ | `var` |
|
|
43
43
|
| `host` | 开发服务器主机 | _number_ | `localhost` |
|
|
44
44
|
| `port` | 开发服务器端口 | _number_ | `8080` |
|
|
45
|
-
| `name` | 组件库全名 | _string_ | `Varlet` |
|
|
46
|
-
| `namespace` | 组件库命名空间, 会作为组件前缀 | _string_ | `var` |
|
|
47
45
|
| `title` | 文档中组件库的标题 | _string_ | `VARLET` |
|
|
48
46
|
| `logo` | 文档中组件库的logo | _string_ | `-` |
|
|
49
47
|
| `defaultLanguage` | 文档默认语言 | _string_ | `zh-CN` |
|
|
50
48
|
| `useMobile` | 是否显示右侧手机预览 | _boolean_ | `false` |
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `highlight` | 文档代码片段样式相关 |
|
|
54
|
-
| `analysis` | 文档统计相关 |
|
|
55
|
-
| `pc` | pc端文档结构配置 |
|
|
56
|
-
| `mobile` | mobile端文档结构配置 |
|
|
49
|
+
| `lightTheme` | 亮色模式文档主题 | _Record<string, any>_ | `-` |
|
|
50
|
+
| `darkTheme` | 暗黑模式文档主题 | _Record<string, any>_ | `-` |
|
|
51
|
+
| `highlight` | 文档代码片段样式相关 | _{ style: string }_ | `-` |
|
|
52
|
+
| `analysis` | 文档统计相关 | _{ baidu: string }_ | `-` |
|
|
53
|
+
| `pc` | pc端文档结构配置 | _Record<string, any>_ | `-` |
|
|
54
|
+
| `mobile` | mobile端文档结构配置 | _Record<string, any>_ | `-` |
|
|
57
55
|
| `moduleCompatible` | 模块兼容配置 | _Record<string, string>_ | `-` |
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
### 自定义页面
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
如果想在组件库中插入其他页面,可以在项目根目录下的创建 `pages` 文件夹编写 vue 组件, 用来生成其他的页面。
|
|
60
|
+
目录结构如下:
|
|
62
61
|
|
|
63
62
|
```js
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
|-- varlet-ui
|
|
64
|
+
|-- src
|
|
65
|
+
|-- docs
|
|
66
|
+
|-- pages
|
|
67
|
+
|-- sponsor
|
|
68
|
+
|-- index.vue
|
|
69
|
+
|-- contributor
|
|
70
|
+
|-- locale
|
|
71
|
+
|-- en-US.ts
|
|
72
|
+
|-- index.vue
|
|
73
|
+
|-- changelog
|
|
74
|
+
|-- locale
|
|
75
|
+
|-- zh-CN.ts
|
|
76
|
+
|-- en-US.ts
|
|
77
|
+
|-- index.vue
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
生成的路由如下:
|
|
68
82
|
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
// varlet.config.js
|
|
77
|
-
module.exports = {
|
|
78
|
-
moduleCompatible: {
|
|
79
|
-
"import dayjs from 'dayjs/esm'\n": "import * as dayjs from 'dayjs'\n"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
#### SiteThemes
|
|
85
|
-
|
|
86
|
-
主题变量相关,由于默认的主题变量可能时常修改,以 `varlet` 官方文档的主题为准
|
|
87
|
-
|
|
88
|
-
| 参数 |
|
|
89
|
-
| ----- |
|
|
90
|
-
| `color-body` |
|
|
91
|
-
| `color-bar` |
|
|
92
|
-
| `color-sub-bar` |
|
|
93
|
-
| `color-text` |
|
|
94
|
-
| `color-sub-text` |
|
|
95
|
-
| `color-border` |
|
|
96
|
-
| `color-shadow` |
|
|
97
|
-
| `color-introduce-border` |
|
|
98
|
-
| `color-primary` |
|
|
99
|
-
| `color-link` |
|
|
100
|
-
| `color-type` |
|
|
101
|
-
| `color-progress` |
|
|
102
|
-
| `color-progress-track` |
|
|
103
|
-
| `color-side-bar` |
|
|
104
|
-
| `color-side-bar-active-background` |
|
|
105
|
-
| `color-app-bar` |
|
|
106
|
-
| `color-nav-button-hover-background` |
|
|
107
|
-
| `color-mobile-cell-hover` |
|
|
108
|
-
| `color-pc-language-active` |
|
|
109
|
-
| `color-pc-language-active-background` |
|
|
110
|
-
| `color-mobile-language-active` |
|
|
111
|
-
| `color-mobile-language-active-background` |
|
|
112
|
-
| `color-hl-background` |
|
|
113
|
-
| `color-hl-code` |
|
|
114
|
-
| `color-hl-border` |
|
|
115
|
-
| `color-hl-group-a` |
|
|
116
|
-
| `color-hl-group-b` |
|
|
117
|
-
| `color-hl-group-c` |
|
|
118
|
-
| `color-hl-group-d` |
|
|
119
|
-
| `color-hl-group-e` |
|
|
120
|
-
| `color-hl-group-f` |
|
|
121
|
-
| `color-hl-group-g` |
|
|
122
|
-
| `color-hl-group-h` |
|
|
123
|
-
| `color-hl-group-i` |
|
|
124
|
-
|
|
125
|
-
#### SiteHighlight
|
|
126
|
-
|
|
127
|
-
代码片段高亮,基于[highlight.js](https://highlightjs.org/)
|
|
128
|
-
|
|
129
|
-
| 参数 | 说明 | 类型 | 默认值 |
|
|
130
|
-
| ----- | -------------- | -------- | ---------- |
|
|
131
|
-
| `style` | highlight的css地址 | _string_ | `-` |
|
|
132
|
-
|
|
133
|
-
#### SiteAnalysis
|
|
134
|
-
|
|
135
|
-
统计埋点相关
|
|
136
|
-
|
|
137
|
-
| 参数 | 说明 | 类型 | 默认值 |
|
|
138
|
-
| ----- | -------------- | -------- | ---------- |
|
|
139
|
-
| `baidu` | 百度统计脚本地址 | _string_ | `-` |
|
|
140
|
-
|
|
141
|
-
#### SitePC, SiteMobile
|
|
142
|
-
|
|
143
|
-
文档结构部分相关,示例配置如下
|
|
144
|
-
|
|
145
|
-
```js
|
|
146
|
-
module.exports = {
|
|
147
|
-
pc: {
|
|
148
|
-
redirect: '/home',
|
|
149
|
-
title: {
|
|
150
|
-
'zh-CN': '一个组件库',
|
|
151
|
-
},
|
|
152
|
-
header: {
|
|
153
|
-
darkMode: null,
|
|
154
|
-
i18n: null,
|
|
155
|
-
github: 'https://github.com/varletjs/varlet',
|
|
156
|
-
},
|
|
157
|
-
menu: [
|
|
158
|
-
{
|
|
159
|
-
text: {
|
|
160
|
-
'zh-CN': '开发指南',
|
|
161
|
-
},
|
|
162
|
-
// 侧边栏菜单目录
|
|
163
|
-
type: 1,
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
text: {
|
|
167
|
-
'zh-CN': '基本介绍',
|
|
168
|
-
},
|
|
169
|
-
doc: 'home',
|
|
170
|
-
// 索引项目根目录下的md文档
|
|
171
|
-
type: 3,
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
text: {
|
|
175
|
-
'zh-CN': '基础组件',
|
|
176
|
-
},
|
|
177
|
-
type: 1,
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
text: {
|
|
181
|
-
'zh-CN': 'Button 按钮',
|
|
182
|
-
},
|
|
183
|
-
doc: 'button',
|
|
184
|
-
// 索引组件根目录下的md文档
|
|
185
|
-
type: 2,
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
},
|
|
189
|
-
mobile: {
|
|
190
|
-
redirect: '/home',
|
|
191
|
-
title: {
|
|
192
|
-
'zh-CN': '一个组件库',
|
|
193
|
-
},
|
|
194
|
-
header: {
|
|
195
|
-
darkMode: null,
|
|
196
|
-
i18n: null,
|
|
197
|
-
playground: null,
|
|
198
|
-
github: 'https://github.com/varletjs/varlet',
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
}
|
|
83
|
+
```text
|
|
84
|
+
/zh-CN/sponsor
|
|
85
|
+
/en-US/contributor
|
|
86
|
+
/zh-CN/changelog
|
|
87
|
+
/en-US/changelog
|
|
202
88
|
```
|
|
203
89
|
|
|
204
90
|
### 命令相关
|
|
@@ -266,132 +152,71 @@ varlet-cli release
|
|
|
266
152
|
```
|
|
267
153
|
|
|
268
154
|
#### 生成一个项目模板
|
|
155
|
+
|
|
269
156
|
```shell
|
|
270
|
-
varlet-cli gen
|
|
157
|
+
varlet-cli gen
|
|
158
|
+
|
|
159
|
+
# Options
|
|
160
|
+
-n
|
|
161
|
+
--name
|
|
162
|
+
项目名
|
|
163
|
+
-s
|
|
164
|
+
--sfc
|
|
165
|
+
生成 sfc 风格的项目模板
|
|
166
|
+
-t
|
|
167
|
+
--tsx
|
|
168
|
+
生成 tsx 格式项目
|
|
169
|
+
-l
|
|
170
|
+
--locale
|
|
171
|
+
需要支持国际化
|
|
271
172
|
```
|
|
272
173
|
|
|
273
|
-
|
|
174
|
+
#### 创建组件模板文件
|
|
274
175
|
|
|
275
|
-
|
|
176
|
+
```shell
|
|
177
|
+
varlet-cli create
|
|
276
178
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
179
|
+
# Options
|
|
180
|
+
-n
|
|
181
|
+
--name
|
|
182
|
+
组件名
|
|
183
|
+
-s
|
|
184
|
+
--sfc
|
|
185
|
+
生成 sfc 风格的组件
|
|
186
|
+
-t
|
|
187
|
+
--tsx
|
|
188
|
+
生成 tsx 风格的文件
|
|
189
|
+
-l
|
|
190
|
+
--locale
|
|
191
|
+
需要支持国际化
|
|
284
192
|
```
|
|
285
193
|
|
|
286
|
-
|
|
194
|
+
### 发布前注意
|
|
287
195
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
module.exports = {
|
|
291
|
-
presets: [
|
|
292
|
-
[
|
|
293
|
-
'@varlet/cli/preset',
|
|
294
|
-
{
|
|
295
|
-
loose: process.env.NODE_ENV === 'compile',
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
],
|
|
299
|
-
}
|
|
300
|
-
```
|
|
196
|
+
1. `npm` 的仓库源必须指向 `npm` 官方镜像
|
|
197
|
+
2. 执行 `npm login` 进行登录
|
|
301
198
|
|
|
302
|
-
###
|
|
303
|
-
|
|
304
|
-
#### git-hook
|
|
305
|
-
|
|
306
|
-
`simple-git-hooks`,`lint-staged` 配合 `eslint`,`stylelint`,`varlet-cli commit-lint` 做commit前的检查,`package.json` 配置如下
|
|
307
|
-
|
|
308
|
-
```json
|
|
309
|
-
{
|
|
310
|
-
"simple-git-hooks": {
|
|
311
|
-
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
312
|
-
"commit-msg": "npx --no-install varlet-cli commit-lint $1"
|
|
313
|
-
},
|
|
314
|
-
"lint-staged": {
|
|
315
|
-
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
316
|
-
"*.{ts,tsx,js,vue}": "eslint --fix",
|
|
317
|
-
"*.{vue,css,less}": "stylelint --fix"
|
|
318
|
-
},
|
|
319
|
-
"eslintConfig": {
|
|
320
|
-
"root": true,
|
|
321
|
-
"ignorePatterns": [
|
|
322
|
-
"es/**",
|
|
323
|
-
"umd/**",
|
|
324
|
-
"site/**",
|
|
325
|
-
"public/**",
|
|
326
|
-
"src/*/__tests__/**",
|
|
327
|
-
".varlet/**"
|
|
328
|
-
],
|
|
329
|
-
"extends": [
|
|
330
|
-
"@varlet"
|
|
331
|
-
]
|
|
332
|
-
},
|
|
333
|
-
"stylelint": {
|
|
334
|
-
"extends": [
|
|
335
|
-
"@varlet/stylelint-config"
|
|
336
|
-
],
|
|
337
|
-
"ignoreFiles": [
|
|
338
|
-
"es/**",
|
|
339
|
-
"umd/**",
|
|
340
|
-
"site/**",
|
|
341
|
-
"coverage/**",
|
|
342
|
-
"public/**",
|
|
343
|
-
"highlight/**"
|
|
344
|
-
]
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
```
|
|
199
|
+
### 模块适配对象
|
|
348
200
|
|
|
349
|
-
|
|
201
|
+
一些外部依赖可能需要进行模块语法的适配,以达到可以正确编译到 `commonjs` 和 `esmodule` 的目的,例如 `dayjs` 的 `esmodule` 写法是
|
|
350
202
|
|
|
351
|
-
```
|
|
352
|
-
|
|
203
|
+
```js
|
|
204
|
+
import dayjs from 'dayjs/esm'
|
|
353
205
|
```
|
|
354
206
|
|
|
355
|
-
|
|
207
|
+
而为了构建 `commonjs` 时的写法是
|
|
356
208
|
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
coverage/**
|
|
360
|
-
es/**
|
|
361
|
-
umd/**
|
|
362
|
-
site/**
|
|
363
|
-
public/**
|
|
364
|
-
src/*/__tests__/**
|
|
365
|
-
*.md
|
|
209
|
+
```js
|
|
210
|
+
import * as dayjs from 'dayjs'
|
|
366
211
|
```
|
|
367
212
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
{
|
|
374
|
-
|
|
375
|
-
"strict": true,
|
|
376
|
-
"downlevelIteration": true,
|
|
377
|
-
"declaration": true,
|
|
378
|
-
"skipLibCheck": true,
|
|
379
|
-
"esModuleInterop": true,
|
|
380
|
-
"allowJs": true,
|
|
381
|
-
"lib": ["esnext", "dom"],
|
|
382
|
-
"allowSyntheticDefaultImports": true,
|
|
383
|
-
"jsx": "preserve"
|
|
213
|
+
在项目中我们拥抱 `esmodule` 模块使用第一种写法,并做如下配置进行适配
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
// varlet.config.js
|
|
217
|
+
module.exports = {
|
|
218
|
+
moduleCompatible: {
|
|
219
|
+
"import dayjs from 'dayjs/esm'\n": "import * as dayjs from 'dayjs'\n"
|
|
384
220
|
}
|
|
385
221
|
}
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
#### 发布前注意
|
|
389
|
-
|
|
390
|
-
1. `npm` 的仓库源必须指向 `npm` 官方镜像
|
|
391
|
-
2. 执行 `npm login` 进行登录
|
|
392
|
-
|
|
393
|
-
### Contributors
|
|
394
|
-
|
|
395
|
-
<a href="https://github.com/varletjs/varlet/graphs/contributors">
|
|
396
|
-
<img src="https://contrib.rocks/image?repo=haoziqaq/varlet" />
|
|
397
|
-
</a>
|
|
222
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.1664527888620",
|
|
4
4
|
"description": "cli of varlet",
|
|
5
5
|
"bin": {
|
|
6
6
|
"varlet-cli": "./lib/index.js"
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@babel/helper-plugin-utils": "^7.14.5",
|
|
33
33
|
"@babel/preset-env": "^7.14.8",
|
|
34
34
|
"@babel/preset-typescript": "^7.14.5",
|
|
35
|
-
"@varlet/icons": "2.0.0-alpha.
|
|
36
|
-
"@varlet/markdown-vite-plugin": "2.0.0-alpha.
|
|
37
|
-
"@varlet/shared": "2.0.0-alpha.
|
|
38
|
-
"@varlet/touch-emulator": "2.0.0-alpha.
|
|
35
|
+
"@varlet/icons": "2.0.0-alpha.1664527888620",
|
|
36
|
+
"@varlet/markdown-vite-plugin": "2.0.0-alpha.1664527888620",
|
|
37
|
+
"@varlet/shared": "2.0.0-alpha.1664527888620",
|
|
38
|
+
"@varlet/touch-emulator": "2.0.0-alpha.1664527888620",
|
|
39
39
|
"@vitejs/plugin-vue": "3.0.1",
|
|
40
40
|
"@vitejs/plugin-vue-jsx": "2.0.0",
|
|
41
41
|
"@vue/babel-plugin-jsx": "1.1.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@types/semver": "^7.3.9"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@varlet/touch-emulator": "2.0.0-alpha.
|
|
83
|
+
"@varlet/touch-emulator": "2.0.0-alpha.1664527888620",
|
|
84
84
|
"@vue/runtime-core": "3.2.16",
|
|
85
85
|
"@vue/test-utils": "^2.0.2",
|
|
86
86
|
"clipboard": "^2.0.6",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="var-site-code-example">
|
|
3
3
|
<div class="var-site-code-example__toolbar">
|
|
4
4
|
<var-button text round @click="toggle" v-if="fold && !disabledFold">
|
|
5
|
-
<var-icon name="xml" size="18"
|
|
5
|
+
<var-icon name="xml" size="18"/>
|
|
6
6
|
</var-button>
|
|
7
7
|
|
|
8
8
|
<var-button
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
round
|
|
13
13
|
v-if="clipboard"
|
|
14
14
|
>
|
|
15
|
-
<var-icon name="content-copy" size="18"
|
|
15
|
+
<var-icon name="content-copy" size="18"/>
|
|
16
16
|
</var-button>
|
|
17
17
|
|
|
18
18
|
<var-button text round @click="toPlayground" v-if="playground">
|
|
19
|
-
<var-icon name="code-json" size="18"
|
|
19
|
+
<var-icon name="code-json" size="18"/>
|
|
20
20
|
</var-button>
|
|
21
21
|
</div>
|
|
22
22
|
<div
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
:style="{
|
|
28
28
|
height: height >= 0 ? `${height}px` : undefined,
|
|
29
29
|
}"
|
|
30
|
-
|
|
30
|
+
>
|
|
31
31
|
<slot/>
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
@@ -43,7 +43,7 @@ import config from '@config'
|
|
|
43
43
|
import { defineComponent, nextTick, ref, onMounted } from 'vue'
|
|
44
44
|
import { doubleRaf } from '../utils/elements'
|
|
45
45
|
import { get } from 'lodash-es'
|
|
46
|
-
import { getBrowserTheme, getPCLocationInfo, utoa } from
|
|
46
|
+
import { getBrowserTheme, getPCLocationInfo, utoa } from '../../utils'
|
|
47
47
|
import type { Ref } from 'vue'
|
|
48
48
|
|
|
49
49
|
let clipId = 0
|
|
@@ -68,7 +68,7 @@ export default defineComponent({
|
|
|
68
68
|
const disabledFold: Ref<boolean> = ref(false)
|
|
69
69
|
const clipboard: Ref = ref(get(config, 'pc.clipboard', {}))
|
|
70
70
|
const height: Ref<number> = ref(-1)
|
|
71
|
-
const playground: Ref<string | undefined> = ref(!props.playgroundIgnore ? get(config, 'pc.header.playground') : undefined
|
|
71
|
+
const playground: Ref<string | undefined> = ref(!props.playgroundIgnore ? get(config, 'pc.header.playground') : undefined)
|
|
72
72
|
let timer: any = null
|
|
73
73
|
|
|
74
74
|
const toggle = async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createApp, h, onActivated, onDeactivated, onMounted, onUnmounted, ref, Ref } from
|
|
1
|
+
import { createApp, h, onActivated, onDeactivated, onMounted, onUnmounted, ref, Ref } from 'vue'
|
|
2
2
|
import type { Component } from 'vue'
|
|
3
|
-
import { isArray } from
|
|
3
|
+
import { isArray } from '@varlet/shared'
|
|
4
4
|
|
|
5
5
|
export interface MountInstance {
|
|
6
6
|
instance: any
|
package/site/mobile/App.vue
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<var-app-bar class="app-bar" title-position="left" :title="bigCamelizeComponentName">
|
|
5
5
|
<template #left>
|
|
6
6
|
<var-button v-if="showBackIcon" text round @click="back" color="transparent" text-color="#fff">
|
|
7
|
-
<var-icon name="chevron-left" class="arrow-left" style="margin-top: 1px"
|
|
7
|
+
<var-icon name="chevron-left" class="arrow-left" style="margin-top: 1px"/>
|
|
8
8
|
</var-button>
|
|
9
9
|
<var-button
|
|
10
10
|
v-if="!showBackIcon && github"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
color="transparent"
|
|
16
16
|
text-color="#fff"
|
|
17
17
|
>
|
|
18
|
-
<var-icon name="github" class="github" style="margin-top: 1px"
|
|
18
|
+
<var-icon name="github" class="github" style="margin-top: 1px"/>
|
|
19
19
|
</var-button>
|
|
20
20
|
</template>
|
|
21
21
|
<template #right>
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
@click.stop="showMenu = true"
|
|
45
45
|
v-if="languages"
|
|
46
46
|
>
|
|
47
|
-
<var-icon name="translate" class="i18n"
|
|
48
|
-
<var-icon name="chevron-down" class="arrow-down"
|
|
47
|
+
<var-icon name="translate" class="i18n"/>
|
|
48
|
+
<var-icon name="chevron-down" class="arrow-down"/>
|
|
49
49
|
</var-button>
|
|
50
50
|
</template>
|
|
51
51
|
</var-app-bar>
|
|
52
52
|
</header>
|
|
53
53
|
<div class="router-view__block">
|
|
54
|
-
<router-view
|
|
54
|
+
<router-view/>
|
|
55
55
|
</div>
|
|
56
56
|
|
|
57
57
|
<transition name="site-menu">
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
Theme,
|
|
85
85
|
watchLang,
|
|
86
86
|
watchTheme
|
|
87
|
-
} from
|
|
87
|
+
} from '../utils'
|
|
88
88
|
import { bigCamelize } from '@varlet/shared'
|
|
89
89
|
import { get } from 'lodash-es'
|
|
90
90
|
|
|
@@ -220,6 +220,7 @@ body {
|
|
|
220
220
|
transform: translateY(-10px);
|
|
221
221
|
opacity: 0;
|
|
222
222
|
}
|
|
223
|
+
|
|
223
224
|
&-menu-enter-active,
|
|
224
225
|
&-menu-leave-active {
|
|
225
226
|
transition-property: opacity, transform;
|
package/site/pc/Layout.vue
CHANGED
|
@@ -7,15 +7,9 @@ import context from '../components/context'
|
|
|
7
7
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
8
8
|
import { useRoute } from 'vue-router'
|
|
9
9
|
import { get } from 'lodash-es'
|
|
10
|
-
import { getPCLocationInfo, MenuTypes } from
|
|
10
|
+
import { getPCLocationInfo, MenuTypes, type Menu } from '../utils'
|
|
11
11
|
import type { Ref } from 'vue'
|
|
12
12
|
|
|
13
|
-
export interface Menu {
|
|
14
|
-
doc: string
|
|
15
|
-
text: Record<string, string>
|
|
16
|
-
type: MenuTypes
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
const menu: Ref<Menu[]> = ref(get(config, 'pc.menu', []))
|
|
20
14
|
const useMobile = ref(get(config, 'useMobile'))
|
|
21
15
|
const mobileRedirect = get(config, 'mobile.redirect')
|
|
@@ -94,7 +88,7 @@ watch(
|
|
|
94
88
|
|
|
95
89
|
<template>
|
|
96
90
|
<div class="varlet-site">
|
|
97
|
-
<app-header :language="language"
|
|
91
|
+
<app-header :language="language"/>
|
|
98
92
|
|
|
99
93
|
<div class="varlet-site-content">
|
|
100
94
|
<app-sidebar
|
|
@@ -109,7 +103,7 @@ watch(
|
|
|
109
103
|
ref="doc"
|
|
110
104
|
:class="[!useMobile && 'varlet-site-doc-container--pc-only']"
|
|
111
105
|
>
|
|
112
|
-
<router-view
|
|
106
|
+
<router-view/>
|
|
113
107
|
</div>
|
|
114
108
|
|
|
115
109
|
<app-mobile
|
|
@@ -127,7 +121,8 @@ watch(
|
|
|
127
121
|
@click-overlay="confirmClose"
|
|
128
122
|
>
|
|
129
123
|
<div class="varlet-site-playground-container">
|
|
130
|
-
<iframe id="playground" class="varlet-site-playground-iframe" :src="context.playgroundURL"
|
|
124
|
+
<iframe id="playground" class="varlet-site-playground-iframe" :src="context.playgroundURL"
|
|
125
|
+
frameborder="0"></iframe>
|
|
131
126
|
</div>
|
|
132
127
|
</var-popup>
|
|
133
128
|
</template>
|
|
@@ -413,7 +408,7 @@ iframe {
|
|
|
413
408
|
margin-bottom: 30px;
|
|
414
409
|
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
415
410
|
|
|
416
|
-
&:first-child{
|
|
411
|
+
&:first-child {
|
|
417
412
|
margin-top: 30px;
|
|
418
413
|
}
|
|
419
414
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import config from '@config'
|
|
3
3
|
import { ref, computed, defineComponent } from 'vue'
|
|
4
4
|
import { get } from 'lodash-es'
|
|
5
|
-
import { getBrowserTheme, getPCLocationInfo, removeEmpty, setTheme, Theme, watchTheme } from
|
|
5
|
+
import { getBrowserTheme, getPCLocationInfo, removeEmpty, setTheme, Theme, watchTheme } from '../../utils'
|
|
6
6
|
import { useRouter } from 'vue-router'
|
|
7
7
|
import AnimationBox from './AnimationBox.vue'
|
|
8
8
|
import type { Ref, ComputedRef } from 'vue'
|
|
@@ -68,7 +68,7 @@ export default defineComponent({
|
|
|
68
68
|
const open = (value: string) => {
|
|
69
69
|
setTimeout(() => {
|
|
70
70
|
window.location.href = value
|
|
71
|
-
}, 350)
|
|
71
|
+
}, 350)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
watchTheme((theme, from) => {
|
|
@@ -111,8 +111,8 @@ export default defineComponent({
|
|
|
111
111
|
<template>
|
|
112
112
|
<div class="varlet-site-header">
|
|
113
113
|
<div class="varlet-site-header__lead">
|
|
114
|
-
<animation-box class="varlet-site-header__logo"
|
|
115
|
-
<div class="varlet-site-header__title" v-if="title"
|
|
114
|
+
<animation-box class="varlet-site-header__logo" @click="backRoot"/>
|
|
115
|
+
<div class="varlet-site-header__title" v-if="title" @click="backRoot">{{ title }}</div>
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div class="varlet-site-header__tail">
|
|
@@ -123,7 +123,7 @@ export default defineComponent({
|
|
|
123
123
|
v-if="versionItems"
|
|
124
124
|
>
|
|
125
125
|
<span style="font-size: 14px;">{{ currentVersion }}</span>
|
|
126
|
-
<var-icon name="chevron-down"
|
|
126
|
+
<var-icon name="chevron-down"/>
|
|
127
127
|
<transition name="fade">
|
|
128
128
|
<div
|
|
129
129
|
class="varlet-site-header__animation-list varlet-site-header__animation-versions var-site-elevation--5"
|
|
@@ -143,10 +143,10 @@ export default defineComponent({
|
|
|
143
143
|
</div>
|
|
144
144
|
|
|
145
145
|
<a class="varlet-site-header__link" target="_blank" :href="playground" v-ripple v-if="playground">
|
|
146
|
-
<var-icon name="code-json" :size="24"
|
|
146
|
+
<var-icon name="code-json" :size="24"/>
|
|
147
147
|
</a>
|
|
148
148
|
<a class="varlet-site-header__link" target="_blank" :href="github" v-ripple v-if="github">
|
|
149
|
-
<var-icon name="github" :size="28"
|
|
149
|
+
<var-icon name="github" :size="28"/>
|
|
150
150
|
</a>
|
|
151
151
|
<div class="varlet-site-header__theme" v-ripple v-if="darkMode" @click="toggleTheme">
|
|
152
152
|
<var-icon
|
|
@@ -164,8 +164,8 @@ export default defineComponent({
|
|
|
164
164
|
@mouseleave="isOpenLanguageMenu = false"
|
|
165
165
|
v-if="languages"
|
|
166
166
|
>
|
|
167
|
-
<var-icon name="translate" size="26px"
|
|
168
|
-
<var-icon name="chevron-down"
|
|
167
|
+
<var-icon name="translate" size="26px"/>
|
|
168
|
+
<var-icon name="chevron-down"/>
|
|
169
169
|
<transition name="fade">
|
|
170
170
|
<div
|
|
171
171
|
class="varlet-site-header__animation-list var-site-elevation--5"
|
|
@@ -178,7 +178,7 @@ export default defineComponent({
|
|
|
178
178
|
:key="key"
|
|
179
179
|
:class="{ 'varlet-site-header__animation-list--active': language === key }"
|
|
180
180
|
@click="handleLanguageChange(key)"
|
|
181
|
-
|
|
181
|
+
>{{ value }}
|
|
182
182
|
</var-cell>
|
|
183
183
|
</div>
|
|
184
184
|
</transition>
|
|
@@ -361,7 +361,7 @@ export default defineComponent({
|
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
&__animation-versions {
|
|
365
365
|
left: -7px;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
@@ -24,10 +24,9 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script lang="ts">
|
|
27
|
-
import { MenuTypes } from '../../utils'
|
|
27
|
+
import { MenuTypes, type Menu } from '../../utils'
|
|
28
28
|
import { reactive, defineComponent } from 'vue'
|
|
29
29
|
import type { PropType } from 'vue'
|
|
30
|
-
import type { Menu } from '../Layout.vue'
|
|
31
30
|
|
|
32
31
|
export default defineComponent({
|
|
33
32
|
name: 'AppSidebar',
|
|
@@ -4,7 +4,7 @@ import config from '@config'
|
|
|
4
4
|
import { get } from 'lodash-es'
|
|
5
5
|
import { ref, watch } from 'vue'
|
|
6
6
|
import { useRoute, useRouter } from 'vue-router'
|
|
7
|
-
import { getBrowserTheme, setTheme, Theme } from
|
|
7
|
+
import { getBrowserTheme, setTheme, Theme } from '../../../utils'
|
|
8
8
|
import { getPCLocationInfo, watchTheme } from '@varlet/cli/site/utils'
|
|
9
9
|
import type { Ref } from 'vue'
|
|
10
10
|
|
|
@@ -75,17 +75,17 @@ watch(() => route.path, setLocale, { immediate: true })
|
|
|
75
75
|
<div class="varlet-doc-index__layout">
|
|
76
76
|
<div class="varlet-doc-index__logo-container">
|
|
77
77
|
<div class="varlet-doc-index__logo-background-mask"></div>
|
|
78
|
-
<animation-box class="varlet-doc-index__logo"
|
|
78
|
+
<animation-box class="varlet-doc-index__logo"/>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
81
|
<div class="varlet-doc-index__title">{{ title }}</div>
|
|
82
82
|
<div class="varlet-doc-index__description">{{ indexPage.description[language] }}</div>
|
|
83
83
|
<div class="varlet-doc-index__link-button-group">
|
|
84
84
|
<var-button class="varlet-doc-index__link-button" text outline @click="goGithub">
|
|
85
|
-
<var-icon name="github" size="24px"
|
|
85
|
+
<var-icon name="github" size="24px"/>
|
|
86
86
|
</var-button>
|
|
87
87
|
<var-button class="varlet-doc-index__link-button" text outline v-if="darkMode" @click="toggleTheme">
|
|
88
|
-
<var-icon size="24px" :name="currentTheme === 'lightTheme' ? 'white-balance-sunny' : 'weather-night'"
|
|
88
|
+
<var-icon size="24px" :name="currentTheme === 'lightTheme' ? 'white-balance-sunny' : 'weather-night'"/>
|
|
89
89
|
</var-button>
|
|
90
90
|
<var-button
|
|
91
91
|
class="varlet-doc-index__link-button"
|
|
@@ -94,11 +94,11 @@ watch(() => route.path, setLocale, { immediate: true })
|
|
|
94
94
|
v-if="languages"
|
|
95
95
|
@click="toggleLanguages"
|
|
96
96
|
>
|
|
97
|
-
<var-icon name="translate" size="24px"
|
|
97
|
+
<var-icon name="translate" size="24px"/>
|
|
98
98
|
</var-button>
|
|
99
99
|
<var-button class="varlet-doc-index__link-button" type="primary" style="line-height: 1.2" @click="getStar">
|
|
100
100
|
<span class="varlet-doc-index__link-button-text">{{ indexPage.started[language] }}</span>
|
|
101
|
-
<var-icon style="transform: rotate(-90deg)" name="arrow-down" size="24px"
|
|
101
|
+
<var-icon style="transform: rotate(-90deg)" name="arrow-down" size="24px"/>
|
|
102
102
|
</var-button>
|
|
103
103
|
</div>
|
|
104
104
|
|
package/site/useProgress.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Progress from './components/progress'
|
|
2
2
|
import config from '@config'
|
|
3
3
|
import { reactive } from 'vue'
|
|
4
|
-
import { getBrowserTheme, mountInstance, Theme, watchTheme } from
|
|
4
|
+
import { getBrowserTheme, mountInstance, Theme, watchTheme } from './utils'
|
|
5
5
|
import { get } from 'lodash-es'
|
|
6
6
|
|
|
7
7
|
function getColor(theme?: Theme) {
|
package/site/utils.ts
CHANGED
|
@@ -39,6 +39,12 @@ export function isPhone() {
|
|
|
39
39
|
return /Android|webOS|iPhone|iPod|BlackBerry|Pad/i.test(navigator.userAgent)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export interface Menu {
|
|
43
|
+
doc: string
|
|
44
|
+
text: Record<string, string>
|
|
45
|
+
type: MenuTypes
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
export enum MenuTypes {
|
|
43
49
|
TITLE = 1,
|
|
44
50
|
COMPONENT = 2,
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"simple-git-hooks": {
|
|
72
72
|
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
73
|
-
"commit-msg": "
|
|
73
|
+
"commit-msg": "pnpm exec varlet-cli commit-lint $1"
|
|
74
74
|
},
|
|
75
75
|
"eslintConfig": {
|
|
76
76
|
"root": true,
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"simple-git-hooks": {
|
|
72
72
|
"pre-commit": "pnpm exec lint-staged --allow-empty --concurrent false",
|
|
73
|
-
"commit-msg": "
|
|
73
|
+
"commit-msg": "pnpm exec varlet-cli commit-lint $1"
|
|
74
74
|
},
|
|
75
75
|
"eslintConfig": {
|
|
76
76
|
"root": true,
|
package/varlet.default.config.js
CHANGED
|
@@ -152,7 +152,7 @@ module.exports = {
|
|
|
152
152
|
},
|
|
153
153
|
versions: null,
|
|
154
154
|
github: 'https://github.com/varletjs/varlet',
|
|
155
|
-
playground: 'https://varlet-ui-playground-git-dev-varletjs.vercel.app
|
|
155
|
+
playground: 'https://varlet-ui-playground-git-dev-varletjs.vercel.app',
|
|
156
156
|
darkMode: true,
|
|
157
157
|
},
|
|
158
158
|
clipboard: {
|