@yuer678/create-kb 0.3.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/dist/index.js +196 -0
- package/package.json +48 -0
- package/templates/ai/.env.example +7 -0
- package/templates/ai/README.md +39 -0
- package/templates/ai/package.json +42 -0
- package/templates/ai/public/index.html +117 -0
- package/templates/ai/src/app.ts +22 -0
- package/templates/ai/src/config.ts +13 -0
- package/templates/ai/src/index.ts +6 -0
- package/templates/ai/src/lib/llm.ts +24 -0
- package/templates/ai/src/routes/chat.ts +72 -0
- package/templates/ai/test/chat.spec.ts +27 -0
- package/templates/ai/tsconfig.json +13 -0
- package/templates/ai/vitest.config.ts +8 -0
- package/templates/api/README.md +50 -0
- package/templates/api/package.json +42 -0
- package/templates/api/src/app.ts +84 -0
- package/templates/api/src/data/options.ts +17 -0
- package/templates/api/src/data/regions.ts +71 -0
- package/templates/api/src/data/users.ts +76 -0
- package/templates/api/src/index.ts +9 -0
- package/templates/api/src/middleware/error.ts +28 -0
- package/templates/api/src/middleware/validate.ts +22 -0
- package/templates/api/src/query.ts +106 -0
- package/templates/api/src/routes/health.ts +21 -0
- package/templates/api/src/routes/options.ts +19 -0
- package/templates/api/src/routes/regions.ts +31 -0
- package/templates/api/src/routes/users.ts +57 -0
- package/templates/api/src/server.ts +31 -0
- package/templates/api/src/types.ts +8 -0
- package/templates/api/test/app.spec.ts +216 -0
- package/templates/api/tsconfig.json +13 -0
- package/templates/api/vitest.config.ts +8 -0
- package/templates/base/README.md +25 -0
- package/templates/base/index.html +12 -0
- package/templates/base/package.json +32 -0
- package/templates/base/src/App.vue +46 -0
- package/templates/base/src/main.ts +6 -0
- package/templates/base/tsconfig.json +18 -0
- package/templates/base/vite.config.ts +6 -0
- package/templates/electron/README.md +32 -0
- package/templates/electron/package.json +54 -0
- package/templates/electron/src/main/index.ts +36 -0
- package/templates/electron/src/preload/index.ts +10 -0
- package/templates/electron/src/renderer/index.html +22 -0
- package/templates/electron/src/renderer/renderer.ts +14 -0
- package/templates/electron/tsconfig.json +13 -0
- package/templates/fullstack/Dockerfile +16 -0
- package/templates/fullstack/README.md +37 -0
- package/templates/fullstack/docker-compose.yml +26 -0
- package/templates/fullstack/package.json +30 -0
- package/templates/fullstack/pnpm-workspace.yaml +3 -0
- package/templates/fullstack/server/package.json +41 -0
- package/templates/fullstack/server/src/app.ts +84 -0
- package/templates/fullstack/server/src/data/options.ts +17 -0
- package/templates/fullstack/server/src/data/regions.ts +71 -0
- package/templates/fullstack/server/src/data/users.ts +76 -0
- package/templates/fullstack/server/src/index.ts +9 -0
- package/templates/fullstack/server/src/middleware/error.ts +28 -0
- package/templates/fullstack/server/src/middleware/validate.ts +22 -0
- package/templates/fullstack/server/src/query.ts +106 -0
- package/templates/fullstack/server/src/routes/health.ts +21 -0
- package/templates/fullstack/server/src/routes/options.ts +19 -0
- package/templates/fullstack/server/src/routes/regions.ts +31 -0
- package/templates/fullstack/server/src/routes/users.ts +57 -0
- package/templates/fullstack/server/src/server.ts +31 -0
- package/templates/fullstack/server/src/types.ts +8 -0
- package/templates/fullstack/server/test/app.spec.ts +216 -0
- package/templates/fullstack/server/tsconfig.json +13 -0
- package/templates/fullstack/server/vitest.config.ts +8 -0
- package/templates/fullstack/web/index.html +12 -0
- package/templates/fullstack/web/package.json +30 -0
- package/templates/fullstack/web/src/App.vue +108 -0
- package/templates/fullstack/web/src/main.ts +4 -0
- package/templates/fullstack/web/tsconfig.json +13 -0
- package/templates/fullstack/web/vite.config.ts +16 -0
- package/templates/react/README.md +8 -0
- package/templates/react/index.html +12 -0
- package/templates/react/package.json +34 -0
- package/templates/react/src/App.css +32 -0
- package/templates/react/src/App.tsx +16 -0
- package/templates/react/src/main.tsx +9 -0
- package/templates/react/tsconfig.json +20 -0
- package/templates/react/vite.config.ts +9 -0
- package/templates/starter/README.md +28 -0
- package/templates/starter/index.html +12 -0
- package/templates/starter/package.json +32 -0
- package/templates/starter/src/App.vue +125 -0
- package/templates/starter/src/main.ts +6 -0
- package/templates/starter/tsconfig.json +18 -0
- package/templates/starter/vite.config.ts +6 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { message } from 'kb-ui-vue'
|
|
4
|
+
|
|
5
|
+
const dark = ref(false)
|
|
6
|
+
|
|
7
|
+
function toggleTheme() {
|
|
8
|
+
dark.value = !dark.value
|
|
9
|
+
document.documentElement.dataset.theme = dark.value ? 'dark' : 'light'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 表单示例
|
|
13
|
+
const inputValue = ref('')
|
|
14
|
+
const checked = ref(true)
|
|
15
|
+
const radioValue = ref('a')
|
|
16
|
+
const selectValue = ref('')
|
|
17
|
+
const selectOptions = [
|
|
18
|
+
{ label: '苹果', value: 'apple' },
|
|
19
|
+
{ label: '香蕉', value: 'banana' },
|
|
20
|
+
{ label: '橙子', value: 'orange' },
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
// 表格
|
|
24
|
+
const tableData = [
|
|
25
|
+
{ name: '张三', age: 18, city: '北京' },
|
|
26
|
+
{ name: '李四', age: 20, city: '上海' },
|
|
27
|
+
{ name: '王五', age: 22, city: '广州' },
|
|
28
|
+
]
|
|
29
|
+
const tableColumns = [
|
|
30
|
+
{ prop: 'name', label: '姓名' },
|
|
31
|
+
{ prop: 'age', label: '年龄' },
|
|
32
|
+
{ prop: 'city', label: '城市' },
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
// 对话框
|
|
36
|
+
const dialogVisible = ref(false)
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<main class="page">
|
|
41
|
+
<h1>{{projectName}}</h1>
|
|
42
|
+
<p class="subtitle">@kb/ui 组件库完整示例</p>
|
|
43
|
+
|
|
44
|
+
<div class="actions">
|
|
45
|
+
<KbButton type="primary" @click="toggleTheme">切换主题</KbButton>
|
|
46
|
+
<KbButton type="success" @click="message.success('保存成功')">保存</KbButton>
|
|
47
|
+
<KbButton type="danger" plain @click="message.error('操作失败')">删除</KbButton>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<section class="block">
|
|
51
|
+
<h2>表单</h2>
|
|
52
|
+
<KbSpace vertical :size="12">
|
|
53
|
+
<KbInput v-model="inputValue" placeholder="请输入内容" clearable style="width: 280px" />
|
|
54
|
+
<KbSpace wrap>
|
|
55
|
+
<KbCheckbox v-model="checked" label="记住我" />
|
|
56
|
+
<KbRadio v-model="radioValue" value="a">选项 A</KbRadio>
|
|
57
|
+
<KbRadio v-model="radioValue" value="b">选项 B</KbRadio>
|
|
58
|
+
</KbSpace>
|
|
59
|
+
<KbSelect v-model="selectValue" :options="selectOptions" placeholder="请选择" style="width: 280px" />
|
|
60
|
+
</KbSpace>
|
|
61
|
+
<p class="hint">
|
|
62
|
+
输入:{{ inputValue || '(空)' }} · 选中:{{ selectValue || '(未选择)' }}
|
|
63
|
+
</p>
|
|
64
|
+
</section>
|
|
65
|
+
|
|
66
|
+
<section class="block">
|
|
67
|
+
<h2>表格</h2>
|
|
68
|
+
<KbTable :data="tableData" :columns="tableColumns" stripe border>
|
|
69
|
+
<template #cell="{ row, column }">
|
|
70
|
+
<KbTag v-if="column.prop === 'city'" type="primary">{{ row[column.prop] }}</KbTag>
|
|
71
|
+
<span v-else>{{ row[column.prop] }}</span>
|
|
72
|
+
</template>
|
|
73
|
+
</KbTable>
|
|
74
|
+
</section>
|
|
75
|
+
|
|
76
|
+
<section class="block">
|
|
77
|
+
<h2>对话框</h2>
|
|
78
|
+
<KbButton type="primary" plain @click="dialogVisible = true">打开对话框</KbButton>
|
|
79
|
+
<KbDialog v-model="dialogVisible" title="确认操作" width="420">
|
|
80
|
+
<p>这是一个对话框示例,footer 支持自定义。</p>
|
|
81
|
+
<template #footer>
|
|
82
|
+
<KbButton @click="dialogVisible = false">取消</KbButton>
|
|
83
|
+
<KbButton type="primary" @click="dialogVisible = false; message.success('已确认')">
|
|
84
|
+
确定
|
|
85
|
+
</KbButton>
|
|
86
|
+
</template>
|
|
87
|
+
</KbDialog>
|
|
88
|
+
</section>
|
|
89
|
+
</main>
|
|
90
|
+
</template>
|
|
91
|
+
|
|
92
|
+
<style scoped>
|
|
93
|
+
.page {
|
|
94
|
+
max-width: 720px;
|
|
95
|
+
margin: 0 auto;
|
|
96
|
+
padding: 40px 24px 80px;
|
|
97
|
+
font-family: var(--kb-font-family);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.subtitle {
|
|
101
|
+
color: var(--kb-color-text-3);
|
|
102
|
+
font-size: var(--kb-font-size-sm);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.actions {
|
|
106
|
+
display: flex;
|
|
107
|
+
gap: var(--kb-space-2);
|
|
108
|
+
margin: 24px 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.block {
|
|
112
|
+
margin-top: 32px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.block h2 {
|
|
116
|
+
font-size: var(--kb-font-size-lg);
|
|
117
|
+
color: var(--kb-color-text-1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.hint {
|
|
121
|
+
margin-top: 8px;
|
|
122
|
+
color: var(--kb-color-text-3);
|
|
123
|
+
font-size: var(--kb-font-size-sm);
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"noUnusedParameters": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"types": ["vite/client"]
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*.ts", "src/**/*.vue", "vite.config.ts"]
|
|
18
|
+
}
|