moyan-mfw-cli 1.1.7 → 1.1.9

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.
@@ -1,40 +1,90 @@
1
- <template>
2
- <div class="header-actions">
3
- <el-space :size="2">
4
- <!-- 主题切换 -->
5
- <div class="action-icon-btn" data-testid="header-theme-btn" @click="toggleTheme">
6
- <el-icon :size="18">
7
- <component :is="isDark ? Sunny : Moon" />
8
- </el-icon>
9
- </div>
10
-
11
- <!-- 全屏切换 -->
12
- <div class="action-icon-btn" data-testid="header-fullscreen-btn" @click="toggleFullscreen">
13
- <el-icon :size="18">
14
- <component :is="isFullscreen ? ScaleToOriginal : FullScreen" />
15
- </el-icon>
16
- </div>
17
-
18
- <!-- 布局设置 -->
19
- <div class="action-icon-btn" data-testid="header-settings-btn" @click="openLayoutSettings">
20
- <el-icon :size="18"><Setting /></el-icon>
21
- </div>
22
- </el-space>
23
- </div>
24
- </template>
1
+ <!--
2
+ **
3
+ * @fileoverview - 头部通用操作区组件(参考 Vben Admin 设计)
4
+ *
5
+ * 该组件是墨焱管理后台顶部导航栏的通用操作区,提供快捷操作入口。
6
+ *
7
+ * 功能说明:
8
+ * 1. 搜索按钮
9
+ * - 显示搜索图标
10
+ * - 支持快捷键 Ctrl+K 触发
11
+ * - 点击打开搜索面板
12
+ *
13
+ * 2. 主题切换
14
+ * - 点击切换亮色/暗色主题
15
+ * - 使用月亮/太阳图标
16
+ *
17
+ * 3. 全屏切换
18
+ * - 点击切换全屏模式
19
+ * - 使用展开/收起图标
20
+ *
21
+ * 4. 语言切换
22
+ * - 点击切换显示语言
23
+ * - 使用地球图标
24
+ *
25
+ * 5. 消息通知
26
+ * - 显示消息入口图标,跳转到 /monitor/overview
27
+ * - 使用 el-badge 组件显示未读消息数量
28
+ *
29
+ * 6. 布局设置
30
+ * - 点击打开布局样式配置抽屉
31
+ * - 通过调用 layoutStore.toggleSettingsPanel 方法控制抽屉显示
32
+ *
33
+ * 布局设计:
34
+ * - 使用 el-space 组件进行横向布局,间距 8px
35
+ * - 纯图标按钮设计,无边框无背景
36
+ * - 图标尺寸:20px
37
+ * - 消息徽章样式优化:红色背景,小号徽章
38
+ *
39
+ * 技术实现:
40
+ * - 使用 Vue 3 Composition API(script setup)
41
+ * - 使用 Element Plus UI 组件库
42
+ * - 使用 SCSS 进行样式编写
43
+ * - 使用 Vue Router 进行导航
44
+ * - 通过 Pinia Store 控制布局设置抽屉
45
+ *
46
+ * @author moyan
47
+ * @since 1.0.0
48
+ -->
25
49
 
26
50
  <script setup lang="ts">
27
- import { Setting, Moon, Sunny, FullScreen, ScaleToOriginal } from '@element-plus/icons-vue';
51
+ import { useLayoutStore, useColorMode } from 'moyan-mfw-base/frontend';
52
+ import {
53
+ Setting,
54
+ Moon,
55
+ Sunny,
56
+ FullScreen,
57
+ ScaleToOriginal,
58
+ } from '@element-plus/icons-vue';
28
59
  import { ref, onMounted, onUnmounted } from 'vue';
29
60
 
30
- const isDark = ref(false);
61
+ const layoutStore = useLayoutStore();
62
+ const { isDark, toggleDark } = useColorMode();
63
+
64
+ /**
65
+ * 全屏状态
66
+ */
31
67
  const isFullscreen = ref(false);
32
68
 
