cmpt-huitu-cli 1.0.12 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmpt-huitu-cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "description": "慧图前端项目工程化 CLI 工具",
6
6
  "main": "index.js",
@@ -5,11 +5,9 @@
5
5
  >
6
6
  <el-container>
7
7
  <el-header>
8
- <div class="logo">Huitu Standard Template</div>
9
8
  <div class="nav">
10
9
  <router-link to="/">Home</router-link> |
11
10
  <router-link to="/about">About</router-link>
12
- <div @click="handleClick">你好</div>
13
11
  </div>
14
12
  </el-header>
15
13
  <el-main>
@@ -32,15 +30,7 @@
32
30
  </div>
33
31
  </template>
34
32
 
35
- <script setup>
36
- import { useRouter } from 'vue-router'
37
-
38
- const router = useRouter()
39
-
40
- const handleClick = () => {
41
- router.push('/about')
42
- }
43
- </script>
33
+ <script setup></script>
44
34
 
45
35
  <style lang="scss">
46
36
  #app {
@@ -4,6 +4,8 @@ import router from './routers'
4
4
  import { createPinia } from 'pinia'
5
5
  import ElementPlus from 'element-plus'
6
6
  import 'element-plus/dist/index.css'
7
+ // 引入 Element Plus 暗黑模式样式
8
+ import 'element-plus/theme-chalk/dark/css-vars.css'
7
9
 
8
10
  // 引入项目样式
9
11
  import '@/styles/index.scss'
@@ -12,6 +14,9 @@ import '@/styles/index.scss'
12
14
  import * as HuituUtils from 'cmpt-huitu-utils'
13
15
  import HuituUI from 'cmpt-huitu-ui'
14
16
 
17
+ // 引入主题工具函数
18
+ import { initTheme } from '@/utils/theme'
19
+
15
20
  const app = createApp(App)
16
21
 
17
22
  app.use(router)
@@ -24,4 +29,7 @@ app.use(HuituUI)
24
29
  // 挂载工具函数到全局 (可选)
25
30
  app.config.globalProperties.$utils = HuituUtils
26
31
 
32
+ // 初始化主题(必须在挂载前调用,确保主题正确应用)
33
+ initTheme()
34
+
27
35
  app.mount('#app')
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @FileDescription: 路由模块演示
3
- * @Author:
3
+ * @Author:
4
4
  * @Date: 2024
5
5
  */
6
6
 
@@ -30,3 +30,12 @@ export async function refreshAccessTokenApi(params) {
30
30
  })
31
31
  return response.data
32
32
  }
33
+
34
+ // 获取主题
35
+ export async function getThemeInfoApi() {
36
+ const response = await cache.request({
37
+ url: 'system/theme/theme-info',
38
+ method: 'post',
39
+ })
40
+ return response.data
41
+ }
@@ -18,6 +18,21 @@
18
18
  // 引入 Element Plus 重置样式(依赖上面的变量)
19
19
  // @use 'cmpt-huitu-ui/src/styles/reset.scss';
20
20
 
21
+ // 全局背景颜色设置
22
+ body {
23
+ background-color: var(--body-bg-color);
24
+ color: var(--main-font-color);
25
+ transition:
26
+ background-color 0.3s ease,
27
+ color 0.3s ease;
28
+ }
29
+
30
+ #app {
31
+ background-color: var(--bg-color);
32
+ min-height: 100vh;
33
+ transition: background-color 0.3s ease;
34
+ }
35
+
21
36
  // 项目自定义样式
22
37
  // 如需添加其他自定义样式,请在 theme/ 目录下创建文件并在此处引入
23
38
  // @use './theme/custom.scss' as *;
@@ -13,6 +13,9 @@
13
13
  --main-font-color: #333333;
14
14
  --main-color: #067dff;
15
15
  --stat-font-color: #067dff;
16
+ /* 背景颜色 */
17
+ --bg-color: #ffffff;
18
+ --body-bg-color: #f5f5f5;
16
19
 
17
20
  /* 表格相关 */
18
21
  // --table-head-bg: linear-gradient(180deg, #b2d2ff 0%, #b9daff 100%);
