Skip to content

Commit e047b27

Browse files
author
潘卓然Y7000P
committed
【站点】【修复】【修复站点部分示例网络劫持问题】
1 parent 7a46bc7 commit e047b27

2 files changed

Lines changed: 16 additions & 26 deletions

File tree

website/src/utils/requesttemp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import axios from 'axios'
33
// 创建axios实例
44
const service = axios.create({
55
baseURL: '', // api的base_url
6-
timeout: 5000 // 请求超时时间
6+
timeout: 60000 // 请求超时时间
77
})
88

99
// respone拦截器

website/src/views/demo/index.vue

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
>
4343
<el-button
4444
size="mini"
45-
@click="handleFullscreen"
45+
@click="full"
4646
>
4747
<IconFont
4848
v-if="fullscreen"
@@ -103,6 +103,7 @@
103103
:value="code"
104104
:options="cmOptions"
105105
@input="onCmCodeChange"
106+
@ready="onCmReady"
106107
></codemirror>
107108
</div>
108109
</el-row>
@@ -203,7 +204,8 @@ import "@/styles/markdown.css";
203204
import "@/styles/prism.css";
204205
// import "@/styles/codemirror.css";
205206
206-
import { getHtml, getMarkdown } from "@/api/demo";
207+
// import { getHtml, getMarkdown } from "@/api/demo";
208+
import axios from 'axios';
207209
import IconFont from "@/components/IconFont/iconfront";
208210
209211
export default {
@@ -223,8 +225,6 @@ export default {
223225
split: isMobile() ? "vertical" : "horizontal",
224226
mobile: isMobile(),
225227
loading: true,
226-
curRouter: "unknow",
227-
oldRouter: "unknow",
228228
active: "code",
229229
code: "const a = 10",
230230
newCode: "const b = 10",
@@ -317,17 +317,17 @@ export default {
317317
}
318318
return mapMode;
319319
},
320+
full () {
321+
const full = !this.fullscreen;
322+
this.$emit('handleFullscreen', full);
323+
this.resetSize(full);
324+
},
320325
run () {
321326
this.oldCode = this.code;
322327
this.code = this.newCode;
323328
this.loading = true;
324329
this.resetCase(this.code);
325330
},
326-
handleFullscreen () {
327-
const full = !this.fullscreen;
328-
this.$emit('handleFullscreen', full);
329-
this.resetSize(full);
330-
},
331331
reset () {
332332
this.loading = true;
333333
this.resetSize(this.fullscreen);
@@ -369,19 +369,19 @@ export default {
369369
// var helpUrl = this.getHelpUrl(mode, file, first, second);
370370
371371
new Promise((resolve, reject) => {
372-
getHtml(url)
372+
axios.get(url)
373373
.then(response => {
374-
self.instanseObject = self.code = response;
374+
self.instanseObject = self.code = response.data;
375375
self.resetCase(code || self.code);
376-
resolve(response);
376+
resolve(response.data);
377377
})
378378
.catch(error => {
379379
reject(error);
380380
self.instanseObject = self.code = "网络请求出错,请检查网络!";
381381
});
382-
getMarkdown(apiUrl)
382+
axios.get(apiUrl)
383383
.then(response => {
384-
self.markdown = response;
384+
self.markdown = response.data;
385385
}).catch(() => {
386386
window.console.warn('暂无该示例的markdown说明,后续持续补充......');
387387
})
@@ -429,17 +429,11 @@ export default {
429429
}
430430
},
431431
onCmReady () {
432-
// this.reset();
432+
this.reset();
433433
},
434434
onCmFocus () { },
435435
onCmCodeChange (newCode) {
436436
this.newCode = newCode;
437-
438-
if (this.curRouter != this.oldRouter) {
439-
/* this.resetSize();
440-
this.resetHtml(undefined, undefined, undefined, undefined, newCode);
441-
this.curRouter = this.oldRouter; */
442-
}
443437
},
444438
markdownRendered () {
445439
this.$nextTick(() => {
@@ -459,14 +453,10 @@ export default {
459453
},
460454
mounted () {
461455
let vm = this;
462-
// self.reset();
463456
vm.markdownScrollbal = vm.$refs.markdownScrollbal;
464457
vm.markdownScrollBox = vm.markdownScrollbal.$el.querySelector(
465458
".el-scrollbar__wrap"
466459
);
467-
setTimeout(() => {
468-
vm.reset();
469-
}, 500);
470460
window.onresize = function temp () {
471461
vm.resetSize(vm.fullscreen);
472462
};

0 commit comments

Comments
 (0)