@duxweb/dvha-template 1.0.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/README.md +71 -0
- package/bin/index.js +250 -0
- package/package.json +50 -0
- package/template/base/App.vue +13 -0
- package/template/base/README.md +154 -0
- package/template/base/index.html +13 -0
- package/template/base/main.ts +64 -0
- package/template/base/package.json +28 -0
- package/template/base/tsconfig.json +37 -0
- package/template/base/typings.d.ts +16 -0
- package/template/base/uno.config.ts +22 -0
- package/template/base/vite-env.d.ts +1 -0
- package/template/base/vite.config.ts +34 -0
- package/template/ui-configs/base/pages/404.vue +63 -0
- package/template/ui-configs/base/pages/home.vue +77 -0
- package/template/ui-configs/base/pages/layout.vue +79 -0
- package/template/ui-configs/base/pages/login.vue +161 -0
- package/template/ui-configs/base/pages/menu.vue +32 -0
- package/template/ui-configs/base.json +22 -0
- package/template/ui-configs/elementui/pages/404.vue +63 -0
- package/template/ui-configs/elementui/pages/home.vue +77 -0
- package/template/ui-configs/elementui/pages/layout.vue +79 -0
- package/template/ui-configs/elementui/pages/login.vue +123 -0
- package/template/ui-configs/elementui/pages/menu.vue +32 -0
- package/template/ui-configs/elementui.json +27 -0
- package/template/ui-configs/naiveui/pages/404.vue +63 -0
- package/template/ui-configs/naiveui/pages/home.vue +77 -0
- package/template/ui-configs/naiveui/pages/layout.vue +79 -0
- package/template/ui-configs/naiveui/pages/login.vue +146 -0
- package/template/ui-configs/naiveui/pages/menu.vue +32 -0
- package/template/ui-configs/naiveui.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# create-dvha
|
|
2
|
+
|
|
3
|
+
快速创建 Dux Vue 项目的脚手架工具。
|
|
4
|
+
|
|
5
|
+
## 使用方法
|
|
6
|
+
|
|
7
|
+
### 使用 bunx (推荐)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bunx dvha init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 使用 npx
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx dvha init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### 使用 yarn
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
yarn dvha init
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 使用 pnpm
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm dvha init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 可用模板
|
|
33
|
+
|
|
34
|
+
1. **Vue 3 + Vite + UnoCSS** - 基础的 Vue 3 项目模板
|
|
35
|
+
2. **Vue 3 + Element Plus** - 使用 Element Plus 的 Vue 3 项目
|
|
36
|
+
3. **Vue 3 + Naive UI** - 使用 Naive UI 的 Vue 3 项目
|
|
37
|
+
|
|
38
|
+
## 特性
|
|
39
|
+
|
|
40
|
+
- 🚀 快速创建项目
|
|
41
|
+
- 🎨 多种 UI 框架模板选择
|
|
42
|
+
- 📦 自动配置开发环境
|
|
43
|
+
- 🔧 开箱即用的开发工具
|
|
44
|
+
|
|
45
|
+
## 开发
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 安装依赖
|
|
49
|
+
bun install
|
|
50
|
+
|
|
51
|
+
# 本地测试
|
|
52
|
+
bun run bin/index.js test-project
|
|
53
|
+
|
|
54
|
+
# 或者使用 npm
|
|
55
|
+
npm install
|
|
56
|
+
node bin/index.js test-project
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 发布
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# 使用 bun 发布
|
|
63
|
+
bun run publish
|
|
64
|
+
|
|
65
|
+
# 或者直接使用 bun
|
|
66
|
+
bun pm publish
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 许可证
|
|
70
|
+
|
|
71
|
+
LGPL-3.0
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs-extra'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import { input, select, confirm } from '@inquirer/prompts'
|
|
7
|
+
import { cyan, green, red, yellow, blue, bold } from 'kolorist'
|
|
8
|
+
import { Command } from 'commander'
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
+
|
|
12
|
+
// 获取版本号
|
|
13
|
+
function getVersion() {
|
|
14
|
+
const packagePath = path.resolve(__dirname, '..', 'package.json')
|
|
15
|
+
if (fs.existsSync(packagePath)) {
|
|
16
|
+
const pkg = fs.readJsonSync(packagePath)
|
|
17
|
+
return pkg.version
|
|
18
|
+
}
|
|
19
|
+
return '1.0.0'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function createProject(projectName) {
|
|
23
|
+
console.log()
|
|
24
|
+
console.log(bold(cyan('欢迎使用 DVHA 项目创建工具! / Welcome to DVHA Project Creator!')))
|
|
25
|
+
console.log()
|
|
26
|
+
|
|
27
|
+
let targetDir = projectName
|
|
28
|
+
|
|
29
|
+
if (!targetDir) {
|
|
30
|
+
targetDir = await input({
|
|
31
|
+
message: '请输入项目名称 / Enter project name:',
|
|
32
|
+
default: 'my-dvha-app'
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!targetDir) {
|
|
37
|
+
console.log(red('✖ 项目名称不能为空 / Project name cannot be empty'))
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const root = path.resolve(targetDir)
|
|
42
|
+
|
|
43
|
+
if (fs.existsSync(root)) {
|
|
44
|
+
const overwrite = await confirm({
|
|
45
|
+
message: `目录 ${targetDir} 已存在,是否覆盖? / Directory ${targetDir} already exists, overwrite?`,
|
|
46
|
+
default: false
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
if (!overwrite) {
|
|
50
|
+
console.log(yellow('✖ 操作已取消 / Operation cancelled'))
|
|
51
|
+
process.exit(1)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fs.emptyDirSync(root)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 读取可用的UI配置
|
|
58
|
+
const uiConfigsDir = path.resolve(__dirname, '..', 'template', 'ui-configs')
|
|
59
|
+
const availableUIs = fs.readdirSync(uiConfigsDir)
|
|
60
|
+
.filter(dir => fs.statSync(path.join(uiConfigsDir, dir)).isDirectory())
|
|
61
|
+
.map(dir => {
|
|
62
|
+
const configPath = path.join(uiConfigsDir, dir + '.json')
|
|
63
|
+
if (fs.existsSync(configPath)) {
|
|
64
|
+
const config = fs.readJsonSync(configPath)
|
|
65
|
+
return {
|
|
66
|
+
name: config.name,
|
|
67
|
+
display: config.display,
|
|
68
|
+
description: config.description,
|
|
69
|
+
value: config.name
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null
|
|
73
|
+
})
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
|
|
76
|
+
const template = await select({
|
|
77
|
+
message: '请选择一个模板 / Please select a template:',
|
|
78
|
+
choices: availableUIs.map(ui => ({
|
|
79
|
+
name: `${ui.display} - ${ui.description}`,
|
|
80
|
+
value: ui.value,
|
|
81
|
+
description: ui.description
|
|
82
|
+
}))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
if (!template) {
|
|
86
|
+
console.log(red('✖ 请选择一个模板 / Please select a template'))
|
|
87
|
+
process.exit(1)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(yellow(`\n正在创建项目 / Creating project: ${targetDir}...`))
|
|
91
|
+
|
|
92
|
+
// 基础模板目录
|
|
93
|
+
const baseTemplateDir = path.resolve(__dirname, '..', 'template', 'base')
|
|
94
|
+
const uiConfigPath = path.resolve(__dirname, '..', 'template', 'ui-configs', `${template}.json`)
|
|
95
|
+
const uiPagesDir = path.resolve(__dirname, '..', 'template', 'ui-configs', template, 'pages')
|
|
96
|
+
|
|
97
|
+
if (!fs.existsSync(baseTemplateDir)) {
|
|
98
|
+
console.log(red(`✖ 基础模板不存在 / Base template does not exist`))
|
|
99
|
+
process.exit(1)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!fs.existsSync(uiConfigPath)) {
|
|
103
|
+
console.log(red(`✖ UI配置 ${template} 不存在 / UI config ${template} does not exist`))
|
|
104
|
+
process.exit(1)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 读取UI配置
|
|
108
|
+
const uiConfig = fs.readJsonSync(uiConfigPath)
|
|
109
|
+
|
|
110
|
+
// 创建目录
|
|
111
|
+
fs.ensureDirSync(root)
|
|
112
|
+
|
|
113
|
+
// 1. 复制基础模板文件
|
|
114
|
+
fs.copySync(baseTemplateDir, root, {
|
|
115
|
+
filter: (src) => {
|
|
116
|
+
const relativePath = path.relative(baseTemplateDir, src)
|
|
117
|
+
const fileName = path.basename(src)
|
|
118
|
+
|
|
119
|
+
// 过滤掉不需要的目录和文件
|
|
120
|
+
const shouldExclude =
|
|
121
|
+
relativePath.includes('node_modules') ||
|
|
122
|
+
relativePath.includes('.git') ||
|
|
123
|
+
relativePath.includes('dist') ||
|
|
124
|
+
relativePath.includes('.vite') ||
|
|
125
|
+
fileName === '.DS_Store' ||
|
|
126
|
+
fileName.endsWith('.log') ||
|
|
127
|
+
fileName === 'bun.lockb' ||
|
|
128
|
+
fileName === 'package-lock.json' ||
|
|
129
|
+
fileName === 'yarn.lock'
|
|
130
|
+
|
|
131
|
+
return !shouldExclude
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
// 2. 复制UI特定的pages文件
|
|
136
|
+
if (fs.existsSync(uiPagesDir)) {
|
|
137
|
+
const targetPagesDir = path.join(root, 'pages')
|
|
138
|
+
fs.emptyDirSync(targetPagesDir)
|
|
139
|
+
fs.copySync(uiPagesDir, targetPagesDir)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 3. 更新package.json
|
|
143
|
+
const pkgPath = path.join(root, 'package.json')
|
|
144
|
+
if (fs.existsSync(pkgPath)) {
|
|
145
|
+
const pkg = fs.readJsonSync(pkgPath)
|
|
146
|
+
|
|
147
|
+
// 更新项目名称
|
|
148
|
+
pkg.name = path.basename(root)
|
|
149
|
+
|
|
150
|
+
// 更新依赖
|
|
151
|
+
pkg.dependencies = {
|
|
152
|
+
...pkg.dependencies,
|
|
153
|
+
...uiConfig.dependencies
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (uiConfig.devDependencies && Object.keys(uiConfig.devDependencies).length > 0) {
|
|
157
|
+
pkg.devDependencies = {
|
|
158
|
+
...pkg.devDependencies,
|
|
159
|
+
...uiConfig.devDependencies
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fs.writeJsonSync(pkgPath, pkg, { spaces: 2 })
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 4. 更新main.ts
|
|
167
|
+
const mainTsPath = path.join(root, 'main.ts')
|
|
168
|
+
if (fs.existsSync(mainTsPath)) {
|
|
169
|
+
let mainTsContent = fs.readFileSync(mainTsPath, 'utf-8')
|
|
170
|
+
|
|
171
|
+
// 在导入语句后添加UI库的导入
|
|
172
|
+
const importStatements = uiConfig.imports || []
|
|
173
|
+
const appUseStatements = uiConfig.appUse || []
|
|
174
|
+
|
|
175
|
+
// 找到现有导入的位置
|
|
176
|
+
const appImportIndex = mainTsContent.indexOf("import App from './App.vue'")
|
|
177
|
+
if (appImportIndex !== -1) {
|
|
178
|
+
const insertPosition = mainTsContent.indexOf('\n', appImportIndex) + 1
|
|
179
|
+
const additionalImports = importStatements.join('\n') + (importStatements.length > 0 ? '\n' : '')
|
|
180
|
+
mainTsContent = mainTsContent.slice(0, insertPosition) + additionalImports + mainTsContent.slice(insertPosition)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 在app.use(createDux(config))之前添加UI库的使用
|
|
184
|
+
if (appUseStatements.length > 0) {
|
|
185
|
+
const appUseIndex = mainTsContent.indexOf('app.use(createDux(config))')
|
|
186
|
+
if (appUseIndex !== -1) {
|
|
187
|
+
const additionalUse = appUseStatements.join('\n') + '\n'
|
|
188
|
+
mainTsContent = mainTsContent.slice(0, appUseIndex) + additionalUse + mainTsContent.slice(appUseIndex)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fs.writeFileSync(mainTsPath, mainTsContent)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
console.log(green('\n✓ 项目创建成功! / Project created successfully!'))
|
|
196
|
+
console.log()
|
|
197
|
+
console.log(bold('下一步 / Next steps:'))
|
|
198
|
+
console.log(cyan(` cd ${targetDir}`))
|
|
199
|
+
console.log(cyan(' bun install'))
|
|
200
|
+
console.log(cyan(' bun run dev'))
|
|
201
|
+
console.log()
|
|
202
|
+
console.log(bold('或者使用 npm / Or use npm:'))
|
|
203
|
+
console.log(cyan(` cd ${targetDir}`))
|
|
204
|
+
console.log(cyan(' npm install'))
|
|
205
|
+
console.log(cyan(' npm run dev'))
|
|
206
|
+
console.log()
|
|
207
|
+
console.log(green('🎉 开始你的 Dux Vue 之旅吧! / Start your Dux Vue journey!'))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 主程序
|
|
211
|
+
const program = new Command()
|
|
212
|
+
|
|
213
|
+
program
|
|
214
|
+
.name('dvha')
|
|
215
|
+
.description('DVHA 项目创建工具 / DVHA Project Creator')
|
|
216
|
+
.version(getVersion())
|
|
217
|
+
|
|
218
|
+
program
|
|
219
|
+
.command('init')
|
|
220
|
+
.description('创建新项目 / Create a new project')
|
|
221
|
+
.argument('[project-name]', '项目名称 / Project name')
|
|
222
|
+
.alias('create')
|
|
223
|
+
.action(async (projectName) => {
|
|
224
|
+
try {
|
|
225
|
+
await createProject(projectName)
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (error.name === 'ExitPromptError') {
|
|
228
|
+
console.log(yellow('\n👋 操作已取消 / Operation cancelled'))
|
|
229
|
+
process.exit(0)
|
|
230
|
+
}
|
|
231
|
+
console.error(red('创建项目时出错 / Error creating project:'), error)
|
|
232
|
+
process.exit(1)
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
// 添加默认行为 - 当没有命令时显示友好提示
|
|
237
|
+
program
|
|
238
|
+
.action(() => {
|
|
239
|
+
console.log()
|
|
240
|
+
console.log(bold(cyan('👋 欢迎使用 DVHA 项目创建工具! / Welcome to DVHA Project Creator!')))
|
|
241
|
+
console.log()
|
|
242
|
+
console.log('使用以下命令开始创建项目 / Use the following command to start creating a project:')
|
|
243
|
+
console.log()
|
|
244
|
+
console.log(green(' dvha init [project-name]'))
|
|
245
|
+
console.log()
|
|
246
|
+
console.log('更多信息请使用 / For more information, use:', cyan('dvha --help'))
|
|
247
|
+
console.log()
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
program.parse()
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@duxweb/dvha-template",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create DVHA project from template",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"dvha": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"template",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "./scripts/test.sh",
|
|
16
|
+
"publish": "./scripts/publish.sh",
|
|
17
|
+
"dev": "bun run bin/index.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"vue",
|
|
21
|
+
"template",
|
|
22
|
+
"scaffold",
|
|
23
|
+
"dux",
|
|
24
|
+
"cli",
|
|
25
|
+
"create",
|
|
26
|
+
"vite",
|
|
27
|
+
"vue3",
|
|
28
|
+
"bun"
|
|
29
|
+
],
|
|
30
|
+
"author": "DuxWeb",
|
|
31
|
+
"license": "LGPL-3.0",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"fs-extra": "^11.2.0",
|
|
34
|
+
"@inquirer/prompts": "^7.5.1",
|
|
35
|
+
"kolorist": "^1.8.0",
|
|
36
|
+
"commander": "^14.0.0"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20.0.0"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/your-username/dux-vue.git",
|
|
44
|
+
"directory": "packages/create-dux-vue"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/your-username/dux-vue/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/your-username/dux-vue#readme"
|
|
50
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Dux Template - 基础管理系统模板
|
|
2
|
+
|
|
3
|
+
这是一个基于 `@duxweb/dvha-core` 框架构建的基础管理系统模板,使用 Vue 3 + UnoCSS 提供简洁现代的界面设计。
|
|
4
|
+
|
|
5
|
+
## ✨ 特性
|
|
6
|
+
|
|
7
|
+
- 🎨 **纯 UnoCSS** - 原子化 CSS 框架,无额外 UI 库依赖
|
|
8
|
+
- 🚀 **Vue 3** - 基于最新的 Vue 3 Composition API
|
|
9
|
+
- 📱 **响应式设计** - 完美适配桌面端和移动端
|
|
10
|
+
- 🔧 **@duxweb/dvha-core** - 集成 Dux 框架的完整功能
|
|
11
|
+
- 🎯 **开箱即用** - 包含常用页面和组件
|
|
12
|
+
- 🔒 **权限管理** - 内置登录和权限控制
|
|
13
|
+
- 📦 **模块化** - 易于扩展和定制
|
|
14
|
+
|
|
15
|
+
## 📁 项目结构
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
packages/template/
|
|
19
|
+
├── pages/ # 页面组件
|
|
20
|
+
│ ├── layout.vue # 主布局(侧边栏+头部)
|
|
21
|
+
│ ├── home.vue # 首页
|
|
22
|
+
│ ├── login.vue # 登录页
|
|
23
|
+
│ └── 404.vue # 404错误页
|
|
24
|
+
├── main.ts # 应用入口
|
|
25
|
+
├── App.vue # 根组件
|
|
26
|
+
├── uno.config.ts # UnoCSS 配置
|
|
27
|
+
└── package.json # 依赖配置
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 🚀 快速开始
|
|
31
|
+
|
|
32
|
+
### 1. 安装依赖
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. 启动开发服务器
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 3. 构建生产版本
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm run build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 📄 页面说明
|
|
51
|
+
|
|
52
|
+
### 🏠 首页 (home.vue)
|
|
53
|
+
- 系统概览和统计数据
|
|
54
|
+
- 快速操作入口
|
|
55
|
+
- 最近活动记录
|
|
56
|
+
- 系统状态监控
|
|
57
|
+
|
|
58
|
+
### 🔐 登录页 (login.vue)
|
|
59
|
+
- 用户身份验证
|
|
60
|
+
- 表单验证和错误提示
|
|
61
|
+
- 记住登录状态
|
|
62
|
+
- 第三方登录支持
|
|
63
|
+
|
|
64
|
+
### 🎯 布局 (layout.vue)
|
|
65
|
+
- 固定头部导航
|
|
66
|
+
- 可折叠侧边栏
|
|
67
|
+
- 移动端适配
|
|
68
|
+
- 用户菜单和通知
|
|
69
|
+
|
|
70
|
+
### ❌ 404页面 (404.vue)
|
|
71
|
+
- 友好的错误提示
|
|
72
|
+
- 搜索功能
|
|
73
|
+
- 快速导航链接
|
|
74
|
+
|
|
75
|
+
## 🎨 样式系统
|
|
76
|
+
|
|
77
|
+
本模板使用 UnoCSS 原子化 CSS 框架,主要包含:
|
|
78
|
+
|
|
79
|
+
- **颜色系统**: 基于 Tailwind 的颜色调色板
|
|
80
|
+
- **图标库**: Tabler Icons (@iconify-json/tabler)
|
|
81
|
+
- **响应式**: 移动优先的响应式设计
|
|
82
|
+
- **动画**: 平滑的过渡和交互效果
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## 🔧 配置说明
|
|
86
|
+
|
|
87
|
+
### Dux 配置 (main.ts)
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const config: IConfig = {
|
|
91
|
+
apiUrl: 'your-api-url',
|
|
92
|
+
defaultManage: 'admin',
|
|
93
|
+
manages: [
|
|
94
|
+
{
|
|
95
|
+
name: 'admin',
|
|
96
|
+
title: '管理系统标题',
|
|
97
|
+
routePrefix: '/admin',
|
|
98
|
+
components: {
|
|
99
|
+
authLayout: () => import('./pages/layout.vue'),
|
|
100
|
+
notFound: () => import('./pages/404.vue'),
|
|
101
|
+
},
|
|
102
|
+
menus: [
|
|
103
|
+
// 菜单配置
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
simpleDataProvider,
|
|
108
|
+
simpleAuthProvider,
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### UnoCSS 配置 (uno.config.ts)
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
export default defineConfig({
|
|
116
|
+
presets: [
|
|
117
|
+
presetWind3(), // Tailwind CSS 兼容
|
|
118
|
+
presetIcons({ // 图标支持
|
|
119
|
+
collections: {
|
|
120
|
+
tabler: () => import('@iconify-json/tabler/icons.json')
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 🛠 自定义和扩展
|
|
128
|
+
|
|
129
|
+
### 添加新页面
|
|
130
|
+
|
|
131
|
+
1. 在 `pages/` 目录创建新的 Vue 组件
|
|
132
|
+
2. 在 `main.ts` 中添加路由配置
|
|
133
|
+
3. 在菜单配置中添加导航项
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// 添加新菜单项
|
|
137
|
+
menus: [
|
|
138
|
+
{
|
|
139
|
+
name: 'new-page',
|
|
140
|
+
path: 'new-page',
|
|
141
|
+
icon: 'i-tabler:page',
|
|
142
|
+
label: '新页面',
|
|
143
|
+
component: () => import('./pages/new-page.vue'),
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 📄 许可证
|
|
149
|
+
|
|
150
|
+
MIT License
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
**提示**: 这是一个基础模板,你可以根据实际需求进行定制和扩展。如果需要更多功能,请参考 @duxweb/dvha-core 的官方文档。
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Dux Vue Example</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app" v-cloak un-cloak></div>
|
|
11
|
+
<script type="module" src="/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { IConfig } from '@duxweb/dvha-core'
|
|
2
|
+
import { createDux, simpleDataProvider, simpleAuthProvider } from '@duxweb/dvha-core'
|
|
3
|
+
import { createApp } from 'vue'
|
|
4
|
+
import App from './App.vue'
|
|
5
|
+
|
|
6
|
+
import '@unocss/reset/tailwind.css'
|
|
7
|
+
import 'virtual:uno.css'
|
|
8
|
+
|
|
9
|
+
const app = createApp(App)
|
|
10
|
+
|
|
11
|
+
const config: IConfig = {
|
|
12
|
+
apiUrl: 'https://m1.apifoxmock.com/m1/4407506-4052338-default',
|
|
13
|
+
defaultManage: 'admin',
|
|
14
|
+
manages: [
|
|
15
|
+
{
|
|
16
|
+
name: 'admin',
|
|
17
|
+
title: 'DVHA 后台管理系统',
|
|
18
|
+
routePrefix: '/admin',
|
|
19
|
+
apiUrl: '/admin',
|
|
20
|
+
components: {
|
|
21
|
+
authLayout: () => import('./pages/layout.vue'),
|
|
22
|
+
notFound: () => import('./pages/404.vue'),
|
|
23
|
+
},
|
|
24
|
+
routes: [
|
|
25
|
+
{
|
|
26
|
+
name: 'admin.login',
|
|
27
|
+
path: 'login',
|
|
28
|
+
component: () => import('./pages/login.vue'),
|
|
29
|
+
meta: {
|
|
30
|
+
authorization: false,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
menus: [
|
|
35
|
+
{
|
|
36
|
+
name: 'home',
|
|
37
|
+
path: 'index',
|
|
38
|
+
icon: 'i-tabler:home',
|
|
39
|
+
label: '首页',
|
|
40
|
+
component: () => import('./pages/home.vue'),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'users',
|
|
44
|
+
path: 'users',
|
|
45
|
+
icon: 'i-tabler:users',
|
|
46
|
+
label: '用户管理',
|
|
47
|
+
component: () => import('./pages/home.vue'),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'settings',
|
|
51
|
+
path: 'settings',
|
|
52
|
+
icon: 'i-tabler:settings',
|
|
53
|
+
label: '系统设置',
|
|
54
|
+
component: () => import('./pages/home.vue'),
|
|
55
|
+
},
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
dataProvider: simpleDataProvider,
|
|
60
|
+
authProvider: simpleAuthProvider,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
app.use(createDux(config))
|
|
64
|
+
app.mount('#app')
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"author": "DuxWeb",
|
|
6
|
+
"license": "LGPL-3.0",
|
|
7
|
+
"files": [
|
|
8
|
+
"README.md",
|
|
9
|
+
"dist",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite dev",
|
|
14
|
+
"build": "vite build",
|
|
15
|
+
"preview": "vite preview"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@duxweb/dvha-core": "workspace:*",
|
|
19
|
+
"@iconify-json/tabler": "^1.2.18",
|
|
20
|
+
"@unocss/preset-icons": "^66.1.2",
|
|
21
|
+
"@vueuse/core": "^13.2.0",
|
|
22
|
+
"@vueuse/integrations": "^13.2.0",
|
|
23
|
+
"axios": "^1.9.0",
|
|
24
|
+
"lodash-es": "^4.17.21",
|
|
25
|
+
"unocss": "^66.1.2",
|
|
26
|
+
"@unocss/reset": "^66.1.2"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"jsxImportSource": "vue",
|
|
6
|
+
"lib": ["ESNext", "DOM"],
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"useDefineForClassFields": true,
|
|
9
|
+
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"module": "ESNext",
|
|
12
|
+
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
|
|
19
|
+
"noImplicitAny": false,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"declaration": true,
|
|
23
|
+
"noEmit": false,
|
|
24
|
+
"outDir": "./dist",
|
|
25
|
+
"allowSyntheticDefaultImports": true,
|
|
26
|
+
"esModuleInterop": true,
|
|
27
|
+
"isolatedModules": true,
|
|
28
|
+
"skipLibCheck": true
|
|
29
|
+
},
|
|
30
|
+
"include": [
|
|
31
|
+
"**/*.ts",
|
|
32
|
+
"**/*.tsx",
|
|
33
|
+
"**/*.vue",
|
|
34
|
+
"**/*.d.ts"
|
|
35
|
+
],
|
|
36
|
+
"exclude": ["node_modules", "dist"]
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// typings.d.ts
|
|
2
|
+
declare module '*.css' {
|
|
3
|
+
const content: string
|
|
4
|
+
export default content
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module '*?raw' {
|
|
8
|
+
const content: string
|
|
9
|
+
export default content
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module '*.vue' {
|
|
13
|
+
import { DefineComponent } from 'vue'
|
|
14
|
+
const component: DefineComponent<{}, {}, any>
|
|
15
|
+
export default component
|
|
16
|
+
}
|