UNPKG

6.05 kBPlain TextView Raw
1<template>
2 <div class="k-view-container">
3 <header class="k-view-header">
4 <span class="k-view-title">K-View</span>
5 <span class="lang-bar">
6 <el-select
7 v-model="tab"
8 size="mini"
9 style="width:100px;"
10 placeholder="请选择"
11 >
12 <el-option
13 v-for="item in options"
14 :key="item.value"
15 :label="item.label"
16 :value="item.value"
17 />
18 </el-select>
19 </span>
20 </header>
21 <section class="k-view-content">
22 <section class="section-nav">
23 <k-side-nav
24 :data-source="menuData"
25 label-key="name"
26 value-key="pathKey"
27 router
28 :default-active="$route.path"
29 :default-openeds="['components']"
30 />
31 </section>
32 <section class="section-box">
33 <k-provider :locale="locale">
34 <router-view />
35 </k-provider>
36 </section>
37 </section>
38 <footer class="k-view-footer">
39 @copyright 2020
40 </footer>
41 </div>
42</template>
43
44<script>
45import { langRouteMap } from "./router";
46import enUS from "../src/locale/lang/en-US";
47import zhCN from "../src/locale/lang/zh-CN";
48
49const lang = {
50 "en-US":enUS,
51 "zh-CN": zhCN,
52};
53
54const menuDataMap = {
55 "en-US": [
56 {
57 name: "quick-start",
58 pathKey:''
59 },
60 {
61 name: "components",
62 pathKey: "components",
63 children: langRouteMap['en-US'].filter(item=>item.name!=='quick-start'),
64 },
65 ],
66 "zh-CN": [
67 {
68 name: "快速开始",
69 pathKey:'zh-CN'
70 },
71 {
72 name: "组件",
73 pathKey: "components",
74 children: langRouteMap['zh-CN'].filter(item=>item.name!=='quick-start'),
75 },
76 ],
77};
78
79export default {
80 data() {
81 const menuData = menuDataMap["en-US"];
82 let markKey = 0;
83 return {
84 markKey,
85 menuData,
86 options: [
87 {
88 label: "En",
89 value: "en-US",
90 },
91 {
92 label: "中文",
93 value: "zh-CN",
94 },
95 ],
96 tab: "en-US",
97 locale:lang['en-US'],
98 isRouteAlive: true,
99 };
100 },
101 watch: {
102 tab(val) {
103 this.toggleLang(val);
104 },
105 },
106 methods: {
107 toggleExpand(node) {
108 console.log("toggleExpand", node);
109 },
110 selectChange(node) {
111 console.log("selectChange", node);
112 },
113 toggleLang(val) {
114 this.locale = lang[val];
115 this.menuData = menuDataMap[val];
116 const [,,compPath] = this.$route.path.split('/')
117 this.$router.push(`/${val}/${compPath||''}`)
118 },
119 },
120};
121</script>
122
123<style lang="scss">
124body {
125 margin: 0;
126 padding: 0;
127}
128.k-view-container {
129 $k-view-header-footer-height: 60px;
130 height: 100%;
131 background: $bg-base;
132 @mixin k-view-box {
133 height: $k-view-header-footer-height;
134 width: 100%;
135 display: flex;
136 align-items: center;
137 justify-content: center;
138 border: 2px solid #f5f5f5;
139 position: fixed;
140 left: 0;
141 z-index: 900;
142 background: $bg-base;
143 }
144 .k-view-header {
145 @include k-view-box;
146 top: 0;
147 .k-view-title {
148 font-size: 24px;
149 }
150 .lang-bar {
151 position: absolute;
152 right: 20px;
153 }
154 }
155 .k-view-footer {
156 @include k-view-box;
157 bottom: 0;
158 }
159 .k-view-content {
160 padding: $k-view-header-footer-height 10px;
161 position: relative;
162 max-width: 1400px;
163 width: 75%;
164 margin: 0 auto;
165 overflow: auto;
166 .section-nav {
167 width: 300px;
168 position: fixed;
169 top:0;
170 padding: $k-view-header-footer-height 10px;
171 height: 100%;
172 background: white;
173 }
174 .section-box {
175 padding: 20px 20px 20px 330px;
176 border: 1px solid $border-color-light;
177 height: 100%;
178 .content {
179 h1,
180 h2,
181 h3,
182 h4 {
183 font-weight: 300;
184 font-family: $font-family;
185 }
186 }
187 color: #0d1a26;
188 @mixin md-h {
189 font-family: Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI",
190 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
191 Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
192 "Segoe UI Symbol";
193 font-variant: tabular-nums;
194 margin: 1.6em 0 0.6em;
195 font-weight: 500;
196 clear: both;
197 }
198 h1 {
199 @include md-h;
200 font-size: $font-size-h1;
201 }
202 h2 {
203 @include md-h;
204 font-size: $font-size-h2;
205 }
206 h3 {
207 @include md-h;
208 font-size: $font-size-h3;
209 }
210 .markdown-table table {
211 border-collapse: collapse;
212 border-spacing: 0;
213 empty-cells: show;
214 border: 1px solid #ebedf0;
215 width: 100%;
216 margin: 8px 0 16px;
217 th {
218 border: 1px solid #ebedf0;
219 padding: 14px 16px;
220 text-align: left;
221 white-space: nowrap;
222 color: #5c6b77;
223 font-weight: 500;
224 background: rgba(0, 0, 0, 0.02);
225 }
226 tr {
227 border-bottom: 1px solid #e8e8e8;
228 }
229 td {
230 padding: 14px 16px;
231 border-width: 1px 0;
232 border-color: #e8e8e8;
233 }
234 td:first-child {
235 font-weight: 500;
236 width: 20%;
237 color: #003a8c;
238 }
239 }
240 .hljs {
241 background: white;
242 }
243 }
244 }
245
246 .router-tag {
247 margin: 10px;
248 border-radius: 10px;
249 }
250
251 .pre-code {
252 font-family: "Lucida Console", Consolas, Monaco, "Andale Mono",
253 "Ubuntu Mono", monospace;
254 text-align: left;
255 white-space: pre;
256 word-spacing: normal;
257 word-break: normal;
258 word-wrap: normal;
259 line-height: 1.5;
260 -moz-tab-size: 4;
261 -o-tab-size: 4;
262 tab-size: 4;
263 -webkit-hyphens: none;
264 -ms-hyphens: none;
265 hyphens: none;
266 }
267
268 * {
269 margin: 0;
270 padding: 0;
271 box-sizing: border-box;
272 }
273 .fl {
274 float: left;
275 }
276 .clearfix {
277 content: "";
278 display: block;
279 overflow: hidden;
280 clear: both;
281 }
282 .clearfix:after {
283 zoom: 1;
284 }
285 ul,
286 li {
287 list-style: none;
288 }
289}
290</style>
291
292