Skip to content

Commit 0f766b9

Browse files
author
shangbin
committed
feat: 增加文件部署能力
1 parent 4f4d69f commit 0f766b9

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/components/Code.vue

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,26 @@
66
<div style="color: #666; font-size: 12px; text-align:center; margin: 5px;">使用代码前请确认相应的组件库已集成至项目</div>
77
<div style="text-align:center;">
88
<el-row>
9-
<el-col :span="12">
9+
<el-col :span="10">
1010
输出形式:
1111
<el-radio-group v-model="outputMode">
1212
<el-radio label="vue">Vue</el-radio>
1313
<el-radio label="html">单页Html</el-radio>
1414
</el-radio-group>
15+
1516
</el-col>
16-
<el-col :span="12">
17+
<el-col :span="14" style="display: flex; align-items: center; justify-content: center;">
1718
<el-tooltip effect="dark" content="拷贝" placement="left">
1819
<img class="round-icon" :src="iconCopy" alt="" @click="copyCheck">
1920
</el-tooltip>
2021
<el-tooltip effect="dark" content="下载" placement="right">
2122
<img class="round-icon" :src="iconDownload" alt="" @click="download">
2223
</el-tooltip>
24+
<div style="display: inline-block;margin-left: 10px;">
25+
<el-button size="small" type="danger" :loading="loading" @click="release">
26+
一键部署至VCC静态页面托管服务</el-button>
27+
<div v-if="accessUrl">部署成功:<a :href="accessUrl" target="_blank">{{accessUrl}}</a></div>
28+
</div>
2329
</el-col>
2430
</el-row>
2531
</div>
@@ -36,6 +42,7 @@ import { saveAs } from "file-saver";
3642
3743
import CodeEditor from './CodeEditor.vue'
3844
import singleIndexOutput from '../libs/singleIndexOutput.js';
45+
import { createUniqueId } from '@/utils/common';
3946
4047
export default {
4148
props: ['rawCode', 'codeDialogVisible'],
@@ -49,6 +56,8 @@ export default {
4956
outputMode: "vue",
5057
iconCopy: ("https://static.imonkey.xueersi.com/download/vcc-resource/icon/copy-outline.svg"),
5158
iconDownload: ("https://static.imonkey.xueersi.com/download/vcc-resource/icon/code-download-outline.svg"),
59+
loading: false,
60+
accessUrl: ''
5261
};
5362
},
5463
beforeCreate() { },
@@ -59,9 +68,15 @@ export default {
5968
updated() { },
6069
destoryed() { },
6170
methods: {
62-
// 在此自动生成
63-
request() {
64-
// 网络请求,可选
71+
release() {
72+
this.loading = true;
73+
axios.post('https://apis.sahadev.tech/v1/file/upload', { "id": `index${createUniqueId()}`, "content": this.singleIndex }).then(res => {
74+
this.accessUrl = res.data.data;
75+
this.loading = false;
76+
}).catch(err => {
77+
this.loading = false;
78+
this.$message.error('发布失败,可能服务暂时不可用.');
79+
});
6580
},
6681
handleClose() {
6782
this.$emit("update:codeDialogVisible", false);

0 commit comments

Comments
 (0)