qcf 0.0.1

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/dist/config.js ADDED
@@ -0,0 +1 @@
1
+ import kebabCase from"lodash.kebabcase";const prompts={type:"input",name:"inputName",message:"请输入组件名称",validate(e){return!!RegExp(/^[A-Za-z]+[/a-z0-9A-Z_-]*$/).test(e.trim())||"格式错误"}};function onlyName(e){var a=e.split("/");return 1<a.length?a[a.length-1]:e}const obj={component:{description:"这是一个创建组件的生成器",prompts:[{...prompts}],actions(e){var e=e.inputName.split("/").map(e=>kebabCase(e)),a=(console.log(42,e),e[e.length-1]);return[{type:"add",path:`src/components/${e.join("/")}/{{kebabCase name}}.vue`,templateFile:"plop-templates/component/template.hbs",data:{name:a}},{type:"add",path:`src/components/${e.join("/")}/{{kebabCase name}}.less`,templateFile:"plop-templates/component/less.hbs",data:{name:a}}]}},page:{description:"add views | 新增页面",prompts:[{...prompts,message:"请输入页面名称"}],actions(e){var a=e.inputName.split("/").map(e=>kebabCase(e));return a&&a[1]&&-1<a[1].indexOf("components")?(console.log(`不能新增${a[1]}子页面,此名称为系统保留名称`),new Error(`不能新增${a[1]}子页面,此名称为系统保留名称`)):[{type:"add",path:`src/views/${a.join("/")}/{{kebabCase name}}.vue`,templateFile:"plop-templates/views/template.hbs",data:{name:onlyName(e.inputName)}},{type:"add",path:`src/views/${a.join("/")}/{{kebabCase name}}.less`,templateFile:"plop-templates/views/less.hbs",data:{name:onlyName(e.inputName)}}]}},pageComp:{description:"add views Components | 新增页面内组件",prompts:[{type:"list",message:" (。♥ᴗ♥。) 请选择你要给哪个页面增加子组件: (。♥ᴗ♥。) ",name:"parentFolder",choices:[]},{...prompts,message:"请输入页面内部组件名称"}],actions(e){var a=e.parentFolder,t=(console.log(a,e.inputName),kebabCase(e.inputName)),t=(console.log(42,t),`src/views/${a}/components/`);return[{type:"add",path:t+"{{kebabCase name}}/index.vue",templateFile:"plop-templates/views-component/template.hbs",data:{name:onlyName(e.inputName)}},{type:"add",path:t+"{{kebabCase name}}/index.less",templateFile:"plop-templates/views-component/less.hbs",data:{name:onlyName(e.inputName)}}]}},service:{description:"add API service | 新增API服务",prompts:[{...prompts,message:"请输入API服务名称"}],actions(e){e.inputName.split("/").map(e=>kebabCase(e));return[{type:"add",path:"src/api/{{kebabCase name}}-service.js",templateFile:"plop-templates/api/template.hbs",data:{name:onlyName(e.inputName)}}]}},icon:{description:"add SVG Icon | 新增SVG Icon",prompts:[{...prompts,message:"请输入SVG Icon名称"}],actions(e){return[{type:"add",path:"src/components/icons/{{bigCamelCase name}}.vue",templateFile:"plop-templates/icon/template.hbs",data:{name:onlyName(e.inputName)}}]}}};export default obj;
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import kebabCase from"lodash.kebabcase";import camelCase from"lodash.camelcase";import upperFirst from"lodash.upperfirst";import options from"./config.js";import path from"path";import fs from"fs";const generator=function(e){e.setDefaultInclude({generators:!0}),e.setHelper("kebabCase",e=>kebabCase(e)),e.setHelper("bigCamelCase",e=>upperFirst(camelCase(e)));var o=path.join(path.resolve(),"./src/views"),o=fs.readdirSync(o).filter(e=>"index.js"!==e);options.pageComp.prompts[0].choices=o,e.setGenerator("component",options.component),e.setGenerator("page",options.page),e.setGenerator("pageComp",options.pageComp),e.setGenerator("service",options.service),e.setGenerator("icon",options.icon)};console.log(18,generator);export default generator;
@@ -0,0 +1,7 @@
1
+ import { BaseService } from './base-service'
2
+
3
+ class {{bigCamelCase name}}Service extends BaseService{
4
+
5
+ }
6
+
7
+ export const {{camelCase name}}Service = new {{bigCamelCase name}}Service()
@@ -0,0 +1,3 @@
1
+ .comp-{{kebabCase name}} {
2
+
3
+ }
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <div class="comp-{{kebabCase name}}">{{bigCamelCase name}}组件</div>
3
+ </template>
4
+
5
+ <script>
6
+ import { reactive, toRefs } from 'vue';
7
+ export default {
8
+ // eslint-disable-next-line vue/multi-word-component-names
9
+ name: '{{bigCamelCase name}}',
10
+ setup() {
11
+ console.log('1-开始创建组件-setup');
12
+ const data = reactive({});
13
+ return {
14
+ ...toRefs(data)
15
+ };
16
+ }
17
+ };
18
+ </script>
19
+ <style scoped lang="less">
20
+ @import './{{kebabCase name}}.less';
21
+ </style>
@@ -0,0 +1,112 @@
1
+ <template>
2
+ <svg xmlns="http://www.w3.org/2000/svg" :width="_width" :height="_height" :spin="spin" :rtl="rtl" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet" fill="" role="presentation" ref="host">
3
+ <g>
4
+ <path
5
+ d="M18 52.7c10.9-2.3 9.4-15.3 9.1-18.2-.5-4.4-5.7-12-12.7-11.4-8.8.8-10.1 13.5-10.1 13.5C3.1 42.5 7.1 55 18 52.7zm11.5 22.6c-.3.9-1 3.3-.4 5.3 1.2 4.6 5.2 4.8 5.2 4.8H40v-14h-6.1c-2.7.8-4.1 3-4.4 3.9zm8.7-44.4c6 0 10.9-6.9 10.9-15.5C49 6.9 44.2 0 38.2 0S27.3 6.9 27.3 15.4c0 8.6 4.9 15.5 10.9 15.5zm25.8 1c8 1 13.2-7.5 14.2-14s-4.1-14-9.8-15.3C62.7 1.3 55.6 10.4 55 16.4c-.8 7.2 1 14.5 9 15.5zm19.7 38.2s-12.4-9.6-19.7-20c-9.8-15.3-23.8-9.1-28.5-1.3-4.6 7.8-11.9 12.7-12.9 14-1 1.3-15 8.8-11.9 22.6 3.1 13.8 14 13.5 14 13.5s8 .8 17.3-1.3 17.3.5 17.3.5S81 105.4 87 91.4s-3.3-21.3-3.3-21.3zM46.5 90.9H32.4c-6.1-1.2-8.5-5.4-8.8-6.1-.3-.7-2-4.1-1.1-9.8 2.6-8.5 10.2-9.1 10.2-9.1h7.5v-9.2l6.4.1v34.1zm26.3-.1H56.6c-6.3-1.6-6.6-6.1-6.6-6.1v-18l6.6-.1v16.2c.4 1.7 2.5 2 2.5 2h6.7v-18h7v24zm23.1-48c0-3.1-2.6-12.5-12.2-12.5s-10.9 8.8-10.9 15.1c0 6 .5 14.3 12.4 14 12-.2 10.7-13.5 10.7-16.6zm0 0"
6
+ data-follow-fill="#4e6ef2"
7
+ :fill="_fill"
8
+ />
9
+ </g>
10
+ </svg>
11
+ </template>
12
+ <script setup>
13
+ import { ref, computed, onMounted, onUpdated } from 'vue';
14
+ const props = defineProps({
15
+ width: {
16
+ type: [Number, String],
17
+ required: false
18
+ },
19
+ height: {
20
+ type: [Number, String],
21
+ required: false
22
+ },
23
+ stroke: {
24
+ type: String,
25
+ required: false
26
+ },
27
+ fill: {
28
+ type: String,
29
+ required: false
30
+ },
31
+ color: {
32
+ type: String,
33
+ required: false
34
+ },
35
+ spin: {
36
+ type: Boolean,
37
+ required: false
38
+ },
39
+ rtl: {
40
+ type: Boolean,
41
+ required: false
42
+ }
43
+ });
44
+ const size = '1em';
45
+
46
+ const _fill = computed(() => props.fill || props.color || undefined);
47
+ const _stroke = computed(() => props.stroke || props.color || undefined);
48
+ const _width = computed(() => props.width || size || undefined);
49
+ const _height = computed(() => props.height || size || undefined);
50
+ const host = ref(null);
51
+
52
+ onMounted(() => {
53
+ if (!_fill.value) {
54
+ host.value?.querySelectorAll('[data-follow-fill]').forEach((item) => {
55
+ item.setAttribute('fill', item.getAttribute('data-follow-fill') || '');
56
+ });
57
+ }
58
+ if (!_stroke.value) {
59
+ host.value?.querySelectorAll('[data-follow-stroke]').forEach((item) => {
60
+ item.setAttribute('stroke', item.getAttribute('data-follow-stroke') || '');
61
+ });
62
+ }
63
+ });
64
+ onUpdated(() => {
65
+ if (!_fill.value) {
66
+ host.value?.querySelectorAll('[data-follow-fill]').forEach((item) => {
67
+ item.setAttribute('fill', item.getAttribute('data-follow-fill') || '');
68
+ });
69
+ }
70
+ if (!_stroke.value) {
71
+ host.value?.querySelectorAll('[data-follow-stroke]').forEach((item) => {
72
+ item.setAttribute('stroke', item.getAttribute('data-follow-stroke') || '');
73
+ });
74
+ }
75
+ });
76
+ </script>
77
+
78
+ <style scoped>
79
+ svg[spin='true'] {
80
+ animation: iconpark-spin 1s infinite linear;
81
+ }
82
+
83
+ svg[spin='true'][rtl='true'] {
84
+ animation: iconpark-spin-rtl 1s infinite linear;
85
+ }
86
+
87
+ svg[rtl='true'] {
88
+ transform: scaleX(-1);
89
+ }
90
+ @keyframes iconpark-spin {
91
+ 0% {
92
+ -webkit-transform: rotate(0);
93
+ transform: rotate(0);
94
+ }
95
+
96
+ 100% {
97
+ -webkit-transform: rotate(360deg);
98
+ transform: rotate(360deg);
99
+ }
100
+ }
101
+ @keyframes iconpark-spin-rtl {
102
+ 0% {
103
+ -webkit-transform: scaleX(-1) rotate(0);
104
+ transform: scaleX(-1) rotate(0);
105
+ }
106
+
107
+ 100% {
108
+ -webkit-transform: scaleX(-1) rotate(360deg);
109
+ transform: scaleX(-1) rotate(360deg);
110
+ }
111
+ }
112
+ </style>
@@ -0,0 +1,3 @@
1
+ .page-{{kebabCase name}} {
2
+
3
+ }
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <div class="page-wrap page-{{kebabCase name}}">{{bigCamelCase name}}页面</div>
3
+ </template>
4
+
5
+ <script>
6
+ import { reactive, toRefs } from 'vue';
7
+ export default {
8
+ // eslint-disable-next-line vue/multi-word-component-names
9
+ name: '{{bigCamelCase name}}',
10
+ setup() {
11
+ console.log('1-开始创建组件-setup');
12
+ const data = reactive({});
13
+ return {
14
+ ...toRefs(data)
15
+ };
16
+ }
17
+ };
18
+ </script>
19
+ <style scoped lang="less">
20
+ @import './{{kebabCase name}}.less';
21
+ </style>
@@ -0,0 +1,3 @@
1
+ .page-comp-{{kebabCase name}} {
2
+
3
+ }
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <div class="page-comp-{{kebabCase name}}">{{bigCamelCase name}}组件</div>
3
+ </template>
4
+
5
+ <script>
6
+ import { reactive, toRefs } from 'vue';
7
+ export default {
8
+ // eslint-disable-next-line vue/multi-word-component-names
9
+ name: '{{bigCamelCase name}}',
10
+ setup() {
11
+ console.log('1-开始创建组件-setup');
12
+ const data = reactive({});
13
+ return {
14
+ ...toRefs(data)
15
+ };
16
+ }
17
+ };
18
+ </script>
19
+ <style scoped lang="less">
20
+ @import './index.less';
21
+ </style>
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "qcf",
3
+ "version": "0.0.1",
4
+ "description": "quick create file(QCF) is a package for quickly creating templates for front-end projects",
5
+ "author": "xunzou",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "main": "./dist/index.js",
12
+ "peerDependencies": {
13
+ "plop": "^3.1.2"
14
+ },
15
+ "devDependencies": {
16
+ "plop": "^3.1.2"
17
+ },
18
+ "dependencies": {
19
+ "lodash.camelcase": "^4.3.0",
20
+ "lodash.kebabcase": "^4.1.1",
21
+ "lodash.upperfirst": "^4.3.1"
22
+ }
23
+ }
package/readme.md ADDED
@@ -0,0 +1,2 @@
1
+ # qcf
2
+ 一个快速创建vue3 模板的功能;