create-vue-workspace 0.1.0
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/LICENSE +21 -0
- package/README.md +173 -0
- package/dist/index.mjs +910 -0
- package/package.json +41 -0
- package/templates/app-web/_env.development +2 -0
- package/templates/app-web/_env.production +2 -0
- package/templates/app-web/index.html +12 -0
- package/templates/app-web/package.json +25 -0
- package/templates/app-web/src/App.vue +18 -0
- package/templates/app-web/src/api/request.ts +15 -0
- package/templates/app-web/src/main.ts +7 -0
- package/templates/app-web/src/router/index.ts +16 -0
- package/templates/app-web/src/stores/app.ts +7 -0
- package/templates/app-web/src/styles/index.scss +8 -0
- package/templates/app-web/src/views/home-view.vue +16 -0
- package/templates/app-web/src/vite-env.d.ts +12 -0
- package/templates/app-web/tsconfig.json +7 -0
- package/templates/app-web/vite.config.ts +17 -0
- package/templates/base/README.md +53 -0
- package/templates/base/_changeset/config.json +11 -0
- package/templates/base/_editorconfig +12 -0
- package/templates/base/_gitignore +12 -0
- package/templates/base/eslint.config.mjs +25 -0
- package/templates/base/package.json +38 -0
- package/templates/base/pnpm-workspace.yaml +3 -0
- package/templates/base/prettier.config.mjs +8 -0
- package/templates/base/stylelint.config.mjs +8 -0
- package/templates/base/tsconfig.base.json +17 -0
- package/templates/base/tsconfig.json +4 -0
- package/templates/base/vitest.config.ts +10 -0
- package/templates/component/__tests__/{{fileName}}.component.spec.tsx +17 -0
- package/templates/component/components/{{fileName}}-sub.component.tsx +9 -0
- package/templates/component/composition/use-{{fileName}}.ts +46 -0
- package/templates/component/index.ts +12 -0
- package/templates/component/package.json +31 -0
- package/templates/component/tsconfig.json +5 -0
- package/templates/component/types.ts +5 -0
- package/templates/component/vite.config.ts +17 -0
- package/templates/component/{{fileName}}.component.tsx +22 -0
- package/templates/component/{{fileName}}.props.ts +12 -0
- package/templates/component/{{fileName}}.scss +11 -0
- package/templates/hook/use-{{kebab}}.ts +26 -0
- package/templates/pkg-lib/package.json +24 -0
- package/templates/pkg-lib/src/index.ts +5 -0
- package/templates/pkg-lib/tsconfig.json +4 -0
- package/templates/pkg-lib/vite.config.ts +17 -0
- package/templates/pkg-ui/package.json +31 -0
- package/templates/pkg-ui/src/index.ts +7 -0
- package/templates/pkg-ui/src/styles/index.scss +6 -0
- package/templates/pkg-ui/tsconfig.json +4 -0
- package/templates/pkg-ui/vite.config.ts +17 -0
- package/templates/pkg-utils/package.json +24 -0
- package/templates/pkg-utils/src/index.ts +20 -0
- package/templates/pkg-utils/tsconfig.json +4 -0
- package/templates/pkg-utils/vite.config.ts +13 -0
- package/templates/util/{{kebab}}.ts +4 -0
- package/templates/view/{{fileName}}.vue +15 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { computed, ref, type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
export interface Use{{pascal}}Result {
|
|
4
|
+
/** 当前值 */
|
|
5
|
+
value: Ref<boolean>;
|
|
6
|
+
/** 取反后的值 */
|
|
7
|
+
negated: ComputedRef<boolean>;
|
|
8
|
+
/** 切换当前值 */
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* TODO: 替换为 use{{pascal}} 的真实实现。
|
|
14
|
+
* 约定:入参为配置对象,返回 Ref / ComputedRef 与操作函数,便于在组件间复用。
|
|
15
|
+
*/
|
|
16
|
+
export function use{{pascal}}(initialValue = false): Use{{pascal}}Result {
|
|
17
|
+
const value = ref(initialValue);
|
|
18
|
+
|
|
19
|
+
const negated = computed(() => !value.value);
|
|
20
|
+
|
|
21
|
+
function toggle(): void {
|
|
22
|
+
value.value = !value.value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { value, negated, toggle };
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "vite build",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.7.2",
|
|
21
|
+
"vite": "^6.0.7",
|
|
22
|
+
"vite-plugin-dts": "^4.4.0"{{vueDevDependency}}
|
|
23
|
+
}{{vuePeerDependencies}}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import dts from 'vite-plugin-dts';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [dts({ rollupTypes: true })],
|
|
6
|
+
build: {
|
|
7
|
+
lib: {
|
|
8
|
+
entry: 'src/index.ts',
|
|
9
|
+
formats: ['es'],
|
|
10
|
+
fileName: () => 'index.mjs',
|
|
11
|
+
},
|
|
12
|
+
rollupOptions: {
|
|
13
|
+
// vue 只可能被可选依赖,标记为外部依赖无副作用
|
|
14
|
+
external: ['vue'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{scope}}/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": ["**/*.css", "**/*.scss"],
|
|
6
|
+
"main": "./dist/index.mjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./style": "./dist/style.css"
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build",
|
|
19
|
+
"typecheck": "vue-tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"vue": "^3.5.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
26
|
+
"sass": "^1.83.0",
|
|
27
|
+
"vite": "^6.0.7",
|
|
28
|
+
"vite-plugin-dts": "^4.4.0",
|
|
29
|
+
"vue-tsc": "^2.2.0"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [vueJsx(), dts({ rollupTypes: true })],
|
|
7
|
+
build: {
|
|
8
|
+
lib: {
|
|
9
|
+
entry: 'src/index.ts',
|
|
10
|
+
formats: ['es'],
|
|
11
|
+
fileName: () => 'index.mjs',
|
|
12
|
+
},
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
external: ['vue'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{scope}}/utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "vite build",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.7.2",
|
|
21
|
+
"vite": "^6.0.7",
|
|
22
|
+
"vite-plugin-dts": "^4.4.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** 判断值是否为空(null / undefined / 空字符串) */
|
|
2
|
+
export function isEmpty(value: unknown): boolean {
|
|
3
|
+
return value === null || value === undefined || value === '';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** 数组去重(按自定义 key) */
|
|
7
|
+
export function uniqueBy<T>(items: T[], getKey: (item: T) => string | number): T[] {
|
|
8
|
+
const seen = new Set<string | number>();
|
|
9
|
+
|
|
10
|
+
return items.filter((item) => {
|
|
11
|
+
const key = getKey(item);
|
|
12
|
+
|
|
13
|
+
if (seen.has(key)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
seen.add(key);
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import dts from 'vite-plugin-dts';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [dts({ rollupTypes: true })],
|
|
6
|
+
build: {
|
|
7
|
+
lib: {
|
|
8
|
+
entry: 'src/index.ts',
|
|
9
|
+
formats: ['es'],
|
|
10
|
+
fileName: () => 'index.mjs',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|