@lvetechs/create-app 1.0.4 → 1.0.5

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.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/templates/react/.env +3 -3
  3. package/templates/react/.env.development +3 -3
  4. package/templates/react/.env.production +3 -3
  5. package/templates/react/package.json +1 -1
  6. package/templates/react/pnpm-lock.yaml +5 -5
  7. package/templates/react/src/hooks/useForm.ts +77 -0
  8. package/templates/react/src/layouts/menuConfig.ts +3 -33
  9. package/templates/react/src/router/index.tsx +0 -39
  10. package/templates/react/src/stores/app.ts +141 -3
  11. package/templates/react/src/stores/notification.ts +128 -0
  12. package/templates/react/src/stores/permission.ts +183 -0
  13. package/templates/react/src/stores/user.ts +151 -4
  14. package/templates/react/src/views/home/index.tsx +167 -6
  15. package/templates/react/src/views/system/user/index.tsx +171 -5
  16. package/templates/vue/.env +2 -2
  17. package/templates/vue/.env.development +2 -2
  18. package/templates/vue/.env.production +2 -2
  19. package/templates/vue/pnpm-lock.yaml +3307 -3307
  20. package/templates/vue/src/auto-imports.d.ts +5 -0
  21. package/templates/vue/src/layouts/menuConfig.ts +3 -33
  22. package/templates/vue/src/router/index.ts +3 -88
  23. package/templates/vue/src/stores/app.ts +133 -2
  24. package/templates/vue/src/stores/notification.ts +172 -0
  25. package/templates/vue/src/stores/permission.ts +184 -0
  26. package/templates/vue/src/stores/user.ts +109 -2
  27. package/templates/vue/src/views/home/index.vue +7 -7
  28. package/templates/react/src/views/about/index.tsx +0 -40
  29. package/templates/react/src/views/login/index.tsx +0 -138
  30. package/templates/react/src/views/register/index.tsx +0 -143
  31. package/templates/react/src/views/result/fail.tsx +0 -39
  32. package/templates/react/src/views/result/success.tsx +0 -35
  33. package/templates/react/src/views/screen/index.tsx +0 -120
  34. package/templates/react/src/views/system/log/login.tsx +0 -51
  35. package/templates/react/src/views/system/log/operation.tsx +0 -47
  36. package/templates/react/src/views/system/menu/index.tsx +0 -62
  37. package/templates/react/src/views/system/role/index.tsx +0 -63
  38. package/templates/vue/src/views/about/index.vue +0 -67
  39. package/templates/vue/src/views/login/index.vue +0 -153
  40. package/templates/vue/src/views/register/index.vue +0 -169
  41. package/templates/vue/src/views/result/fail.vue +0 -92
  42. package/templates/vue/src/views/result/success.vue +0 -92
  43. package/templates/vue/src/views/screen/index.vue +0 -150
  44. package/templates/vue/src/views/system/log/login.vue +0 -51
  45. package/templates/vue/src/views/system/log/operation.vue +0 -47
  46. package/templates/vue/src/views/system/menu/index.vue +0 -58
  47. package/templates/vue/src/views/system/role/index.vue +0 -59
