mirror of https://github.com/halo-dev/halo-admin
Refactor upload component.
parent
e5ac8df1bd
commit
ae98ef7351
|
@ -13,6 +13,8 @@
|
||||||
"ant-design-vue": "^1.3.16",
|
"ant-design-vue": "^1.3.16",
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"enquire.js": "^2.1.6",
|
"enquire.js": "^2.1.6",
|
||||||
|
"filepond": "^4.6.1",
|
||||||
|
"filepond-plugin-image-preview": "^4.4.0",
|
||||||
"halo-editor": "^2.7.6",
|
"halo-editor": "^2.7.6",
|
||||||
"marked": "^0.6.3",
|
"marked": "^0.6.3",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
|
@ -22,6 +24,7 @@
|
||||||
"vue-clipboard2": "^0.3.0",
|
"vue-clipboard2": "^0.3.0",
|
||||||
"vue-codemirror-lite": "^1.0.4",
|
"vue-codemirror-lite": "^1.0.4",
|
||||||
"vue-count-to": "^1.0.13",
|
"vue-count-to": "^1.0.13",
|
||||||
|
"vue-filepond": "^5.1.3",
|
||||||
"vue-ls": "^3.2.1",
|
"vue-ls": "^3.2.1",
|
||||||
"vue-router": "^3.1.2",
|
"vue-router": "^3.1.2",
|
||||||
"vue-video-player": "^5.0.2",
|
"vue-video-player": "^5.0.2",
|
||||||
|
|
|
@ -6,7 +6,7 @@ const backupApi = {}
|
||||||
|
|
||||||
backupApi.importMarkdown = (formData, uploadProgress, cancelToken) => {
|
backupApi.importMarkdown = (formData, uploadProgress, cancelToken) => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/import/markdowns`,
|
url: `${baseUrl}/import/markdown`,
|
||||||
timeout: 8640000, // 24 hours
|
timeout: 8640000, // 24 hours
|
||||||
data: formData, // form data
|
data: formData, // form data
|
||||||
onUploadProgress: uploadProgress,
|
onUploadProgress: uploadProgress,
|
||||||
|
|
|
@ -66,6 +66,13 @@ postApi.delete = postId => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postApi.preview = postId => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/preview/${postId}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
postApi.postStatus = {
|
postApi.postStatus = {
|
||||||
PUBLISHED: {
|
PUBLISHED: {
|
||||||
color: 'green',
|
color: 'green',
|
||||||
|
|
|
@ -61,6 +61,13 @@ sheetApi.delete = sheetId => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sheetApi.preview = sheetId => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/preview/${sheetId}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
sheetApi.sheetStatus = {
|
sheetApi.sheetStatus = {
|
||||||
PUBLISHED: {
|
PUBLISHED: {
|
||||||
color: 'green',
|
color: 'green',
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<file-pond
|
||||||
|
ref="pond"
|
||||||
|
:label-idle="label"
|
||||||
|
:name="name"
|
||||||
|
:allow-multiple="multiple"
|
||||||
|
:allowRevert="false"
|
||||||
|
:accepted-file-types="accept"
|
||||||
|
:maxParallelUploads="options.attachment_upload_max_parallel_uploads"
|
||||||
|
:allowImagePreview="options.attachment_upload_image_preview_enable"
|
||||||
|
:maxFiles="options.attachment_upload_max_files"
|
||||||
|
labelFileProcessing="上传中"
|
||||||
|
labelFileProcessingComplete="上传完成"
|
||||||
|
labelFileProcessingAborted="取消上传"
|
||||||
|
labelFileProcessingError="上传错误"
|
||||||
|
labelTapToCancel="点击取消"
|
||||||
|
labelTapToRetry="点击重试"
|
||||||
|
:files="fileList"
|
||||||
|
:server="server"
|
||||||
|
@init="handleFilePondInit"
|
||||||
|
>
|
||||||
|
</file-pond>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
import vueFilePond from 'vue-filepond'
|
||||||
|
import 'filepond/dist/filepond.min.css'
|
||||||
|
|
||||||
|
// Plugins
|
||||||
|
import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
|
||||||
|
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css'
|
||||||
|
|
||||||
|
// Create component and regist plugins
|
||||||
|
const FilePond = vueFilePond(FilePondPluginImagePreview)
|
||||||
|
export default {
|
||||||
|
name: 'FilePondUpload',
|
||||||
|
components: {
|
||||||
|
FilePond
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: 'file'
|
||||||
|
},
|
||||||
|
filed: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
multiple: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
accept: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: '点击选择文件或将文件拖拽到此处'
|
||||||
|
},
|
||||||
|
uploadHandler: {
|
||||||
|
type: Function,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: function() {
|
||||||
|
return {
|
||||||
|
server: {
|
||||||
|
process: (fieldName, file, metadata, load, error, progress, abort) => {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append(fieldName, file, file.name)
|
||||||
|
|
||||||
|
const CancelToken = axios.CancelToken
|
||||||
|
const source = CancelToken.source()
|
||||||
|
|
||||||
|
this.uploadHandler(
|
||||||
|
formData,
|
||||||
|
progressEvent => {
|
||||||
|
if (progressEvent.total > 0) {
|
||||||
|
progress(progressEvent.lengthComputable, progressEvent.loaded, progressEvent.total)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
source.token,
|
||||||
|
this.filed,
|
||||||
|
file
|
||||||
|
)
|
||||||
|
.then(response => {
|
||||||
|
load(response)
|
||||||
|
this.$log.debug('Uploaded successfully', response)
|
||||||
|
this.$emit('success', response, file)
|
||||||
|
})
|
||||||
|
.catch(failure => {
|
||||||
|
this.$log.debug('Failed to upload file', failure)
|
||||||
|
this.$emit('failure', failure, file)
|
||||||
|
error()
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
abort: () => {
|
||||||
|
abort()
|
||||||
|
this.$log.debug('Upload operation aborted by the user')
|
||||||
|
source.cancel('Upload operation canceled by the user.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fileList: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['options'])
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleFilePondInit() {
|
||||||
|
console.log('FilePond has initialized')
|
||||||
|
},
|
||||||
|
handleClearFileList() {
|
||||||
|
this.$refs.pond.removeFiles()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
</style>
|
|
@ -1,110 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<a-upload-dragger
|
|
||||||
v-if="draggable"
|
|
||||||
:name="name"
|
|
||||||
:accept="accept"
|
|
||||||
:customRequest="handleUpload"
|
|
||||||
:remove="handleRemove"
|
|
||||||
@change="handleChange"
|
|
||||||
>
|
|
||||||
<slot
|
|
||||||
role="button"
|
|
||||||
class="ant-upload ant-upload-btn"
|
|
||||||
/>
|
|
||||||
</a-upload-dragger>
|
|
||||||
<a-upload
|
|
||||||
v-else
|
|
||||||
:name="name"
|
|
||||||
:accept="accept"
|
|
||||||
:customRequest="handleUpload"
|
|
||||||
:remove="handleRemove"
|
|
||||||
@change="handleChange"
|
|
||||||
>
|
|
||||||
<slot />
|
|
||||||
</a-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'UpdateTheme',
|
|
||||||
props: {
|
|
||||||
name: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'file'
|
|
||||||
},
|
|
||||||
themeId: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
draggable: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
uploadHandler: {
|
|
||||||
type: Function,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleChange(info) {
|
|
||||||
this.$emit('change', info)
|
|
||||||
},
|
|
||||||
handleRemove(file) {
|
|
||||||
this.$log.debug('Removed file', file)
|
|
||||||
this.$emit('remove', file)
|
|
||||||
},
|
|
||||||
handleUpload(option) {
|
|
||||||
this.$log.debug('Uploading option', option)
|
|
||||||
const CancelToken = axios.CancelToken
|
|
||||||
const source = CancelToken.source()
|
|
||||||
|
|
||||||
const data = new FormData()
|
|
||||||
data.append(this.name, option.file)
|
|
||||||
|
|
||||||
this.uploadHandler(
|
|
||||||
data,
|
|
||||||
progressEvent => {
|
|
||||||
if (progressEvent.total > 0) {
|
|
||||||
progressEvent.percent = (progressEvent.loaded / progressEvent.total) * 100
|
|
||||||
}
|
|
||||||
this.$log.debug('Uploading percent: ', progressEvent.percent)
|
|
||||||
option.onProgress(progressEvent)
|
|
||||||
},
|
|
||||||
source.token,
|
|
||||||
this.themeId,
|
|
||||||
option.file
|
|
||||||
)
|
|
||||||
.then(response => {
|
|
||||||
this.$log.debug('Uploaded successfully', response)
|
|
||||||
option.onSuccess(response, option.file)
|
|
||||||
this.$emit('success', response, option.file)
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$log.debug('Failed to upload file', error)
|
|
||||||
option.onError(error, error.response)
|
|
||||||
this.$emit('failure', error, option.file)
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
abort: () => {
|
|
||||||
this.$log.debug('Upload operation aborted by the user')
|
|
||||||
source.cancel('Upload operation canceled by the user.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
|
@ -4,13 +4,13 @@ import Vue from 'vue'
|
||||||
import Ellipsis from '@/components/Ellipsis'
|
import Ellipsis from '@/components/Ellipsis'
|
||||||
import FooterToolbar from '@/components/FooterToolbar'
|
import FooterToolbar from '@/components/FooterToolbar'
|
||||||
import Upload from '@/components/Upload/Upload'
|
import Upload from '@/components/Upload/Upload'
|
||||||
import UpdateTheme from '@/components/Upload/UpdateTheme'
|
import FilePondUpload from '@/components/Upload/FilePondUpload'
|
||||||
|
|
||||||
const _components = {
|
const _components = {
|
||||||
Ellipsis,
|
Ellipsis,
|
||||||
FooterToolbar,
|
FooterToolbar,
|
||||||
Upload,
|
Upload,
|
||||||
UpdateTheme
|
FilePondUpload
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = {}
|
const components = {}
|
||||||
|
|
|
@ -3,7 +3,12 @@ import {
|
||||||
OPTIONS
|
OPTIONS
|
||||||
} from '@/store/mutation-types'
|
} from '@/store/mutation-types'
|
||||||
import optionApi from '@/api/option'
|
import optionApi from '@/api/option'
|
||||||
const keys = ['blog_url']
|
const keys = [
|
||||||
|
'blog_url',
|
||||||
|
'attachment_upload_image_preview_enable',
|
||||||
|
'attachment_upload_max_parallel_uploads',
|
||||||
|
'attachment_upload_max_files'
|
||||||
|
]
|
||||||
const option = {
|
const option = {
|
||||||
state: {
|
state: {
|
||||||
options: []
|
options: []
|
||||||
|
|
|
@ -136,18 +136,12 @@
|
||||||
v-model="uploadVisible"
|
v-model="uploadVisible"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
:afterClose="onUploadClose"
|
:afterClose="onUploadClose"
|
||||||
|
destroyOnClose
|
||||||
>
|
>
|
||||||
<upload
|
<FilePondUpload
|
||||||
name="file"
|
ref="upload"
|
||||||
multiple
|
|
||||||
:uploadHandler="uploadHandler"
|
:uploadHandler="uploadHandler"
|
||||||
>
|
></FilePondUpload>
|
||||||
<p class="ant-upload-drag-icon">
|
|
||||||
<a-icon type="inbox" />
|
|
||||||
</p>
|
|
||||||
<p class="ant-upload-text">点击选择文件或将文件拖拽到此处</p>
|
|
||||||
<p class="ant-upload-hint">支持单个或批量上传</p>
|
|
||||||
</upload>
|
|
||||||
</a-modal>
|
</a-modal>
|
||||||
<AttachmentDetailDrawer
|
<AttachmentDetailDrawer
|
||||||
v-model="drawerVisible"
|
v-model="drawerVisible"
|
||||||
|
@ -193,8 +187,8 @@ export default {
|
||||||
mediaType: null,
|
mediaType: null,
|
||||||
attachmentType: null
|
attachmentType: null
|
||||||
},
|
},
|
||||||
uploadHandler: attachmentApi.upload,
|
drawerVisible: false,
|
||||||
drawerVisible: false
|
uploadHandler: attachmentApi.upload
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -260,6 +254,7 @@ export default {
|
||||||
this.loadAttachments()
|
this.loadAttachments()
|
||||||
},
|
},
|
||||||
onUploadClose() {
|
onUploadClose() {
|
||||||
|
this.$refs.upload.handleClearFileList()
|
||||||
this.loadAttachments()
|
this.loadAttachments()
|
||||||
this.loadMediaTypes()
|
this.loadMediaTypes()
|
||||||
},
|
},
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
:attachment="selectedAttachment"
|
:attachment="selectedAttachment"
|
||||||
@delete="handleDelete"
|
@delete="handleDelete"
|
||||||
/>
|
/>
|
||||||
<a-divider class="divider-transparent"/>
|
<a-divider class="divider-transparent" />
|
||||||
<div class="bottom-control">
|
<div class="bottom-control">
|
||||||
<a-button
|
<a-button
|
||||||
@click="handleShowUploadModal"
|
@click="handleShowUploadModal"
|
||||||
|
@ -70,18 +70,12 @@
|
||||||
v-model="uploadVisible"
|
v-model="uploadVisible"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
:afterClose="onUploadClose"
|
:afterClose="onUploadClose"
|
||||||
|
destroyOnClose
|
||||||
>
|
>
|
||||||
<upload
|
<FilePondUpload
|
||||||
name="file"
|
ref="upload"
|
||||||
multiple
|
:uploadHandler="uploadHandler"
|
||||||
:uploadHandler="attachmentUploadHandler"
|
></FilePondUpload>
|
||||||
>
|
|
||||||
<p class="ant-upload-drag-icon">
|
|
||||||
<a-icon type="inbox" />
|
|
||||||
</p>
|
|
||||||
<p class="ant-upload-text">点击选择文件或将文件拖拽到此处</p>
|
|
||||||
<p class="ant-upload-hint">支持单个或批量上传</p>
|
|
||||||
</upload>
|
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -128,7 +122,7 @@ export default {
|
||||||
},
|
},
|
||||||
attachments: [],
|
attachments: [],
|
||||||
selectedAttachment: {},
|
selectedAttachment: {},
|
||||||
attachmentUploadHandler: attachmentApi.upload
|
uploadHandler: attachmentApi.upload
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -183,6 +177,7 @@ export default {
|
||||||
this.loadAttachments()
|
this.loadAttachments()
|
||||||
},
|
},
|
||||||
onUploadClose() {
|
onUploadClose() {
|
||||||
|
this.$refs.upload.handleClearFileList()
|
||||||
this.loadSkeleton()
|
this.loadSkeleton()
|
||||||
this.loadAttachments()
|
this.loadAttachments()
|
||||||
},
|
},
|
||||||
|
|
|
@ -67,18 +67,12 @@
|
||||||
v-model="uploadVisible"
|
v-model="uploadVisible"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
:afterClose="onUploadClose"
|
:afterClose="onUploadClose"
|
||||||
|
destroyOnClose
|
||||||
>
|
>
|
||||||
<upload
|
<FilePondUpload
|
||||||
name="file"
|
ref="upload"
|
||||||
multiple
|
:uploadHandler="uploadHandler"
|
||||||
:uploadHandler="attachmentUploadHandler"
|
></FilePondUpload>
|
||||||
>
|
|
||||||
<p class="ant-upload-drag-icon">
|
|
||||||
<a-icon type="inbox" />
|
|
||||||
</p>
|
|
||||||
<p class="ant-upload-text">点击选择文件或将文件拖拽到此处</p>
|
|
||||||
<p class="ant-upload-hint">支持单个或批量上传</p>
|
|
||||||
</upload>
|
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -126,7 +120,7 @@ export default {
|
||||||
sort: ''
|
sort: ''
|
||||||
},
|
},
|
||||||
attachments: [],
|
attachments: [],
|
||||||
attachmentUploadHandler: attachmentApi.upload
|
uploadHandler: attachmentApi.upload
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -174,6 +168,7 @@ export default {
|
||||||
this.loadAttachments()
|
this.loadAttachments()
|
||||||
},
|
},
|
||||||
onUploadClose() {
|
onUploadClose() {
|
||||||
|
this.$refs.upload.handleClearFileList()
|
||||||
this.loadSkeleton()
|
this.loadSkeleton()
|
||||||
this.loadAttachments()
|
this.loadAttachments()
|
||||||
},
|
},
|
||||||
|
|
|
@ -235,6 +235,7 @@
|
||||||
:title="'回复给:'+selectComment.author"
|
:title="'回复给:'+selectComment.author"
|
||||||
v-model="replyCommentVisible"
|
v-model="replyCommentVisible"
|
||||||
@close="onReplyClose"
|
@close="onReplyClose"
|
||||||
|
destroyOnClose
|
||||||
>
|
>
|
||||||
<template slot="footer">
|
<template slot="footer">
|
||||||
<a-button
|
<a-button
|
||||||
|
|
|
@ -162,8 +162,10 @@
|
||||||
<a-modal
|
<a-modal
|
||||||
title="安装主题"
|
title="安装主题"
|
||||||
v-model="uploadThemeVisible"
|
v-model="uploadThemeVisible"
|
||||||
|
destroyOnClose
|
||||||
:footer="null"
|
:footer="null"
|
||||||
:bodyStyle="{ padding: '0 24px 24px' }"
|
:bodyStyle="{ padding: '0 24px 24px' }"
|
||||||
|
:afterClose="onThemeUploadClose"
|
||||||
>
|
>
|
||||||
<div class="custom-tab-wrapper">
|
<div class="custom-tab-wrapper">
|
||||||
<a-tabs>
|
<a-tabs>
|
||||||
|
@ -201,20 +203,15 @@
|
||||||
tab="本地上传"
|
tab="本地上传"
|
||||||
key="2"
|
key="2"
|
||||||
>
|
>
|
||||||
<upload
|
<FilePondUpload
|
||||||
|
ref="upload"
|
||||||
name="file"
|
name="file"
|
||||||
multiple
|
|
||||||
accept="application/zip"
|
accept="application/zip"
|
||||||
|
label="点击选择主题包或将主题包拖拽到此处<br>仅支持 ZIP 格式的文件"
|
||||||
:uploadHandler="uploadHandler"
|
:uploadHandler="uploadHandler"
|
||||||
@change="handleUploadChange"
|
|
||||||
@success="handleUploadSuccess"
|
@success="handleUploadSuccess"
|
||||||
>
|
>
|
||||||
<p class="ant-upload-drag-icon">
|
</FilePondUpload>
|
||||||
<a-icon type="inbox" />
|
|
||||||
</p>
|
|
||||||
<p class="ant-upload-text">点击选择主题包或将主题包拖拽到此处</p>
|
|
||||||
<p class="ant-upload-hint">支持单个或批量上传,仅支持 ZIP 格式的文件</p>
|
|
||||||
</upload>
|
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
@ -223,21 +220,20 @@
|
||||||
title="更新主题"
|
title="更新主题"
|
||||||
v-model="uploadNewThemeVisible"
|
v-model="uploadNewThemeVisible"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
|
destroyOnClose
|
||||||
|
:afterClose="onThemeUploadClose"
|
||||||
>
|
>
|
||||||
<UpdateTheme
|
<FilePondUpload
|
||||||
|
ref="updateByupload"
|
||||||
name="file"
|
name="file"
|
||||||
:themeId="prepareUpdateTheme.id"
|
|
||||||
accept="application/zip"
|
accept="application/zip"
|
||||||
|
label="点击选择主题更新包或将主题更新包拖拽到此处<br>仅支持 ZIP 格式的文件"
|
||||||
:uploadHandler="updateByUploadHandler"
|
:uploadHandler="updateByUploadHandler"
|
||||||
@change="handleNewThemeUploadChange"
|
:filed="prepareUpdateTheme.id"
|
||||||
|
:multiple="false"
|
||||||
@success="handleUploadSuccess"
|
@success="handleUploadSuccess"
|
||||||
>
|
>
|
||||||
<p class="ant-upload-drag-icon">
|
</FilePondUpload>
|
||||||
<a-icon type="inbox" />
|
|
||||||
</p>
|
|
||||||
<p class="ant-upload-text">点击选择主题包或将主题包拖拽到此处</p>
|
|
||||||
<p class="ant-upload-hint">请选择最新的主题包,仅支持 ZIP 格式的文件</p>
|
|
||||||
</UpdateTheme>
|
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -313,26 +309,6 @@ export default {
|
||||||
this.loadThemes()
|
this.loadThemes()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onThemeSettingsClose() {
|
|
||||||
this.themeSettingVisible = false
|
|
||||||
this.selectedTheme = {}
|
|
||||||
},
|
|
||||||
handleUploadChange(info) {
|
|
||||||
const status = info.file.status
|
|
||||||
if (status === 'done') {
|
|
||||||
this.$message.success(`${info.file.name} 主题上传成功!`)
|
|
||||||
} else if (status === 'error') {
|
|
||||||
this.$message.error(`${info.file.name} 主题上传失败!`)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleNewThemeUploadChange(info) {
|
|
||||||
const status = info.file.status
|
|
||||||
if (status === 'done') {
|
|
||||||
this.$message.success(`${info.file.name} 主题更新成功!`)
|
|
||||||
} else if (status === 'error') {
|
|
||||||
this.$message.error(`${info.file.name} 主题更新失败!`)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleUploadSuccess() {
|
handleUploadSuccess() {
|
||||||
if (this.uploadThemeVisible) {
|
if (this.uploadThemeVisible) {
|
||||||
this.uploadThemeVisible = false
|
this.uploadThemeVisible = false
|
||||||
|
@ -375,13 +351,25 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleShowUpdateNewThemeModal(item) {
|
handleShowUpdateNewThemeModal(item) {
|
||||||
console.log(item)
|
|
||||||
this.prepareUpdateTheme = item
|
this.prepareUpdateTheme = item
|
||||||
this.uploadNewThemeVisible = true
|
this.uploadNewThemeVisible = true
|
||||||
},
|
},
|
||||||
handleShowThemeSetting(theme) {
|
handleShowThemeSetting(theme) {
|
||||||
this.selectedTheme = theme
|
this.selectedTheme = theme
|
||||||
this.themeSettingVisible = true
|
this.themeSettingVisible = true
|
||||||
|
},
|
||||||
|
onThemeUploadClose() {
|
||||||
|
if (this.uploadThemeVisible) {
|
||||||
|
this.$refs.upload.handleClearFileList()
|
||||||
|
}
|
||||||
|
if (this.uploadNewThemeVisible) {
|
||||||
|
this.$refs.updateByupload.handleClearFileList()
|
||||||
|
}
|
||||||
|
this.loadThemes()
|
||||||
|
},
|
||||||
|
onThemeSettingsClose() {
|
||||||
|
this.themeSettingVisible = false
|
||||||
|
this.selectedTheme = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,14 +187,18 @@ export default {
|
||||||
// Update the post
|
// Update the post
|
||||||
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
|
||||||
this.$log.debug('Updated post', response.data.data)
|
this.$log.debug('Updated post', response.data.data)
|
||||||
window.open(`${this.options.blog_url}/api/admin/posts/preview/${this.postToStage.id}`, '_blank')
|
postApi.preview(this.postToStage.id).then(response => {
|
||||||
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Create the post
|
// Create the post
|
||||||
postApi.create(this.postToStage, false).then(response => {
|
postApi.create(this.postToStage, false).then(response => {
|
||||||
this.$log.debug('Created post', response.data.data)
|
this.$log.debug('Created post', response.data.data)
|
||||||
this.postToStage = response.data.data
|
this.postToStage = response.data.data
|
||||||
window.open(`${this.options.blog_url}/api/admin/posts/preview/${this.postToStage.id}`, '_blank')
|
postApi.preview(this.postToStage.id).then(response => {
|
||||||
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -143,10 +143,10 @@
|
||||||
twoToneColor="red"
|
twoToneColor="red"
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
|
v-if="record.status=='PUBLISHED'"
|
||||||
:href="options.blog_url+'/archives/'+record.url"
|
:href="options.blog_url+'/archives/'+record.url"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
style="text-decoration: none;"
|
style="text-decoration: none;"
|
||||||
v-if="record.status=='PUBLISHED'"
|
|
||||||
>
|
>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
placement="top"
|
placement="top"
|
||||||
|
@ -154,10 +154,10 @@
|
||||||
>{{ text }}</a-tooltip>
|
>{{ text }}</a-tooltip>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
v-else-if="record.status == 'INTIMATE'"
|
||||||
:href="options.blog_url+'/archives/'+record.url+'/password'"
|
:href="options.blog_url+'/archives/'+record.url+'/password'"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
style="text-decoration: none;"
|
style="text-decoration: none;"
|
||||||
v-else-if="record.status == 'INTIMATE'"
|
|
||||||
>
|
>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
placement="top"
|
placement="top"
|
||||||
|
@ -165,10 +165,10 @@
|
||||||
>{{ text }}</a-tooltip>
|
>{{ text }}</a-tooltip>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
:href="`${options.blog_url}/api/admin/posts/preview/${record.id}`"
|
|
||||||
target="_blank"
|
|
||||||
style="text-decoration: none;"
|
|
||||||
v-else-if="record.status=='DRAFT'"
|
v-else-if="record.status=='DRAFT'"
|
||||||
|
href="javascript:void(0)"
|
||||||
|
style="text-decoration: none;"
|
||||||
|
@click="handlePreview(record.id)"
|
||||||
>
|
>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
placement="topLeft"
|
placement="topLeft"
|
||||||
|
@ -176,10 +176,10 @@
|
||||||
>{{ text }}</a-tooltip>
|
>{{ text }}</a-tooltip>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
v-else
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
style="text-decoration: none;"
|
style="text-decoration: none;"
|
||||||
disabled
|
disabled
|
||||||
v-else
|
|
||||||
>
|
>
|
||||||
{{ text }}
|
{{ text }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -564,6 +564,11 @@ export default {
|
||||||
this.postSettingVisible = true
|
this.postSettingVisible = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handlePreview(postId) {
|
||||||
|
postApi.preview(postId).then(response => {
|
||||||
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
|
},
|
||||||
// 关闭文章设置抽屉
|
// 关闭文章设置抽屉
|
||||||
onPostSettingsClose() {
|
onPostSettingsClose() {
|
||||||
this.postSettingVisible = false
|
this.postSettingVisible = false
|
||||||
|
|
|
@ -174,13 +174,17 @@ export default {
|
||||||
if (this.sheetToStage.id) {
|
if (this.sheetToStage.id) {
|
||||||
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
|
sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
|
||||||
this.$log.debug('Updated sheet', response.data.data)
|
this.$log.debug('Updated sheet', response.data.data)
|
||||||
window.open(`${this.options.blog_url}/api/admin/sheets/preview/${this.sheetToStage.id}`, '_blank')
|
sheetApi.preview(this.sheetToStage.id).then(response => {
|
||||||
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sheetApi.create(this.sheetToStage, false).then(response => {
|
sheetApi.create(this.sheetToStage, false).then(response => {
|
||||||
this.$log.debug('Created sheet', response.data.data)
|
this.$log.debug('Created sheet', response.data.data)
|
||||||
this.sheetToStage = response.data.data
|
this.sheetToStage = response.data.data
|
||||||
window.open(`${this.options.blog_url}/api/admin/sheets/preview/${this.sheetToStage.id}`, '_blank')
|
sheetApi.preview(this.sheetToStage.id).then(response => {
|
||||||
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,10 +83,10 @@
|
||||||
style="max-width: 150px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"
|
style="max-width: 150px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
|
v-if="record.status=='PUBLISHED'"
|
||||||
:href="options.blog_url+'/s/'+record.url"
|
:href="options.blog_url+'/s/'+record.url"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
style="text-decoration: none;"
|
style="text-decoration: none;"
|
||||||
v-if="record.status=='PUBLISHED'"
|
|
||||||
>
|
>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
placement="top"
|
placement="top"
|
||||||
|
@ -94,10 +94,10 @@
|
||||||
>{{ text }}</a-tooltip>
|
>{{ text }}</a-tooltip>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
:href="`${options.blog_url}/api/admin/sheets/preview/${record.id}`"
|
|
||||||
target="_blank"
|
|
||||||
style="text-decoration: none;"
|
|
||||||
v-else-if="record.status=='DRAFT'"
|
v-else-if="record.status=='DRAFT'"
|
||||||
|
href="javascript:void(0)"
|
||||||
|
style="text-decoration: none;"
|
||||||
|
@click="handlePreview(record.id)"
|
||||||
>
|
>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
placement="topLeft"
|
placement="topLeft"
|
||||||
|
@ -105,10 +105,10 @@
|
||||||
>{{ text }}</a-tooltip>
|
>{{ text }}</a-tooltip>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
v-else
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
style="text-decoration: none;"
|
style="text-decoration: none;"
|
||||||
disabled
|
disabled
|
||||||
v-else
|
|
||||||
>
|
>
|
||||||
{{ text }}
|
{{ text }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -390,6 +390,11 @@ export default {
|
||||||
this.sheetSettingVisible = true
|
this.sheetSettingVisible = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handlePreview(sheetId) {
|
||||||
|
sheetApi.preview(sheetId).then(response => {
|
||||||
|
window.open(response.data, '_blank')
|
||||||
|
})
|
||||||
|
},
|
||||||
onSheetSettingsClose() {
|
onSheetSettingsClose() {
|
||||||
this.sheetSettingVisible = false
|
this.sheetSettingVisible = false
|
||||||
this.selectedSheet = {}
|
this.selectedSheet = {}
|
||||||
|
|
|
@ -251,6 +251,30 @@
|
||||||
<a-icon type="picture" />附件设置
|
<a-icon type="picture" />附件设置
|
||||||
</span>
|
</span>
|
||||||
<a-form layout="vertical">
|
<a-form layout="vertical">
|
||||||
|
<a-form-item
|
||||||
|
label="上传图片时预览:"
|
||||||
|
:wrapper-col="wrapperCol"
|
||||||
|
>
|
||||||
|
<a-switch v-model="options.attachment_upload_image_preview_enable" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
label="最大上传文件数:"
|
||||||
|
:wrapper-col="wrapperCol"
|
||||||
|
>
|
||||||
|
<a-input
|
||||||
|
type="number"
|
||||||
|
v-model="options.attachment_upload_max_files"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
label="同时上传文件数:"
|
||||||
|
:wrapper-col="wrapperCol"
|
||||||
|
>
|
||||||
|
<a-input
|
||||||
|
type="number"
|
||||||
|
v-model="options.attachment_upload_max_parallel_uploads"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
<a-form-item
|
<a-form-item
|
||||||
label="存储位置:"
|
label="存储位置:"
|
||||||
:wrapper-col="wrapperCol"
|
:wrapper-col="wrapperCol"
|
||||||
|
|
|
@ -27,20 +27,16 @@
|
||||||
title="Markdown 文章导入"
|
title="Markdown 文章导入"
|
||||||
v-model="markdownUpload"
|
v-model="markdownUpload"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
|
destroyOnClose
|
||||||
|
:afterClose="onUploadClose"
|
||||||
>
|
>
|
||||||
<upload
|
<FilePondUpload
|
||||||
name="files"
|
ref="upload"
|
||||||
multiple
|
name="file"
|
||||||
accept="text/markdown"
|
accept="text/markdown"
|
||||||
|
label="拖拽或点击选择 Markdown 文件到此处"
|
||||||
:uploadHandler="uploadHandler"
|
:uploadHandler="uploadHandler"
|
||||||
@change="handleChange"
|
></FilePondUpload>
|
||||||
>
|
|
||||||
<p class="ant-upload-drag-icon">
|
|
||||||
<a-icon type="inbox" />
|
|
||||||
</p>
|
|
||||||
<p class="ant-upload-text">拖拽或点击选择 Markdown 文件到此处</p>
|
|
||||||
<p class="ant-upload-hint">支持多个文件同时上传</p>
|
|
||||||
</upload>
|
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,6 +65,9 @@ export default {
|
||||||
} else if (status === 'error') {
|
} else if (status === 'error') {
|
||||||
this.$message.error(`${info.file.name} 导入失败!`)
|
this.$message.error(`${info.file.name} 导入失败!`)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onUploadClose() {
|
||||||
|
this.$refs.upload.handleClearFileList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue