congmao-cli 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.
Files changed (180) hide show
  1. package/README.md +2 -0
  2. package/bin/index.js +20 -0
  3. package/package.json +42 -0
  4. package/src/commands/create.js +171 -0
  5. package/src/commands/mcp.js +157 -0
  6. package/src/mcp/CURSOR_SETUP.md +259 -0
  7. package/src/mcp/README.md +134 -0
  8. package/src/mcp/USAGE_EXAMPLES.md +181 -0
  9. package/src/mcp/get-cursor-config.js +58 -0
  10. package/src/mcp/package.json +23 -0
  11. package/src/mcp/pnpm-lock.yaml +2441 -0
  12. package/src/mcp/src/handlers.js +211 -0
  13. package/src/mcp/src/http-server.js +332 -0
  14. package/src/mcp/src/index.js +195 -0
  15. package/src/mcp/src/schemas.js +54 -0
  16. package/src/mcp/test-create-project.js +49 -0
  17. package/src/mcp/test-mcp.js +89 -0
  18. package/src/mcp/test-show-tree.js +66 -0
  19. package/src/template/Uni-app/README.md +19 -0
  20. package/src/template/Uni-app/babel.config.js +81 -0
  21. package/src/template/Uni-app/package.json +107 -0
  22. package/src/template/Uni-app/postcss.config.js +27 -0
  23. package/src/template/Uni-app/public/index.html +25 -0
  24. package/src/template/Uni-app/shims-uni.d.ts +11 -0
  25. package/src/template/Uni-app/shims-vue.d.ts +4 -0
  26. package/src/template/Uni-app/src/App.vue +17 -0
  27. package/src/template/Uni-app/src/main.js +12 -0
  28. package/src/template/Uni-app/src/manifest.json +75 -0
  29. package/src/template/Uni-app/src/pages/index/index.vue +49 -0
  30. package/src/template/Uni-app/src/pages.json +16 -0
  31. package/src/template/Uni-app/src/static/logo.png +0 -0
  32. package/src/template/Uni-app/src/uni.promisify.adaptor.js +13 -0
  33. package/src/template/Uni-app/src/uni.scss +76 -0
  34. package/src/template/Uni-app/yarn.lock +11466 -0
  35. package/src/template/Vue2/.editorconfig +14 -0
  36. package/src/template/Vue2/.env +2 -0
  37. package/src/template/Vue2/.env.development +2 -0
  38. package/src/template/Vue2/.env.site +2 -0
  39. package/src/template/Vue2/.prettierrc.js +39 -0
  40. package/src/template/Vue2/.stylelintignore +8 -0
  41. package/src/template/Vue2/README-zh_CN.md +115 -0
  42. package/src/template/Vue2/commitlint.config.js +1 -0
  43. package/src/template/Vue2/docs/docs-starter.png +0 -0
  44. package/src/template/Vue2/docs/docs-startup.png +0 -0
  45. package/src/template/Vue2/docs/docs-structure.png +0 -0
  46. package/src/template/Vue2/globals.d.ts +13 -0
  47. package/src/template/Vue2/index.html +27 -0
  48. package/src/template/Vue2/jsx.d.ts +13 -0
  49. package/src/template/Vue2/mock/index.ts +147 -0
  50. package/src/template/Vue2/package.json +91 -0
  51. package/src/template/Vue2/package.json.ejs +91 -0
  52. package/src/template/Vue2/public/favicon.ico +0 -0
  53. package/src/template/Vue2/shims-vue.d.ts +5 -0
  54. package/src/template/Vue2/src/App.vue +19 -0
  55. package/src/template/Vue2/src/assets/assets-login-bg-black.png +0 -0
  56. package/src/template/Vue2/src/assets/assets-login-bg-white.png +0 -0
  57. package/src/template/Vue2/src/assets/assets-logo-full.svg +39 -0
  58. package/src/template/Vue2/src/assets/assets-product-1.svg +5 -0
  59. package/src/template/Vue2/src/assets/assets-product-2.svg +5 -0
  60. package/src/template/Vue2/src/assets/assets-product-3.svg +5 -0
  61. package/src/template/Vue2/src/assets/assets-product-4.svg +5 -0
  62. package/src/template/Vue2/src/assets/assets-result-403.svg +32 -0
  63. package/src/template/Vue2/src/assets/assets-result-404.svg +36 -0
  64. package/src/template/Vue2/src/assets/assets-result-500.svg +32 -0
  65. package/src/template/Vue2/src/assets/assets-result-ie.svg +33 -0
  66. package/src/template/Vue2/src/assets/assets-result-maintenance.svg +49 -0
  67. package/src/template/Vue2/src/assets/assets-result-wifi.svg +23 -0
  68. package/src/template/Vue2/src/assets/assets-setting-auto.svg +13 -0
  69. package/src/template/Vue2/src/assets/assets-setting-dark.svg +5 -0
  70. package/src/template/Vue2/src/assets/assets-setting-light.svg +13 -0
  71. package/src/template/Vue2/src/assets/assets-t-logo.svg +41 -0
  72. package/src/template/Vue2/src/assets/assets-tencent-logo.png +0 -0
  73. package/src/template/Vue2/src/components/color/index.vue +35 -0
  74. package/src/template/Vue2/src/components/product-card/index.vue +121 -0
  75. package/src/template/Vue2/src/components/result/index.vue +118 -0
  76. package/src/template/Vue2/src/components/thumbnail/index.vue +49 -0
  77. package/src/template/Vue2/src/components/trend/index.vue +105 -0
  78. package/src/template/Vue2/src/config/color.ts +30 -0
  79. package/src/template/Vue2/src/config/global.ts +2 -0
  80. package/src/template/Vue2/src/config/host.ts +26 -0
  81. package/src/template/Vue2/src/config/style.ts +14 -0
  82. package/src/template/Vue2/src/constants/index.ts +46 -0
  83. package/src/template/Vue2/src/interface.ts +39 -0
  84. package/src/template/Vue2/src/layouts/blank.vue +12 -0
  85. package/src/template/Vue2/src/layouts/components/Breadcrumb.vue +39 -0
  86. package/src/template/Vue2/src/layouts/components/Content.vue +43 -0
  87. package/src/template/Vue2/src/layouts/components/Footer.vue +27 -0
  88. package/src/template/Vue2/src/layouts/components/Header.vue +321 -0
  89. package/src/template/Vue2/src/layouts/components/LayoutContent.vue +168 -0
  90. package/src/template/Vue2/src/layouts/components/LayoutHeader.vue +52 -0
  91. package/src/template/Vue2/src/layouts/components/LayoutSidebar.vue +51 -0
  92. package/src/template/Vue2/src/layouts/components/MenuContent.vue +108 -0
  93. package/src/template/Vue2/src/layouts/components/Notice.vue +221 -0
  94. package/src/template/Vue2/src/layouts/components/Search.vue +134 -0
  95. package/src/template/Vue2/src/layouts/components/SideNav.vue +150 -0
  96. package/src/template/Vue2/src/layouts/index.vue +100 -0
  97. package/src/template/Vue2/src/layouts/setting.vue +404 -0
  98. package/src/template/Vue2/src/main.js +9 -0
  99. package/src/template/Vue2/src/main.jsx +51 -0
  100. package/src/template/Vue2/src/pages/dashboard/base/components/MiddleChart.vue +158 -0
  101. package/src/template/Vue2/src/pages/dashboard/base/components/OutputOverview.vue +189 -0
  102. package/src/template/Vue2/src/pages/dashboard/base/components/RankList.vue +111 -0
  103. package/src/template/Vue2/src/pages/dashboard/base/components/TopPanel.vue +246 -0
  104. package/src/template/Vue2/src/pages/dashboard/base/index.ts +702 -0
  105. package/src/template/Vue2/src/pages/dashboard/base/index.vue +44 -0
  106. package/src/template/Vue2/src/pages/dashboard/detail/index.ts +267 -0
  107. package/src/template/Vue2/src/pages/dashboard/detail/index.vue +242 -0
  108. package/src/template/Vue2/src/pages/detail/advanced/components/Product.vue +167 -0
  109. package/src/template/Vue2/src/pages/detail/advanced/index.less +74 -0
  110. package/src/template/Vue2/src/pages/detail/advanced/index.vue +219 -0
  111. package/src/template/Vue2/src/pages/detail/base/index.less +105 -0
  112. package/src/template/Vue2/src/pages/detail/base/index.vue +46 -0
  113. package/src/template/Vue2/src/pages/detail/deploy/index.ts +204 -0
  114. package/src/template/Vue2/src/pages/detail/deploy/index.vue +224 -0
  115. package/src/template/Vue2/src/pages/detail/secondary/index.less +71 -0
  116. package/src/template/Vue2/src/pages/detail/secondary/index.vue +131 -0
  117. package/src/template/Vue2/src/pages/form/base/index.less +57 -0
  118. package/src/template/Vue2/src/pages/form/base/index.vue +254 -0
  119. package/src/template/Vue2/src/pages/form/step/index.less +37 -0
  120. package/src/template/Vue2/src/pages/form/step/index.vue +259 -0
  121. package/src/template/Vue2/src/pages/frame/doc/index.vue +86 -0
  122. package/src/template/Vue2/src/pages/frame/tdesign/index.vue +86 -0
  123. package/src/template/Vue2/src/pages/list/base/index.vue +267 -0
  124. package/src/template/Vue2/src/pages/list/card/index.vue +221 -0
  125. package/src/template/Vue2/src/pages/list/components/CommonTable.vue +313 -0
  126. package/src/template/Vue2/src/pages/list/filter/index.vue +15 -0
  127. package/src/template/Vue2/src/pages/list/tree/index.vue +174 -0
  128. package/src/template/Vue2/src/pages/login/components/components-header.vue +74 -0
  129. package/src/template/Vue2/src/pages/login/components/components-login.vue +154 -0
  130. package/src/template/Vue2/src/pages/login/components/components-register.vue +144 -0
  131. package/src/template/Vue2/src/pages/login/index.less +202 -0
  132. package/src/template/Vue2/src/pages/login/index.vue +53 -0
  133. package/src/template/Vue2/src/pages/nest-menu/Index.vue +10 -0
  134. package/src/template/Vue2/src/pages/result/403/index.vue +14 -0
  135. package/src/template/Vue2/src/pages/result/404/index.vue +14 -0
  136. package/src/template/Vue2/src/pages/result/500/index.vue +14 -0
  137. package/src/template/Vue2/src/pages/result/browser-incompatible/index.vue +77 -0
  138. package/src/template/Vue2/src/pages/result/fail/index.vue +57 -0
  139. package/src/template/Vue2/src/pages/result/maintenance/index.vue +14 -0
  140. package/src/template/Vue2/src/pages/result/network-error/index.vue +24 -0
  141. package/src/template/Vue2/src/pages/result/success/index.vue +59 -0
  142. package/src/template/Vue2/src/pages/user/index.less +148 -0
  143. package/src/template/Vue2/src/pages/user/index.ts +157 -0
  144. package/src/template/Vue2/src/pages/user/index.vue +204 -0
  145. package/src/template/Vue2/src/permission.js +56 -0
  146. package/src/template/Vue2/src/router/index.js +43 -0
  147. package/src/template/Vue2/src/router/modules/base.ts +29 -0
  148. package/src/template/Vue2/src/router/modules/components.ts +175 -0
  149. package/src/template/Vue2/src/router/modules/others.ts +55 -0
  150. package/src/template/Vue2/src/service/service-advance.ts +233 -0
  151. package/src/template/Vue2/src/service/service-base.ts +205 -0
  152. package/src/template/Vue2/src/service/service-detail-base.ts +84 -0
  153. package/src/template/Vue2/src/service/service-detail-deploy.ts +234 -0
  154. package/src/template/Vue2/src/service/service-detail.ts +57 -0
  155. package/src/template/Vue2/src/service/service-user.ts +64 -0
  156. package/src/template/Vue2/src/store/index.ts +22 -0
  157. package/src/template/Vue2/src/store/modules/notification.ts +90 -0
  158. package/src/template/Vue2/src/store/modules/permission.ts +66 -0
  159. package/src/template/Vue2/src/store/modules/setting.ts +122 -0
  160. package/src/template/Vue2/src/store/modules/tab-router.ts +83 -0
  161. package/src/template/Vue2/src/store/modules/user.ts +98 -0
  162. package/src/template/Vue2/src/style/font-family.less +6 -0
  163. package/src/template/Vue2/src/style/index.less +5 -0
  164. package/src/template/Vue2/src/style/layout.less +201 -0
  165. package/src/template/Vue2/src/style/reset.less +78 -0
  166. package/src/template/Vue2/src/style/variables.less +27 -0
  167. package/src/template/Vue2/src/utils/charts.ts +38 -0
  168. package/src/template/Vue2/src/utils/color.ts +118 -0
  169. package/src/template/Vue2/src/utils/date.ts +12 -0
  170. package/src/template/Vue2/src/utils/request.ts +60 -0
  171. package/src/template/Vue2/stylelint.config.js +5 -0
  172. package/src/template/Vue2/tsconfig.json +26 -0
  173. package/src/template/Vue2/vite.config.js +58 -0
  174. package/src/template/Vue3/package.json.ejs +8 -0
  175. package/src/template/Vue3/pages.json +10 -0
  176. package/src/template/Vue3/src/main.js +7 -0
  177. package/src/utils/copy.js +17 -0
  178. package/src/utils/eslint.js +205 -0
  179. package/src/utils/logo.js +18 -0
  180. package/src/utils/render.js +20 -0
