add
This commit is contained in:
@@ -52,3 +52,21 @@ export function transToArticle1(codeId, templateId) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 将复制网站文案同步到博客网站
|
||||
export function syncWebsite(codeId) {
|
||||
return request({
|
||||
url: '/office/code/syncWebsite/' + codeId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
// 下载项目在文件管理中关联的全部截图
|
||||
export function downloadScreenshots(codeId) {
|
||||
return request({
|
||||
url: '/office/code/screenshots/' + codeId + '/download',
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
timeout: 120000
|
||||
})
|
||||
}
|
||||
|
||||
@@ -96,6 +96,19 @@
|
||||
>导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
:disabled="single || downloadingScreenshots"
|
||||
:loading="downloadingScreenshots"
|
||||
@click="handleDownloadScreenshots"
|
||||
v-hasPermi="['office:code:export']"
|
||||
>下载截图
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@@ -121,7 +134,17 @@
|
||||
icon="el-icon-document-copy"
|
||||
@click="showCoverDialog(scope.row)"
|
||||
v-hasPermi="['office:code:edit']"
|
||||
>转文章(南音)
|
||||
>同步小程序
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-upload2"
|
||||
:loading="syncingCodeId === scope.row.codeId"
|
||||
:disabled="syncingCodeId !== null"
|
||||
@click="handleSyncWebsite(scope.row)"
|
||||
v-hasPermi="['office:code:edit']"
|
||||
>同步网站
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
@@ -284,10 +307,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {listCode, getCode, delCode, addCode, updateCode, transToArticle1} from "@/api/office/code";
|
||||
import {listCode, getCode, delCode, addCode, updateCode, transToArticle1, syncWebsite, downloadScreenshots} from "@/api/office/code";
|
||||
import {listEnabledTemplates} from "@/api/office/copyTemplate";
|
||||
import {html2Text} from "../../../utils";
|
||||
import {getToken} from "@/utils/auth";
|
||||
import {blobValidate} from "@/utils/ruoyi";
|
||||
|
||||
export default {
|
||||
name: "Code",
|
||||
@@ -299,6 +323,8 @@
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 当前选中的源码项目
|
||||
selectedCode: null,
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
@@ -346,7 +372,11 @@
|
||||
// 文案模板列表(动态按钮)
|
||||
copyTemplates: [],
|
||||
// 转文章时使用的文案模板
|
||||
articleTemplateId: null
|
||||
articleTemplateId: null,
|
||||
// 正在同步网站的源码ID,防止重复点击
|
||||
syncingCodeId: null,
|
||||
// 是否正在打包下载项目截图
|
||||
downloadingScreenshots: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -489,9 +519,34 @@
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.codeId)
|
||||
this.selectedCode = selection.length === 1 ? selection[0] : null
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 下载所选项目在文件管理中的全部截图 */
|
||||
handleDownloadScreenshots() {
|
||||
if (!this.selectedCode || this.downloadingScreenshots) {
|
||||
return
|
||||
}
|
||||
const selectedCode = this.selectedCode
|
||||
this.downloadingScreenshots = true
|
||||
downloadScreenshots(selectedCode.codeId).then(async data => {
|
||||
if (!blobValidate(data)) {
|
||||
await this.$download.printErrMsg(data)
|
||||
return
|
||||
}
|
||||
const safeProjectName = (selectedCode.codeName || '项目')
|
||||
.replace(/[\\/:*?"<>|\x00-\x1F]/g, '_')
|
||||
.replace(/[. ]+$/g, '') || '项目'
|
||||
const archive = new Blob([data], {type: 'application/zip'})
|
||||
this.$download.saveAs(archive, safeProjectName + '截图.zip')
|
||||
this.$modal.msgSuccess('项目截图已开始下载')
|
||||
}).catch(error => {
|
||||
console.error('下载项目截图失败:', error)
|
||||
}).finally(() => {
|
||||
this.downloadingScreenshots = false
|
||||
})
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
@@ -594,6 +649,19 @@
|
||||
});
|
||||
this.coverDialogVisible = false;
|
||||
},
|
||||
/** 同步网站 */
|
||||
handleSyncWebsite(row) {
|
||||
const codeId = row.codeId;
|
||||
this.$modal.confirm('确认将“' + row.codeName + '”同步并发布到网站?').then(() => {
|
||||
this.syncingCodeId = codeId;
|
||||
return syncWebsite(codeId);
|
||||
}).then(response => {
|
||||
this.$modal.msgSuccess(response.msg);
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.syncingCodeId = null;
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
|
||||
Reference in New Issue
Block a user