@@ -40,6 +43,9 @@
40
43
  --main-font-color: #ffffff;
41
44
  --main-color: #e3a000;
42
45
  --stat-font-color: #ffffff;
46
+ /* 背景颜色 */
47
+ --bg-color: #1a1a1a;
48
+ --body-bg-color: #0d0d0d;
43
49
 
44
50
  /* 表格相关 */
45
51
  // --table-head-bg: linear-gradient(180deg, rgba(1, 49, 78, 1) 0%, rgba(0, 66, 104, 1) 100%);
@@ -7,7 +7,20 @@ import { cache } from 'cmpt-huitu-utils'
7
7
  const { local } = cache
8
8
  export const setTheme = (theme) => {
9
9
  local.set('data-theme', theme)
10
- document.documentElement.setAttribute('data-theme', theme)
10
+ const html = document.documentElement
11
+
12
+ // 设置 data-theme 属性
13
+ html.setAttribute('data-theme', theme)
14
+
15
+ // 设置 vxe-table 主题 (data-vxe-ui-theme)
16
+ html.setAttribute('data-vxe-ui-theme', theme)
17
+
18
+ // 设置 Element Plus 暗黑模式
19
+ if (theme === 'dark') {
20
+ html.classList.add('dark')
21
+ } else {
22
+ html.classList.remove('dark')
23
+ }
11
24
  }
12
25
  // 获取当前主题
13
26
  export const getTheme = () => {
@@ -1,21 +1,22 @@
1
1
  <template>
2
2
  <div class="home">
3
3
  <h1>欢迎使用慧图标准脚手架</h1>
4
- <VexTable
5
- :columns="columns"
6
- :data="data"
7
- />
8
- <HTable
9
- :data="data"
10
- :columns="hTableColumns"
4
+ <el-button
5
+ type="primary"
6
+ :icon="Star"
7
+ @click="changeTheme"
8
+ >切换主题 (当前: {{ currentTheme === 'dark' ? '深色' : '浅色' }})</el-button
9
+ >
10
+ <el-button
11
+ type="primary"
12
+ @click="openDialog"
13
+ >打开弹框组件</el-button
14
+ >
15
+ <el-button
16
+ type="primary"
17
+ @click="openDrawer"
18
+ >打开抽屉组件</el-button
11
19
  >
12
- </HTable>
13
- <div class="chartsBox">
14
- <htLineRelation
15
- class="charts"
16
- ref="myChart"
17
- ></htLineRelation>
18
- </div>
19
20
  <div class="content">
20
21
  <p>这是一个基于 Monorepo 架构的 Vue 3 标准模版。</p>
21
22
  <p>已集成:</p>
@@ -32,11 +33,108 @@
32
33
  <h3>组件演示</h3>
33
34
  <p>VexTable 和 HTable 组件已成功集成</p>
34
35
  </div>
36
+
37
+ <el-row :gutter="20">
38
+ <el-col :span="12">
39
+ <div class="tableBox">
40
+ <h3>VexTable</h3>
41
+ <VexTable
42
+ :columns="columns"
43
+ :data="data"
44
+ />
45
+ </div>
46
+ </el-col>
47
+ <el-col :span="12">
48
+ <div class="tableBox">
49
+ <h3>HTable</h3>
50
+ <HTable
51
+ :data="data"
52
+ :columns="hTableColumns"
53
+ />
54
+ </div>
55
+ </el-col>
56
+ </el-row>
35
57
  </div>
58
+ <!--图表组件-->
59
+ <div class="chartsBox">
60
+ <htLineRelation
61
+ class="charts"
62
+ ref="myChart"
63
+ ></htLineRelation>
64
+ </div>
65
+ <!--地图组件-->
66
+ <div class="mapsBox">
67
+ <htMap
68
+ class="maps"
69
+ ref="myMap"
70
+ :layers="layers"
71
+ ></htMap>
72
+ </div>
73
+
74
+ <!--弹框组件-->
75
+ <HtDragDialog
76
+ v-model:visible="dialogVisible"
77
+ caption="测试拖拽弹窗"
78
+ :icon-name="iconName"
79
+ :w="500"
80
+ :h="400"
81
+ :min-width="300"
82
+ :min-height="200"
83
+ >
84
+ <div class="ht-dialog-wrap content">
85
+ <div class="ht-dialog-content">
86
+ <p>这是一个可拖拽、可拉伸的弹窗。</p>
87
+ <p>尝试拖动标题栏或调整边缘大小。</p>
88
+ <el-form label-width="80px">
89
+ <el-form-item label="输入框">
90
+ <el-input placeholder="请输入"></el-input>
91
+ </el-form-item>
92
+ </el-form>
93
+ </div>
94
+ <div class="ht-dialog-footer">
95
+ <el-button @click="dialogVisible = false">取消</el-button>
96
+ <el-button
97
+ type="primary"
98
+ class="right-btn"
99
+ @click="dialogVisible = false"
100
+ >确定</el-button
101
+ >
102
+ </div>
103
+ </div>
104
+ </HtDragDialog>
105
+
106
+ <!--抽屉组件-->
107
+ <HtNewDrawer
108
+ v-model:visible="drawerVisible"
109
+ title="测试抽屉"
110
+ drawer-size="50%"
111
+ :mask-closable="true"
112
+ >
113
+ <div style="padding: 20px">
114
+ <h3>抽屉内容</h3>
115
+ <p>这是一个基于 View UI Plus 的抽屉组件。</p>
116
+ <p>支持全屏切换、左侧关闭按钮等功能。</p>
117
+ </div>
118
+ </HtNewDrawer>
36
119
  </div>
37
120
  </template>
38
121
 
39
122
  <script setup>
123
+ import { getThemeInfoApi } from '@/services/login'
124
+ import { ElMessage } from 'element-plus'
125
+ import { Star } from '@element-plus/icons-vue'
126
+ import { setTheme, getTheme } from '@/utils/theme'
127
+
128
+ // 当前主题状态
129
+ const currentTheme = ref(getTheme())
130
+
131
+ onMounted(() => {
132
+ getThemeInfoApi().then((res) => {
133
+ console.log(res)
134
+ ElMessage.success('调用接口/system/theme/theme-info获取主题成功')
135
+ })
136
+ })
137
+
40
138
  const columns = [
41
139
  { type: 'seq', title: '序号', width: 80 },
42
140
  { field: 'name', title: '姓名', width: 120 },
@@ -69,15 +167,33 @@
69
167
  fixed: 'left',
70
168
  },
71
169
  ]