69
+ /**
70
+ * 打开布局设置面板。
71
+ * 调用 layoutStore 的 toggleSettingsPanel 方法显示抽屉。
72
+ */
73
+ const openLayoutSettings = () => {
74
+ layoutStore.toggleSettingsPanel(true);
75
+ };
76
+
77
+
78
+ /**
79
+ * 切换主题
80
+ */
33
81
  const toggleTheme = () => {
34
- isDark.value = !isDark.value;
35
- document.documentElement.classList.toggle('dark', isDark.value);
82
+ toggleDark();
36
83
  };
37
84
 
85
+ /**
86
+ * 切换全屏
87
+ */
38
88
  const toggleFullscreen = async () => {
39
89
  if (!document.fullscreenElement) {
40
90
  await document.documentElement.requestFullscreen();
@@ -45,13 +95,21 @@ const toggleFullscreen = async () => {
45
95
  }
46
96
  };
47
97
 
48
- const openLayoutSettings = () => {
49
- console.log('Open layout settings');
98
+
99
+
100
+ /**
101
+ * 打开搜索
102
+ */
103
+ const openSearch = () => {
50
104
  };
51
105
 
106
+ /**
107
+ * 监听键盘快捷键
108
+ */
52
109
  const handleKeydown = (e: KeyboardEvent) => {
53
110
  if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
54
111
  e.preventDefault();
112
+ openSearch();
55
113
  }
56
114
  };
57
115
 
@@ -64,6 +122,43 @@ onUnmounted(() => {
64
122
  });
65
123
  </script>
66
124
 
125
+ <template>
126
+ <div class="header-actions">
127
+ <el-space :size="2">
128
+ <!-- 搜索按钮 -->
129
+ <!-- <div class="action-icon-btn" @click="openSearch">
130
+ <el-icon :size="18"><Search /></el-icon>
131
+ </div> -->
132
+
133
+ <!-- 主题切换 -->
134
+ <div class="action-icon-btn" data-testid="header-theme-btn" @click="toggleTheme">
135
+ <el-icon :size="18">
136
+ <component :is="isDark ? Sunny : Moon" />
137
+ </el-icon>
138
+ </div>
139
+
140
+ <!-- 全屏切换 -->
141
+ <div class="action-icon-btn" data-testid="header-fullscreen-btn" @click="toggleFullscreen">
142
+ <el-icon :size="18">
143
+ <component :is="isFullscreen ? ScaleToOriginal : FullScreen" />
144
+ </el-icon>
145
+ </div>
146
+
147
+ <!-- 消息通知 -->
148
+ <!-- <el-badge :value="3" class="action-badge">
149
+ <div class="action-icon-btn" @click="navigateTo('/monitor/overview')">
150
+ <el-icon :size="18"><Bell /></el-icon>
151
+ </div>
152
+ </el-badge> -->
153
+
154
+ <!-- 布局设置 -->
155
+ <div class="action-icon-btn" data-testid="header-settings-btn" @click="openLayoutSettings">
156
+ <el-icon :size="18"><Setting /></el-icon>
157
+ </div>
158
+ </el-space>
159
+ </div>
160
+ </template>
161
+
67
162
  <style scoped lang="scss">
68
163
  .header-actions {
69
164
  display: flex;
@@ -90,4 +185,19 @@ onUnmounted(() => {
90
185
  background: rgba(255, 255, 255, 0.18);
91
186
  }
92
187
  }
188
+
189
+ .action-badge {
190
+ :deep(.el-badge__content) {
191
+ right: 0;
192
+ top: 0;
193
+ border: none;
194
+ background: #ff4d4f;
195
+ font-weight: 600;
196
+ min-width: 16px;
197
+ height: 16px;
198
+ padding: 0 4px;
199
+ font-size: 11px;
200
+ transform: translate(25%, -25%);
201
+ }
202
+ }
93
203
  </style>
@@ -1,4 +1,6 @@
1
1
  import { createBaseAdminApp, registerPermissionValues } from 'moyan-mfw-base/frontend'
2
+ import 'moyan-mfw-base/frontend/style.css'
3
+ import 'moyan-mfw-extension-ad/frontend/style.css'
2
4
  import { HeaderCommonActions } from './components/Layout'
3
5
  import { businessRoutes } from './router'
4
6
  import { adRoutes } from 'moyan-mfw-extension-ad/frontend'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moyan-mfw-cli",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "MFW framework CLI — extension scaffolding, validation, and publishing tools",
5
5
  "type": "module",
6
6
  "bin": {