@@ -1,39 +0,0 @@
1
- import { useNavigate } from 'react-router-dom'
2
- import '@/styles/page-common.scss'
3
-
4
- export default function ResultFail() {
5
- const navigate = useNavigate()
6
-
7
- return (
8
- <div
9
- style={{
10
- height: '100vh',
11
- display: 'flex',
12
- alignItems: 'center',
13
- justifyContent: 'center',
14
- backgroundColor: '#f5f7fa'
15
- }}
16
- >
17
- <div className="page-card" style={{ textAlign: 'center', padding: '60px 80px' }}>
18
- <div style={{ fontSize: 64, marginBottom: 20 }}>❌</div>
19
- <h1 style={{ fontSize: 24, marginBottom: 12 }}>操作失败</h1>
20
- <p style={{ fontSize: 15, color: '#909399', marginBottom: 32 }}>
21
- 抱歉,您的操作未能完成,请检查后重试。
22
- </p>
23
- <div style={{ display: 'flex', gap: 12, justifyContent: 'center' }}>
24
- <button
25
- className="btn-primary"
26
- style={{ backgroundColor: '#f56c6c' }}
27
- onClick={() => navigate(-1)}
28
- >
29
- 返回重试
30
- </button>
31
- <button className="btn-outline" onClick={() => navigate('/')}>
32
- 返回首页
33
- </button>
34
- </div>
35
- </div>
36
- </div>
37
- )
38
- }
39
-
@@ -1,35 +0,0 @@
1
- import { useNavigate } from 'react-router-dom'
2
- import '@/styles/page-common.scss'
3
-
4
- export default function ResultSuccess() {
5
- const navigate = useNavigate()
6
-
7
- return (
8
- <div
9
- style={{
10
- height: '100vh',
11
- display: 'flex',
12
- alignItems: 'center',
13
- justifyContent: 'center',
14
- backgroundColor: '#f5f7fa'
15
- }}
16
- >
17
- <div className="page-card" style={{ textAlign: 'center', padding: '60px 80px' }}>
18
- <div style={{ fontSize: 64, marginBottom: 20 }}>✅</div>
19
- <h1 style={{ fontSize: 24, marginBottom: 12 }}>操作成功</h1>
20
- <p style={{ fontSize: 15, color: '#909399', marginBottom: 32 }}>
21
- 您的操作已成功完成,可以返回首页继续操作。
22
- </p>
23
- <div style={{ display: 'flex', gap: 12, justifyContent: 'center' }}>
24
- <button className="btn-primary" onClick={() => navigate('/')}>
25
- 返回首页
26
- </button>
27
- <button className="btn-outline" onClick={() => navigate(-1)}>
28
- 返回上一页
29
- </button>
30
- </div>
31
- </div>
32
- </div>
33
- )
34
- }
35
-
@@ -1,120 +0,0 @@
1
- import { useNavigate } from 'react-router-dom'
2
-
3
- export default function DataScreen() {
4
- const navigate = useNavigate()
5
-
6
- const panels = [
7
- { title: '总用户数', value: '12,580', desc: '较昨日 +128' },
8
- { title: '今日活跃', value: '3,426', desc: '活跃率 27.2%' },
9
- { title: '今日订单', value: '856', desc: '较昨日 +52' },
10
- { title: '今日营收', value: '¥98,320', desc: '较昨日 +12.3%' }
11
- ]
12
-
13
- return (
14
- <div className="screen-page">
15
- {/* 顶部标题栏 */}
16
- <header className="screen-header">
17
- <button className="back-btn" onClick={() => navigate('/')}>
18
- ← 返回
19
- </button>
20
- <h1>数据大屏</h1>
21
- <span className="screen-time">{new Date().toLocaleString()}</span>
22
- </header>
23
-
24
- {/* 数据面板 */}
25
- <div className="screen-body">
26
- {panels.map((p) => (
27
- <div className="panel" key={p.title}>
28
- <h3>{p.title}</h3>
29
- <div className="panel-value">{p.value}</div>
30
- <p className="panel-desc">{p.desc}</p>
31
- </div>
32
- ))}
33
- <div className="panel wide">
34
- <h3>📊 数据图表区域</h3>
35
- <div className="chart-placeholder">
36
- <p>此处可集成 ECharts / Recharts 等图表库</p>
37
- </div>
38
- </div>
39
- <div className="panel wide">
40
- <h3>🗺️ 地图区域</h3>
41
- <div className="chart-placeholder">
42
- <p>此处可集成地图或其他可视化组件</p>
43
- </div>
44
- </div>
45
- </div>
46
-
47
- <style>{`
48
- .screen-page {
49
- height: 100vh;
50
- background: #0d1b2a;
51
- color: #e0e6ed;
52
- display: flex;
53
- flex-direction: column;
54
- overflow: hidden;
55
- }
56
- .screen-header {
57
- display: flex;
58
- align-items: center;
59
- justify-content: space-between;
60
- padding: 12px 24px;
61
- background: rgba(255,255,255,0.05);
62
- border-bottom: 1px solid rgba(255,255,255,0.1);
63
- }
64
- .screen-header h1 {
65
- font-size: 22px;
66
- background: linear-gradient(90deg, #00d2ff, #928dff);
67
- -webkit-background-clip: text;
68
- -webkit-text-fill-color: transparent;
69
- }
70
- .screen-time { font-size: 13px; color: #8892a4; }
71
- .back-btn {
72
- background: rgba(255,255,255,0.1);
73
- border: 1px solid rgba(255,255,255,0.2);
74
- color: #e0e6ed;
75
- padding: 6px 16px;
76
- border-radius: 4px;
77
- cursor: pointer;
78
- font-size: 13px;
79
- }
80
- .back-btn:hover { background: rgba(255,255,255,0.2); }
81
- .screen-body {
82
- flex: 1;
83
- display: grid;
84
- grid-template-columns: repeat(4, 1fr);
85
- gap: 16px;
86
- padding: 20px 24px;
87
- overflow-y: auto;
88
- }
89
- .panel {
90
- background: rgba(255,255,255,0.05);
91
- border: 1px solid rgba(255,255,255,0.08);
92
- border-radius: 8px;
93
- padding: 20px;
94
- }
95
- .panel h3 { font-size: 14px; color: #8892a4; margin-bottom: 12px; }
96
- .panel.wide { grid-column: span 2; }
97
- .panel-value {
98
- font-size: 32px;
99
- font-weight: 700;
100
- background: linear-gradient(90deg, #00d2ff, #928dff);
101
- -webkit-background-clip: text;
102
- -webkit-text-fill-color: transparent;
103
- margin-bottom: 8px;
104
- }
105
- .panel-desc { font-size: 13px; color: #67c23a; }
106
- .chart-placeholder {
107
- height: 200px;
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- border: 1px dashed rgba(255,255,255,0.15);
112
- border-radius: 6px;
113
- color: #8892a4;
114
- font-size: 14px;
115
- }
116
- `}</style>
117
- </div>
118
- )
119
- }
120
-
@@ -1,51 +0,0 @@
1
- import '@/styles/page-common.scss'
2
-
3
- const logs = [
4
- { id: 1, user: 'admin', ip: '192.168.1.1', location: '本地', browser: 'Chrome 122', os: 'Windows 10', time: '2024-03-20 09:00:00', status: '成功' },
5
- { id: 2, user: 'editor', ip: '192.168.1.2', location: '本地', browser: 'Firefox 123', os: 'macOS', time: '2024-03-20 09:30:00', status: '成功' },
6
- { id: 3, user: 'hacker', ip: '10.0.0.1', location: '未知', browser: 'Unknown', os: 'Linux', time: '2024-03-20 12:00:00', status: '失败' }
7
- ]
8
-
9
- export default function LoginLog() {
10
- return (
11
- <div className="page-container">
12
- <div className="page-header">
13
- <h2>登录日志</h2>
14
- <button className="btn-primary">导出日志</button>
15
- </div>
16
- <table className="data-table">
17
- <thead>
18
- <tr>
19
- <th>ID</th>
20
- <th>用户名</th>
21
- <th>IP 地址</th>
22
- <th>登录地点</th>
23
- <th>浏览器</th>
24
- <th>操作系统</th>
25
- <th>登录时间</th>
26
- <th>状态</th>
27
- </tr>
28
- </thead>
29
- <tbody>
30
- {logs.map((log) => (
31
- <tr key={log.id}>
32
- <td>{log.id}</td>
33
- <td>{log.user}</td>
34
- <td>{log.ip}</td>
35
- <td>{log.location}</td>
36
- <td>{log.browser}</td>
37
- <td>{log.os}</td>
38
- <td>{log.time}</td>
39
- <td>
40
- <span className={log.status === '成功' ? 'status-active' : 'status-disabled'}>
41
- {log.status}
42
- </span>
43
- </td>
44
- </tr>
45
- ))}
46
- </tbody>
47
- </table>
48
- </div>
49
- )
50
- }
51
-
@@ -1,47 +0,0 @@
1
- import '@/styles/page-common.scss'
2
-
3
- const logs = [
4
- { id: 1, user: 'admin', action: '新增用户', ip: '192.168.1.1', time: '2024-03-20 10:30:00', status: '成功' },
5
- { id: 2, user: 'admin', action: '修改角色', ip: '192.168.1.1', time: '2024-03-20 11:15:00', status: '成功' },
6
- { id: 3, user: 'editor', action: '删除文章', ip: '192.168.1.2', time: '2024-03-20 14:22:00', status: '失败' }
7
- ]
8
-
9
- export default function OperationLog() {
10
- return (
11
- <div className="page-container">
12
- <div className="page-header">
13
- <h2>操作日志</h2>
14
- <button className="btn-primary">导出日志</button>
15
- </div>
16
- <table className="data-table">
17
- <thead>
18
- <tr>
19
- <th>ID</th>
20
- <th>操作人</th>
21
- <th>操作内容</th>
22
- <th>IP 地址</th>
23
- <th>操作时间</th>
24
- <th>状态</th>
25
- </tr>
26
- </thead>
27
- <tbody>
28
- {logs.map((log) => (
29
- <tr key={log.id}>
30
- <td>{log.id}</td>
31
- <td>{log.user}</td>
32
- <td>{log.action}</td>
33
- <td>{log.ip}</td>
34
- <td>{log.time}</td>
35
- <td>
36
- <span className={log.status === '成功' ? 'status-active' : 'status-disabled'}>
37
- {log.status}
38
- </span>
39
- </td>
40
- </tr>
41
- ))}
42
- </tbody>
43
- </table>
44
- </div>
45
- )
46
- }
47
-
@@ -1,62 +0,0 @@
1
- import '@/styles/page-common.scss'
2
-
3
- const menus = [
4
- { id: 1, title: '首页', path: '/home', icon: '🏠', type: '菜单', sort: 1 },
5
- { id: 2, title: '系统管理', path: '/system', icon: '⚙️', type: '目录', sort: 2 },
6
- { id: 3, title: '用户管理', path: '/system/user', icon: '👤', type: '菜单', sort: 1 },
7
- { id: 4, title: '角色管理', path: '/system/role', icon: '🔑', type: '菜单', sort: 2 },
8
- { id: 5, title: '菜单管理', path: '/system/menu', icon: '📋', type: '菜单', sort: 3 }
9
- ]
10
-
11
- export default function SystemMenu() {
12
- return (
13
- <div className="page-container">
14
- <div className="page-header">
15
- <h2>菜单管理</h2>
16
- <button className="btn-primary">+ 新增菜单</button>
17
- </div>
18
- <table className="data-table">
19
- <thead>
20
- <tr>
21
- <th>ID</th>
22
- <th>标题</th>
23
- <th>路径</th>
24
- <th>图标</th>
25
- <th>类型</th>
26
- <th>排序</th>
27
- <th>操作</th>
28
- </tr>
29
- </thead>
30
- <tbody>
31
- {menus.map((menu) => (
32
- <tr key={menu.id}>
33
- <td>{menu.id}</td>
34
- <td>{menu.title}</td>
35
- <td>
36
- <code
37
- style={{
38
- background: 'var(--bg-color-page)',
39
- padding: '2px 8px',
40
- borderRadius: 3,
41
- fontSize: 13,
42
- color: 'var(--primary-color)'
43
- }}
44
- >
45
- {menu.path}
46
- </code>
47
- </td>
48
- <td>{menu.icon}</td>
49
- <td>{menu.type}</td>
50
- <td>{menu.sort}</td>
51
- <td>
52
- <button className="btn-link">编辑</button>
53
- <button className="btn-link danger">删除</button>
54
- </td>
55
- </tr>
56
- ))}
57
- </tbody>
58
- </table>
59
- </div>
60
- )
61
- }
62
-
@@ -1,63 +0,0 @@
1
- import '@/styles/page-common.scss'
2
-
3
- const roles = [
4
- { id: 1, name: 'admin', label: '超级管理员', description: '拥有所有权限', status: '启用' },
5
- { id: 2, name: 'editor', label: '编辑', description: '可编辑内容', status: '启用' },
6
- { id: 3, name: 'viewer', label: '只读', description: '只能查看', status: '启用' }
7
- ]
8
-
9
- export default function SystemRole() {
10
- return (
11
- <div className="page-container">
12
- <div className="page-header">
13
- <h2>角色管理</h2>
14
- <button className="btn-primary">+ 新增角色</button>
15
- </div>
16
- <table className="data-table">
17
- <thead>
18
- <tr>
19
- <th>ID</th>
20
- <th>角色标识</th>
21
- <th>角色名称</th>
22
- <th>描述</th>
23
- <th>状态</th>
24
- <th>操作</th>
25
- </tr>
26
- </thead>
27
- <tbody>
28
- {roles.map((role) => (
29
- <tr key={role.id}>
30
- <td>{role.id}</td>
31
- <td>
32
- <code
33
- style={{
34
- background: 'var(--bg-color-page)',
35
- padding: '2px 8px',
36
- borderRadius: 3,
37
- fontSize: 13,
38
- color: 'var(--primary-color)'
39
- }}
40
- >
41
- {role.name}
42
- </code>
43
- </td>
44
- <td>{role.label}</td>
45
- <td>{role.description}</td>
46
- <td>
47
- <span className={role.status === '启用' ? 'status-active' : 'status-disabled'}>
48
- {role.status}
49
- </span>
50
- </td>
51
- <td>
52
- <button className="btn-link">编辑</button>
53
- <button className="btn-link">权限</button>
54
- <button className="btn-link danger">删除</button>
55
- </td>
56
- </tr>
57
- ))}
58
- </tbody>
59
- </table>
60
- </div>
61
- )
62
- }
63
-
@@ -1,67 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <div class="about-page">
6
- <div class="about-card">
7
- <h1>关于</h1>
8
- <p>这是一个基于 Vue 3 的现代化前端模板项目。</p>
9
- <ul>
10
- <li>Vue 3 Composition API</li>
11
- <li>Vite 5 构建工具</li>
12
- <li>TypeScript 5 类型支持</li>
13
- <li>Vue Router 4 路由管理</li>
14
- <li>Pinia 状态管理 (支持持久化)</li>
15
- <li>Axios 请求封装 (拦截器 + 类型)</li>
16
- <li>TailwindCSS</li>
17
- <li>unplugin-auto-import 自动导入</li>
18
- <li>ESLint + Prettier 代码规范</li>
19
- </ul>
20
- </div>
21
- </div>
22
- </template>
23
-
24
- <style scoped lang="scss">
25
- .about-page {
26
- max-width: 700px;
27
- margin: 0 auto;
28
- }
29
-
30
- .about-card {
31
- background: var(--bg-color-overlay);
32
- border-radius: var(--border-radius-lg);
33
- padding: 32px;
34
- box-shadow: var(--box-shadow-light);
35
-
36
- h1 {
37
- font-size: 24px;
38
- margin-bottom: 12px;
39
- color: var(--text-color);
40
- }
41
-
42
- p {
43
- color: var(--text-color-secondary);
44
- margin-bottom: 16px;
45
- }
46
-
47
- ul {
48
- list-style: none;
49
- padding: 0;
50
-
51
- li {
52
- padding: 8px 0;
53
- border-bottom: 1px solid var(--border-color-light);
54
- color: var(--text-color-regular);
55
-
56
- &::before {
57
- content: '✅ ';
58
- }
59
-
60
- &:last-child {
61
- border-bottom: none;
62
- }
63
- }
64
- }
65
- }
66
- </style>
67
-
@@ -1,153 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref } from 'vue'
3
- import { useRouter } from 'vue-router'
4
- import { useUserStore } from '@/stores/user'
5
-
6
- const router = useRouter()
7
- const userStore = useUserStore()
8
-
9
- const form = ref({
10
- username: '',
11
- password: ''
12
- })
13
- const loading = ref(false)
14
-
15
- async function handleLogin() {
16
- if (!form.value.username || !form.value.password) {
17
- alert('请输入用户名和密码')
18
- return
19
- }
20
-
21
- loading.value = true
22
- try {
23
- // TODO: 调用登录 API
24
- // const res = await loginApi(form.value)
25
- // userStore.setToken(res.data.token)
26
-
27
- // 模拟登录
28
- userStore.setToken('mock-token')
29
- userStore.setUserInfo({
30
- id: 1,
31
- username: form.value.username,
32
- nickname: '管理员',
33
- avatar: '',
34
- roles: ['admin']
35
- })
36
-
37
- router.push('/')
38
- } catch (error) {
39
- console.error('登录失败:', error)
40
- } finally {
41
- loading.value = false
42
- }
43
- }
44
- </script>
45
-
46
- <template>
47
- <div class="login-page">
48
- <div class="login-card">
49
- <h2>用户登录</h2>
50
- <form @submit.prevent="handleLogin">
51
- <div class="form-item">
52
- <label>用户名</label>
53
- <input
54
- v-model="form.username"
55
- type="text"
56
- placeholder="请输入用户名"
57
- autocomplete="username"
58
- />
59
- </div>
60
- <div class="form-item">
61
- <label>密码</label>
62
- <input
63
- v-model="form.password"
64
- type="password"
65
- placeholder="请输入密码"
66
- autocomplete="current-password"
67
- />
68
- </div>
69
- <button type="submit" class="login-btn" :disabled="loading">
70
- {{ loading ? '登录中...' : '登 录' }}
71
- </button>
72
- </form>
73
- </div>
74
- </div>
75
- </template>
76
-
77
- <style scoped lang="scss">
78
- .login-page {
79
- height: 100vh;
80
- display: flex;
81
- align-items: center;
82
- justify-content: center;
83
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
84
- }
85
-
86
- .login-card {
87
- width: 380px;
88
- padding: 40px;
89
- background: #fff;
90
- border-radius: 12px;
91
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
92
-
93
- h2 {
94
- text-align: center;
95
- margin-bottom: 32px;
96
- color: #333;
97
- font-size: 24px;
98
- }
99
- }
100
-
101
- .form-item {
102
- margin-bottom: 20px;
103
-
104
- label {
105
- display: block;
106
- margin-bottom: 6px;
107
- font-size: 14px;
108
- color: #606266;
109
- }
110
-
111
- input {
112
- width: 100%;
113
- padding: 10px 12px;
114
- border: 1px solid #dcdfe6;
115
- border-radius: 6px;
116
- font-size: 14px;
117
- outline: none;
118
- transition: border-color 0.2s;
119
- box-sizing: border-box;
120
-
121
- &:focus {
122
- border-color: #409eff;
123
- }
124
-
125
- &::placeholder {
126
- color: #c0c4cc;
127
- }
128
- }
129
- }
130
-
131
- .login-btn {
132
- width: 100%;
133
- padding: 12px;
134
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
135
- color: #fff;
136
- border: none;
137
- border-radius: 6px;
138
- font-size: 16px;
139
- cursor: pointer;
140
- transition: opacity 0.2s;
141
- margin-top: 8px;
142
-
143
- &:hover {
144
- opacity: 0.9;
145
- }
146
-
147
- &:disabled {
148
- opacity: 0.6;
149
- cursor: not-allowed;
150
- }
151
- }
152
- </style>
153
-