170
+
171
+ // 更换主题
172
+ const changeTheme = () => {
173
+ // 切换主题:light <-> dark
174
+ const newTheme = currentTheme.value === 'light' ? 'dark' : 'light'
175
+ setTheme(newTheme)
176
+ currentTheme.value = newTheme
177
+ ElMessage.success(`已切换到${newTheme === 'dark' ? '深色' : '浅色'}主题`)
178
+ }
179
+
180
+ // 打开抽屉
181
+ const drawerVisible = ref(false)
182
+ const openDrawer = () => {
183
+ drawerVisible.value = true
184
+ }
185
+
186
+ // 打开弹框
187
+ const dialogVisible = ref(false)
188
+ const openDialog = () => {
189
+ dialogVisible.value = true
190
+ }
72
191
  </script>
73
192
 
74
193
  <style scoped>
75
194
  .home {
76
195
  padding: 20px;
77
196
  }
78
- .content {
79
- margin-top: 20px;
80
- }
81
197
  ul {
82
198
  list-style: none;
83
199
  padding: 0;
@@ -93,11 +209,19 @@
93
209
  margin-bottom: 20px;
94
210
  }
95
211
  .chartsBox {
96
- width: 600px;
212
+ width: 700px;
97
213
  height: 500px;
98
214
  }
99
215
  .charts {
100
216
  width: 100%;
101
217
  height: 100%;
102
218
  }
219
+ .mapsBox {
220
+ width: 800px;
221
+ height: 400px;
222
+ }
223
+ .maps {
224
+ width: 100%;
225
+ height: 100%;
226
+ }
103
227
  </style>