diff options
Diffstat (limited to 'doc/docs/.vuepress/components')
-rwxr-xr-x | doc/docs/.vuepress/components/YueCompiler.vue | 83 |
1 files changed, 61 insertions, 22 deletions
diff --git a/doc/docs/.vuepress/components/YueCompiler.vue b/doc/docs/.vuepress/components/YueCompiler.vue index 6b6042c..3a22d1c 100755 --- a/doc/docs/.vuepress/components/YueCompiler.vue +++ b/doc/docs/.vuepress/components/YueCompiler.vue | |||
@@ -1,21 +1,21 @@ | |||
1 | <template> | 1 | <template> |
2 | <div style="width: 100%; height: auto;"> | 2 | <div style="width: 100%; height: auto;"> |
3 | <div class="parent" style="background-color: #f5f7ff;"> | 3 | <div class="parent" style="background-color: #f5f7ff;"> |
4 | <div class="childL" style="height: 2.5em;"> | 4 | <div class="editor-section"> |
5 | <div class="childTitle">YueScript {{ info }}</div> | 5 | <div class="childTitle">YueScript {{ info }}</div> |
6 | <div class="editor-container" ref='yueEditor'> | ||
7 | <ClientOnly> | ||
8 | <prism-editor class="my-editor" v-model="code" :highlight="highlighterYue" @input="codeChanged($event)" line-numbers :readonly="readonly"></prism-editor> | ||
9 | </ClientOnly> | ||
10 | </div> | ||
6 | </div> | 11 | </div> |
7 | <div class="childR" style="height: 2.5em;"> | 12 | <div class="editor-section"> |
8 | <div class="childTitle">Lua</div> | 13 | <div class="childTitle">Lua</div> |
9 | </div> | 14 | <div class="editor-container"> |
10 | <div class="childL" ref='yueEditor' style="height: 30em;"> | 15 | <ClientOnly> |
11 | <ClientOnly> | 16 | <prism-editor class="my-editor" v-model="compiled" :highlight="highlighterLua" @input="codeChanged($event)" :line-numbers="isMobileLayout" readonly></prism-editor> |
12 | <prism-editor class="my-editor" v-model="code" :highlight="highlighterYue" @input="codeChanged($event)" line-numbers :readonly="readonly"></prism-editor> | 17 | </ClientOnly> |
13 | </ClientOnly> | 18 | </div> |
14 | </div> | ||
15 | <div class="childR" style="height: 30em;"> | ||
16 | <ClientOnly> | ||
17 | <prism-editor class="my-editor" v-model="compiled" :highlight="highlighterLua" @input="codeChanged($event)" readonly></prism-editor> | ||
18 | </ClientOnly> | ||
19 | </div> | 19 | </div> |
20 | </div> | 20 | </div> |
21 | <div v-if="!compileronly"> | 21 | <div v-if="!compileronly"> |
@@ -57,9 +57,18 @@ | |||
57 | code: '', | 57 | code: '', |
58 | compiled: '', | 58 | compiled: '', |
59 | result: '', | 59 | result: '', |
60 | windowWidth: 0, | ||
60 | }; | 61 | }; |
61 | }, | 62 | }, |
63 | computed: { | ||
64 | isMobileLayout() { | ||
65 | return this.windowWidth <= 768; | ||
66 | }, | ||
67 | }, | ||
62 | mounted () { | 68 | mounted () { |
69 | this.windowWidth = window.innerWidth; | ||
70 | window.addEventListener('resize', this.handleResize); | ||
71 | |||
63 | if (this.text !== '') { | 72 | if (this.text !== '') { |
64 | this.$data.code = this.text; | 73 | this.$data.code = this.text; |
65 | this.codeChanged(this.text); | 74 | this.codeChanged(this.text); |
@@ -86,7 +95,13 @@ | |||
86 | })(this); | 95 | })(this); |
87 | check(); | 96 | check(); |
88 | }, | 97 | }, |
98 | beforeDestroy() { | ||
99 | window.removeEventListener('resize', this.handleResize); | ||
100 | }, | ||
89 | methods: { | 101 | methods: { |
102 | handleResize() { | ||
103 | this.windowWidth = window.innerWidth; | ||
104 | }, | ||
90 | runCode() { | 105 | runCode() { |
91 | if (window.yue && this.$data.compiled !== '') { | 106 | if (window.yue && this.$data.compiled !== '') { |
92 | let res = ''; | 107 | let res = ''; |
@@ -136,27 +151,35 @@ | |||
136 | resize: none; | 151 | resize: none; |
137 | margin-top: 5px; | 152 | margin-top: 5px; |
138 | } | 153 | } |
139 | .childL { | 154 | |
140 | float: left; | 155 | .parent { |
141 | width: 50%; | 156 | display: flex; |
142 | box-sizing: border-box; | 157 | flex-wrap: wrap; |
143 | background-clip: content-box; | 158 | width: 100%; |
144 | background: #f5f7ff; | ||
145 | } | 159 | } |
146 | .childR { | 160 | |
147 | float: left; | 161 | .editor-section { |
148 | width: 50%; | 162 | width: 50%; |
149 | box-sizing: border-box; | 163 | box-sizing: border-box; |
150 | background-clip: content-box; | ||
151 | background: #f5f7ff; | 164 | background: #f5f7ff; |
152 | } | 165 | } |
166 | |||
167 | .editor-container { | ||
168 | height: 55vh; | ||
169 | } | ||
170 | |||
153 | .childTitle { | 171 | .childTitle { |
154 | width: 100%; | 172 | width: 100%; |
155 | font-size: 1.2em; | 173 | font-size: 1.2em; |
156 | color: #b7ae8f; | 174 | color: #b7ae8f; |
157 | text-align: center; | 175 | text-align: center; |
158 | padding: 0.2em; | 176 | padding: 0.2em; |
177 | height: 2.5em; | ||
178 | display: flex; | ||
179 | align-items: center; | ||
180 | justify-content: center; | ||
159 | } | 181 | } |
182 | |||
160 | .button { | 183 | .button { |
161 | float: right; | 184 | float: right; |
162 | border: none; | 185 | border: none; |
@@ -173,9 +196,11 @@ | |||
173 | margin-top: 10px; | 196 | margin-top: 10px; |
174 | margin-right: 5px; | 197 | margin-right: 5px; |
175 | } | 198 | } |
199 | |||
176 | .button:hover { | 200 | .button:hover { |
177 | background-color: #beb69a; | 201 | background-color: #beb69a; |
178 | } | 202 | } |
203 | |||
179 | .button:focus, | 204 | .button:focus, |
180 | .button:active:focus, | 205 | .button:active:focus, |
181 | .button.active:focus, | 206 | .button.active:focus, |
@@ -207,5 +232,19 @@ | |||
207 | .my-editor >>> .prism-editor__textarea:focus { | 232 | .my-editor >>> .prism-editor__textarea:focus { |
208 | outline: none; | 233 | outline: none; |
209 | } | 234 | } |
210 | </style> | ||
211 | 235 | ||
236 | /* 移动端响应式布局 */ | ||
237 | @media screen and (max-width: 768px) { | ||
238 | .parent { | ||
239 | flex-direction: column; | ||
240 | } | ||
241 | |||
242 | .editor-section { | ||
243 | width: 100%; | ||
244 | } | ||
245 | |||
246 | .editor-container { | ||
247 | height: 30vh; | ||
248 | } | ||
249 | } | ||
250 | </style> | ||