Skip to content

Commit 491bbc0

Browse files
committed
feat: 脚手架使用 unplugin-auto-import 插件来自动导入 API
实现功能:目前只是默认自动导入vue(框架)以及官方生态库 vue-router、pinia 的相关api,这意味着你需要用到相关库的api,可在文件中直接使用而不需要再次import 注:有可能部分api未被自动导入,如果你直接使用时报错,请手动inport,如 vue-router 库的 createRouter, createWebHistory api。
1 parent 91f2588 commit 491bbc0

File tree

16 files changed

+265
-38
lines changed

16 files changed

+265
-38
lines changed

.eslintignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ coverage
2929

3030
# visualizer产物
3131
stats.html
32-
33-
components.d.ts
32+
# 组件内容生成的类型声明
33+
components.d.ts
34+
# 自动导入相关api内容生成的类型声明
35+
auto-imports.d.ts

.eslintrc-auto-import.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"globals": {
3+
"EffectScope": true,
4+
"acceptHMRUpdate": true,
5+
"computed": true,
6+
"createApp": true,
7+
"createPinia": true,
8+
"customRef": true,
9+
"defineAsyncComponent": true,
10+
"defineComponent": true,
11+
"defineStore": true,
12+
"effectScope": true,
13+
"getActivePinia": true,
14+
"getCurrentInstance": true,
15+
"getCurrentScope": true,
16+
"h": true,
17+
"inject": true,
18+
"isProxy": true,
19+
"isReactive": true,
20+
"isReadonly": true,
21+
"isRef": true,
22+
"mapActions": true,
23+
"mapGetters": true,
24+
"mapState": true,
25+
"mapStores": true,
26+
"mapWritableState": true,
27+
"markRaw": true,
28+
"nextTick": true,
29+
"onActivated": true,
30+
"onBeforeMount": true,
31+
"onBeforeRouteLeave": true,
32+
"onBeforeRouteUpdate": true,
33+
"onBeforeUnmount": true,
34+
"onBeforeUpdate": true,
35+
"onDeactivated": true,
36+
"onErrorCaptured": true,
37+
"onMounted": true,
38+
"onRenderTracked": true,
39+
"onRenderTriggered": true,
40+
"onScopeDispose": true,
41+
"onServerPrefetch": true,
42+
"onUnmounted": true,
43+
"onUpdated": true,
44+
"provide": true,
45+
"reactive": true,
46+
"readonly": true,
47+
"ref": true,
48+
"resolveComponent": true,
49+
"resolveDirective": true,
50+
"setActivePinia": true,
51+
"setMapStoreSuffix": true,
52+
"shallowReactive": true,
53+
"shallowReadonly": true,
54+
"shallowRef": true,
55+
"storeToRefs": true,
56+
"toRaw": true,
57+
"toRef": true,
58+
"toRefs": true,
59+
"triggerRef": true,
60+
"unref": true,
61+
"useAttrs": true,
62+
"useCssModule": true,
63+
"useCssVars": true,
64+
"useLink": true,
65+
"useRoute": true,
66+
"useRouter": true,
67+
"useSlots": true,
68+
"watch": true,
69+
"watchEffect": true,
70+
"watchPostEffect": true,
71+
"watchSyncEffect": true
72+
}
73+
}

.eslintrc.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: zhoukai
55
* @Date: 2022-08-25 15:52:00
66
* @LastEditors: zhoukai
7-
* @LastEditTime: 2023-01-29 17:19:21
7+
* @LastEditTime: 2023-01-30 10:00:34
88
*/
99

1010
/* eslint-env node */
@@ -21,7 +21,8 @@ module.exports = {
2121
'plugin:vue/vue3-essential',
2222
'eslint:recommended',
2323
'@vue/eslint-config-typescript/recommended',
24-
'@vue/eslint-config-prettier'
24+
'@vue/eslint-config-prettier',
25+
'./.eslintrc-auto-import.json'
2526
],
2627
parserOptions: {
2728
ecmaVersion: 'latest'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ node_modules
3030
# visualizer产物
3131
stats.html
3232
# 组件内容生成的类型声明,建议把他加入 gitignore 中,以免出现频繁更改导致 git 监测到项目内容一直变动的问题
33-
compnents.d.ts
33+
compnents.d.ts
34+
35+
auto-imports.d.ts

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"rollup-plugin-visualizer": "^5.8.3",
5454
"tailwindcss": "^3.2.4",
5555
"typescript": "~4.7.4",
56+
"unplugin-auto-import": "^0.13.0",
5657
"unplugin-vue-components": "^0.22.7",
5758
"vite": "^3.0.4",
5859
"vite-plugin-html": "^3.2.0",

pnpm-lock.yaml

Lines changed: 136 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)