@@ -0,0 +1,221 @@
1
+ <template>
2
+ <t-popup
3
+ expand-animation
4
+ placement="bottom-right"
5
+ trigger="click"
6
+ :visible="isNoticeVisible"
7
+ @visible-change="onPopupVisibleChange"
8
+ >
9
+ <template #content>
10
+ <div class="header-msg">
11
+ <div class="header-msg-top">
12
+ <p>通知</p>
13
+ <t-button v-if="unreadMsg.length > 0" class="clear-btn" variant="text" theme="primary" @click="setRead('all')"
14
+ >清空</t-button
15
+ >
16
+ </div>
17
+ <t-list v-if="unreadMsg.length > 0" class="narrow-scrollbar" :split="true">
18
+ <t-list-item v-for="(item, index) in unreadMsg" :key="index">
19
+ <div>
20
+ <p class="msg-content">{{ item.content }}</p>
21
+ <p class="msg-type">{{ item.type }}</p>
22
+ </div>
23
+ <p class="msg-time">{{ item.date }}</p>
24
+ <template #action>
25
+ <t-button size="small" variant="outline" @click="setRead('radio', item)"> 设为已读 </t-button>
26
+ </template>
27
+ </t-list-item>
28
+ </t-list>
29
+
30
+ <div v-else class="empty-list">
31
+ <img src="https://tdesign.gtimg.com/pro-template/personal/nothing.png" alt="空" />
32
+ <p>暂无通知</p>
33
+ </div>
34
+ <div class="header-msg-bottom">
35
+ <t-button
36
+ v-if="unreadMsg.length > 0"
37
+ class="header-msg-bottom-link"
38
+ variant="text"
39
+ theme="primary"
40
+ @click="goDetail"
41
+ >查看全部</t-button
42
+ >
43
+ </div>
44
+ </div>
45
+ </template>
46
+ <t-badge :count="unreadMsg.length" :offset="[15, 6]">
47
+ <t-button theme="default" shape="square" variant="text" @click="isNoticeVisible = true">
48
+ <mail-icon />
49
+ </t-button>
50
+ </t-badge>
51
+ </t-popup>
52
+ </template>
53
+
54
+ <script lang="ts">
55
+ import Vue from 'vue';
56
+ import { mapState, mapGetters } from 'vuex';
57
+ import { MailIcon } from 'tdesign-icons-vue';
58
+
59
+ import { NotificationItem } from '@/interface';
60
+
61
+ export default Vue.extend({
62
+ components: {
63
+ MailIcon,
64
+ },
65
+ data() {
66
+ return {
67
+ isNoticeVisible: false,
68
+ };
69
+ },
70
+ computed: {
71
+ ...mapState('notification', ['msgData']),
72
+ ...mapGetters('notification', ['unreadMsg']),
73
+ },
74
+ methods: {
75
+ onPopupVisibleChange(visible: boolean, context) {
76
+ if (context.trigger === 'trigger-element-click') {
77
+ this.isNoticeVisible = true;
78
+ return;
79
+ }
80
+ this.isNoticeVisible = visible;
81
+ },
82
+ goDetail() {
83
+ this.$router.push('/detail/secondary');
84
+ this.isNoticeVisible = false;
85
+ },
86
+ setRead(type: string, item?: NotificationItem) {
87
+ const changeMsg = this.msgData;
88
+ if (type === 'all') {
89
+ changeMsg.forEach((e) => {
90
+ e.status = false;
91
+ });
92
+ } else {
93
+ changeMsg.forEach((e) => {
94
+ if (e.id === item.id) {
95
+ e.status = false;
96
+ }
97
+ });
98
+ }
99
+ this.$store.commit('notification/setMsgData', changeMsg);
100
+ },
101
+ },
102
+ });
103
+ </script>
104
+
105
+ <style lang="less" scoped>
106
+ @import '@/style/variables.less';
107
+
108
+ .header-msg {
109
+ width: 400px;
110
+ height: 500px;
111
+
112
+ .empty-list {
113
+ height: calc(100% - 104px);
114
+ text-align: center;
115
+ padding-top: 135px;
116
+ font-size: 14px;
117
+ color: var(--td-text-color-secondary);
118
+
119
+ img {
120
+ width: 63px;
121
+ }
122
+
123
+ p {
124
+ margin-top: 30px;
125
+ }
126
+ }
127
+
128
+ &-top {
129
+ position: relative;
130
+ height: 56px;
131
+ font-size: 16px;
132
+ color: var(--td-text-color-primary);
133
+ text-align: center;
134
+ line-height: 56px;
135
+ border-bottom: 1px solid var(--td-component-border);
136
+
137
+ .clear-btn {
138
+ position: absolute;
139
+ top: 12px;
140
+ right: 24px;
141
+ }
142
+ }
143
+
144
+ &-bottom {
145
+ height: 48px;
146
+ align-items: center;
147
+ display: flex;
148
+ justify-content: center;
149
+
150
+ &-link {
151
+ text-decoration: none;
152
+ font-size: 14px;
153
+ color: var(--td-brand-color);
154
+ line-height: 48px;
155
+ cursor: pointer;
156
+ }
157
+ }
158
+
159
+ .t-list {
160
+ height: calc(100% - 104px);
161
+ }
162
+
163
+ .t-list-item {
164
+ overflow: hidden;
165
+ width: 100%;
166
+ padding: 16px 24px;
167
+ border-radius: var(--td-radius-default);
168
+ font-size: 14px;
169
+ color: var(--td-text-color-primary);
170
+ line-height: 22px;
171
+ cursor: pointer;
172
+
173
+ &:hover {
174
+ transition: background 0.2s ease;
175
+ background: var(--td-bg-color-container-hover);
176
+
177
+ .msg-content {
178
+ color: var(--td-brand-color);
179
+ }
180
+
181
+ .t-list-item__action {
182
+ button {
183
+ bottom: 16px;
184
+ opacity: 1;
185
+ }
186
+ }
187
+
188
+ .msg-time {
189
+ bottom: -6px;
190
+ opacity: 0;
191
+ }
192
+ }
193
+
194
+ .msg-content {
195
+ margin-bottom: 16px;
196
+ }
197
+
198
+ .msg-type {
199
+ color: var(--td-text-color-secondary);
200
+ }
201
+
202
+ .t-list-item__action {
203
+ button {
204
+ opacity: 0;
205
+ position: absolute;
206
+ right: 24px;
207
+ bottom: -6px;
208
+ }
209
+ }
210
+
211
+ .msg-time {
212
+ transition: all 0.2s ease;
213
+ opacity: 1;
214
+ position: absolute;
215
+ right: 24px;
216
+ bottom: 16px;
217
+ color: var(--td-text-color-secondary);
218
+ }
219
+ }
220
+ }
221
+ </style>
@@ -0,0 +1,134 @@
1
+ <template>
2
+ <div v-if="layout === 'side'" class="header-menu-search">
3
+ <t-input
4
+ :class="{ 'hover-active': isSearchFocus }"
5
+ placeholder="请输入搜索内容"
6
+ @blur="changeSearchFocus(false)"
7
+ @focus="changeSearchFocus(true)"
8
+ >
9
+ <template #prefix-icon>
10
+ <search-icon class="icon" size="16" />
11
+ </template>
12
+ </t-input>
13
+ </div>
14
+
15
+ <div v-else class="header-menu-search-left">
16
+ <t-button
17
+ :class="{ 'search-icon-hide': isSearchFocus }"
18
+ theme="default"
19
+ shape="square"
20
+ variant="text"
21
+ @click="changeSearchFocus(true)"
22
+ >
23
+ <search-icon />
24
+ </t-button>
25
+ <t-input
26
+ ref="inputRef"
27
+ v-model="searchData"
28
+ :class="['header-search', { 'width-zero': !isSearchFocus }]"
29
+ placeholder="输入要搜索内容"
30
+ :autofocus="isSearchFocus"
31
+ @blur="changeSearchFocus(false)"
32
+ >
33
+ <template #prefix-icon>
34
+ <search-icon size="16" />
35
+ </template>
36
+ </t-input>
37
+ </div>
38
+ </template>
39
+
40
+ <script lang="ts">
41
+ import Vue, { PropType } from 'vue';
42
+ import { SearchIcon } from 'tdesign-icons-vue';
43
+
44
+ export default Vue.extend({
45
+ components: {
46
+ SearchIcon,
47
+ },
48
+ props: {
49
+ layout: {
50
+ type: String as PropType<string>,
51
+ },
52
+ },
53
+ data() {
54
+ return {
55
+ isSearchFocus: false,
56
+ searchData: '',
57
+ };
58
+ },
59
+ methods: {
60
+ changeSearchFocus(value: boolean) {
61
+ if (!value) {
62
+ this.searchData = '';
63
+ }
64
+ this.isSearchFocus = value;
65
+ },
66
+ },
67
+ });
68
+ </script>
69
+ <style lang="less" scoped>
70
+ @import '@/style/variables.less';
71
+
72
+ .header-menu-search {
73
+ display: flex;
74
+ margin-left: 16px;
75
+
76
+ .hover-active {
77
+ .t-input {
78
+ background: var(--td-bg-color-secondarycontainer);
79
+ }
80
+
81
+ /deep/ .t-icon {
82
+ color: var(--td-brand-color);
83
+ }
84
+ }
85
+
86
+ /deep/ .t-icon {
87
+ font-size: 20px;
88
+ color: var(--td-text-color-primary);
89
+ }
90
+
91
+ .t-input {
92
+ border: none;
93
+ outline: none;
94
+ box-shadow: none;
95
+ transition: background @anim-duration-base linear;
96
+
97
+ &:hover {
98
+ background: var(--td-bg-color-secondarycontainer);
99
+ }
100
+ }
101
+ }
102
+
103
+ .header-search {
104
+ width: 200px;
105
+ transition: width @anim-duration-base @anim-time-fn-easing;
106
+
107
+ .t-input {
108
+ border: 0;
109
+ padding-left: 40px;
110
+
111
+ &:focus {
112
+ box-shadow: none;
113
+ }
114
+ }
115
+
116
+ &.width-zero {
117
+ width: 0;
118
+ opacity: 0;
119
+ }
120
+ }
121
+
122
+ .t-button {
123
+ transition: opacity @anim-duration-base @anim-time-fn-easing;
124
+ }
125
+
126
+ .search-icon-hide {
127
+ opacity: 0;
128
+ }
129
+
130
+ .header-menu-search-left {
131
+ display: flex;
132
+ align-items: center;
133
+ }
134
+ </style>
@@ -0,0 +1,150 @@
1
+ <template>
2
+ <div :class="sideNavCls">
3
+ <t-menu
4
+ width="232px"
5
+ :class="menuCls"
6
+ :theme="theme"
7
+ :value="active"
8
+ :collapsed="collapsed"
9
+ :defaultExpanded="defaultExpanded"
10
+ >
11
+ <template #logo>
12
+ <span v-if="showLogo" :class="`${prefix}-side-nav-logo-wrapper`" @click="() => handleNav('/dashboard/base')">
13
+ <component :is="getLogo" :class="`${prefix}-side-nav-logo-${collapsed ? 't' : 'tdesign'}-logo`" />
14
+ </span>
15
+ </template>
16
+ <menu-content :navData="menu" />
17
+ <template #operations>
18
+ <span class="version-container"> {{ !collapsed ? `TDesign Starter ${pgk.version}` : pgk.version }} </span>
19
+ </template>
20
+ </t-menu>
21
+ <div :class="`${prefix}-side-nav-placeholder${collapsed ? '-hidden' : ''}`"></div>
22
+ </div>
23
+ </template>
24
+
25
+ <script lang="ts">
26
+ import Vue from 'vue';
27
+ import { prefix } from '@/config/global';
28
+ import { ClassName } from '@/interface';
29
+ import Logo from '@/assets/assets-t-logo.svg';
30
+ import LogoFull from '@/assets/assets-logo-full.svg';
31
+
32
+ import MenuContent from './MenuContent.vue';
33
+ import pgk from '../../../package.json';
34
+
35
+ const MIN_POINT = 992 - 1;
36
+
37
+ export default Vue.extend({
38
+ name: 'sideNav',
39
+ components: {
40
+ MenuContent,
41
+ },
42
+ props: {
43
+ menu: Array,
44
+ showLogo: {
45
+ type: Boolean,
46
+ default: true,
47
+ },
48
+ isFixed: {
49
+ type: Boolean,
50
+ default: true,
51
+ },
52
+ layout: String,
53
+ headerHeight: {
54
+ type: String,
55
+ default: '56px',
56
+ },
57
+ theme: {
58
+ type: String,
59
+ default: 'light',
60
+ },
61
+ isCompact: {
62
+ type: Boolean,
63
+ default: false,
64
+ },
65
+ maxLevel: {
66
+ type: Number,
67
+ default: 3,
68
+ },
69
+ },
70
+ data() {
71
+ return {
72
+ prefix,
73
+ pgk,
74
+ };
75
+ },
76
+ computed: {
77
+ defaultExpanded() {
78
+ const path = this.active;
79
+ const parentPath = path.substring(0, path.lastIndexOf('/'));
80
+ if (parentPath.lastIndexOf('/')) {
81
+ const threeLevel = parentPath.substring(0, parentPath.lastIndexOf('/'));
82
+ return threeLevel === '' ? [] : [threeLevel, parentPath];
83
+ }
84
+ return parentPath === '' ? [] : [parentPath];
85
+ },
86
+ iconName(): string {
87
+ return this.$store.state.setting.isSidebarCompact ? 'menu-fold' : 'menu-unfold';
88
+ },
89
+ collapsed(): boolean {
90
+ return this.$store.state.setting.isSidebarCompact;
91
+ },
92
+ sideNavCls(): Array<ClassName> {
93
+ return [
94
+ `${this.prefix}-sidebar-layout`,
95
+ {
96
+ [`${this.prefix}-sidebar-compact`]: this.isCompact,
97
+ },
98
+ ];
99
+ },
100
+ menuCls(): Array<ClassName> {
101
+ return [
102
+ `${this.prefix}-side-nav`,
103
+ {
104
+ [`${this.prefix}-side-nav-no-logo`]: !this.showLogo,
105
+ [`${this.prefix}-side-nav-no-fixed`]: !this.isFixed,
106
+ [`${this.prefix}-side-nav-mix-fixed`]: this.layout === 'mix' && this.isFixed,
107
+ },
108
+ ];
109
+ },
110
+ layoutCls(): Array<ClassName> {
111
+ return [`${this.prefix}-side-nav-${this.layout}`, `${this.prefix}-sidebar-layout`];
112
+ },
113
+ active(): string {
114
+ if (!this.$route.path) {
115
+ return '';
116
+ }
117
+ return this.$route.path
118
+ .split('/')
119
+ .filter((_item: string, index: number) => index <= this.maxLevel && index > 0)
120
+ .map((item: string) => `/${item}`)
121
+ .join('');
122
+ },
123
+ getLogo() {
124
+ if (this.collapsed) {
125
+ return Logo;
126
+ }
127
+ return LogoFull;
128
+ },
129
+ },
130
+ mounted() {
131
+ this.autoCollapsed();
132
+
133
+ window.onresize = () => {
134
+ this.autoCollapsed();
135
+ };
136
+ },
137
+ methods: {
138
+ changeCollapsed(): void {
139
+ this.$store.commit('setting/toggleSidebarCompact');
140
+ },
141
+ autoCollapsed(): void {
142
+ const isCompact = window.innerWidth <= MIN_POINT;
143
+ this.$store.commit('setting/showSidebarCompact', isCompact);
144
+ },
145
+ handleNav(url: string) {
146
+ this.$router.push(url);
147
+ },
148
+ },
149
+ });
150
+ </script>
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <div>
3
+ <template v-if="setting.layout === 'side'">
4
+ <t-layout key="side">
5
+ <t-aside><layout-sidebar /></t-aside>
6
+ <t-layout>
7
+ <t-header><layout-header /></t-header>
8
+ <t-content><layout-content /></t-content>
9
+ </t-layout>
10
+ </t-layout>
11
+ </template>
12
+ <template v-else-if="setting.layout === 'top'">
13
+ <t-layout key="top">
14
+ <t-header> <layout-header /></t-header>
15
+ <t-content><layout-content /></t-content>
16
+ </t-layout>
17
+ </template>
18
+ <template v-else>
19
+ <t-layout key="mix">
20
+ <t-header><layout-header /></t-header>
21
+ <t-layout>
22
+ <t-aside><layout-sidebar /></t-aside>
23
+ <t-content><layout-content /></t-content>
24
+ </t-layout>
25
+ </t-layout>
26
+ </template>
27
+ <setting />
28
+ </div>
29
+ </template>
30
+
31
+ <script lang="ts">
32
+ import Vue from 'vue';
33
+ import { mapGetters } from 'vuex';
34
+
35
+ import LayoutHeader from './components/LayoutHeader.vue';
36
+ import LayoutContent from './components/LayoutContent.vue';
37
+ import LayoutSidebar from './components/LayoutSidebar.vue';
38
+ import Setting from './setting.vue';
39
+
40
+ import { prefix } from '@/config/global';
41
+ import { SettingType } from '@/interface';
42
+
43
+ import '@/style/layout.less';
44
+
45
+ const name = `${prefix}-base-layout`;
46
+
47
+ export default Vue.extend({
48
+ name,
49
+ components: {
50
+ LayoutHeader,
51
+ LayoutContent,
52
+ LayoutSidebar,
53
+ Setting,
54
+ },
55
+ computed: {
56
+ ...mapGetters({
57
+ tabRouterList: 'tabRouter/tabRouterList',
58
+ }),
59
+ setting(): SettingType {
60
+ return this.$store.state.setting;
61
+ },
62
+ },
63
+ watch: {
64
+ $route(newRoute) {
65
+ // 监听路由变化往多标签新增
66
+ const {
67
+ path,
68
+ meta: { title },
69
+ name,
70
+ } = newRoute;
71
+ this.$store.commit('tabRouter/appendTabRouterList', { path, title, name, isAlive: true });
72
+ },
73
+ },
74
+ // 如果不需要持久化标签页可以注释掉created和destroyed的内容
75
+ created() {
76
+ window.addEventListener('beforeunload', this.setTabRouterListCache);
77
+ },
78
+ destroyed() {
79
+ window.removeEventListener('beforeunload', this.setTabRouterListCache);
80
+ },
81
+ mounted() {
82
+ const {
83
+ path,
84
+ meta: { title },
85
+ name,
86
+ } = this.$route;
87
+
88
+ if (localStorage.getItem('tabRouterList')) this.getTabRouterListCache();
89
+ this.$store.commit('tabRouter/appendTabRouterList', { path, title, name, isAlive: true });
90
+ },
91
+ methods: {
92
+ getTabRouterListCache() {
93
+ this.$store.commit('tabRouter/initTabRouterList', JSON.parse(localStorage.getItem('tabRouterList')));
94
+ },
95
+ setTabRouterListCache() {
96
+ localStorage.setItem('tabRouterList', JSON.stringify(this.tabRouterList));
97
+ },
98
+ },
99
+ });
100
+ </script>