Skip to content

Commit 3441327

Browse files
committed
feat(app-preview): fix style
1 parent ef27d97 commit 3441327

2 files changed

Lines changed: 16 additions & 64 deletions

File tree

  • packages
    • toolbars/preview/src
    • vue-generator/src/templates/vue-template/templateFiles/src/http

packages/toolbars/preview/src/Main.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
<div class="toolbar-save toolbar-helpGuid">
33
<toolbar-base content="预览页面" :icon="options.icon?.default || options?.icon" :options="options" trigger="click">
44
<template #button>
5-
<div>
6-
<tiny-button type="text" @click="preview('page')">页面预览</tiny-button>
7-
<tiny-button type="text" @click="preview('app')">应用预览</tiny-button>
5+
<div class="toolbar-preview-item">
6+
<span @click="preview('page')">页面预览</span>
7+
<span @click="preview('app')">应用预览</span>
88
</div>
99
</template>
1010
</toolbar-base>
1111
</div>
1212
</template>
1313

1414
<script lang="ts">
15-
import { Button } from '@opentiny/vue'
1615
/* metaService: engine.toolbars.preview.Main */
1716
import { previewPage } from '@opentiny/tiny-engine-common/js/preview'
1817
import { useLayout, useNotify, getOptions } from '@opentiny/tiny-engine-meta-register'
@@ -21,8 +20,7 @@ import { ToolbarBase } from '@opentiny/tiny-engine-common'
2120
2221
export default {
2322
components: {
24-
ToolbarBase,
25-
TinyButton: Button
23+
ToolbarBase
2624
},
2725
props: {
2826
options: {
@@ -81,3 +79,15 @@ export default {
8179
}
8280
}
8381
</script>
82+
<style lang="less" scoped>
83+
.toolbar-preview-item {
84+
display: flex;
85+
justify-content: center;
86+
flex-direction: column;
87+
gap: 8px;
88+
89+
span {
90+
cursor: pointer;
91+
}
92+
}
93+
</style>

packages/vue-generator/src/templates/vue-template/templateFiles/src/http/axios.js

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,10 @@
1111
*/
1212

1313
import axios from 'axios'
14-
import MockAdapter from 'axios-mock-adapter'
1514

1615
export default (config) => {
1716
const instance = axios.create(config)
1817
const defaults = {}
19-
let mock
20-
21-
if (typeof MockAdapter.prototype.proxy === 'undefined') {
22-
MockAdapter.prototype.proxy = function ({ url, config = {}, proxy, response, handleData } = {}) {
23-
// eslint-disable-next-line @typescript-eslint/no-this-alias
24-
let stream = this
25-
const request = (proxy, any) => {
26-
return (setting) => {
27-
return new Promise((resolve) => {
28-
config.responseType = 'json'
29-
axios
30-
.get(any ? proxy + setting.url + '.json' : proxy, config)
31-
.then(({ data }) => {
32-
if (typeof handleData === 'function') {
33-
data = handleData.call(null, data, setting)
34-
}
35-
resolve([200, data])
36-
})
37-
.catch((error) => {
38-
resolve([error.response.status, error.response.data])
39-
})
40-
})
41-
}
42-
}
43-
44-
if (url === '*' && proxy && typeof proxy === 'string') {
45-
stream = proxy === '*' ? this.onAny().passThrough() : this.onAny().reply(request(proxy, true))
46-
} else {
47-
if (proxy && typeof proxy === 'string') {
48-
stream = this.onAny(url).reply(request(proxy))
49-
} else if (typeof response === 'function') {
50-
stream = this.onAny(url).reply(response)
51-
}
52-
}
53-
54-
return stream
55-
}
56-
}
5718

5819
return {
5920
request(config) {
@@ -115,25 +76,6 @@ export default (config) => {
11576
}
11677
}
11778
},
118-
mock(config) {
119-
if (!mock) {
120-
mock = new MockAdapter(instance)
121-
}
122-
123-
if (Array.isArray(config)) {
124-
config.forEach((item) => {
125-
mock.proxy(item)
126-
})
127-
}
128-
129-
return mock
130-
},
131-
disableMock() {
132-
if (mock) {
133-
mock.restore()
134-
}
135-
mock = undefined
136-
},
13779
isMock() {
13880
return typeof mock !== 'undefined'
13981
},

0 commit comments

Comments
 (0)