diff --git a/src/components/Code.vue b/src/components/Code.vue index 6f80621..3bb0598 100644 --- a/src/components/Code.vue +++ b/src/components/Code.vue @@ -6,20 +6,26 @@
使用代码前请确认相应的组件库已集成至项目
- + 输出形式: Vue 单页Html + - + +
+ + 一键部署至VCC静态页面托管服务 +
部署成功:{{accessUrl}}
+
@@ -36,6 +42,7 @@ import { saveAs } from "file-saver"; import CodeEditor from './CodeEditor.vue' import singleIndexOutput from '../libs/singleIndexOutput.js'; +import { createUniqueId } from '@/utils/common'; export default { props: ['rawCode', 'codeDialogVisible'], @@ -49,6 +56,8 @@ export default { outputMode: "vue", iconCopy: ("https://static.imonkey.xueersi.com/download/vcc-resource/icon/copy-outline.svg"), iconDownload: ("https://static.imonkey.xueersi.com/download/vcc-resource/icon/code-download-outline.svg"), + loading: false, + accessUrl: '' }; }, beforeCreate() { }, @@ -59,9 +68,15 @@ export default { updated() { }, destoryed() { }, methods: { - // 在此自动生成 - request() { - // 网络请求,可选 + release() { + this.loading = true; + axios.post('https://apis.sahadev.tech/v1/file/upload', { "id": `index${createUniqueId()}`, "content": this.singleIndex }).then(res => { + this.accessUrl = res.data.data; + this.loading = false; + }).catch(err => { + this.loading = false; + this.$message.error('发布失败,可能服务暂时不可用.'); + }); }, handleClose() { this.$emit("update:codeDialogVisible", false);