Merge pull request #36 from secondarycoder/dev-addTencentYunOSS

新增腾讯云oss功能
pull/37/head
John Niang 2019-07-25 22:16:22 +08:00 committed by GitHub
commit 88613d8c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 308 additions and 36 deletions

View File

@ -87,6 +87,14 @@ attachmentApi.type = {
ALIYUN: {
type: 'aliyun',
text: '阿里云'
},
BAIDUYUN: {
type: 'baiduyun',
text: '百度云'
},
TENCENTYUN: {
type: 'tencentyun',
text: '百度云'
}
}

View File

@ -4,9 +4,14 @@
:href="options.blog_url"
target="_blank"
>
<span class="action">
<a-icon type="link" />
</span>
<a-tooltip
placement="bottom"
title="点击跳转到首页"
>
<span class="action">
<a-icon type="link" />
</span>
</a-tooltip>
</a>
<a
href="javascript:void(0)"

View File

@ -708,4 +708,8 @@ body {
.post-thum-remove {
margin-top: 16px;
}
}
.ant-calendar-picker{
width: 100%!important;
}

View File

@ -18,7 +18,8 @@ const toolbars = {
trash: true, // 清空
navigation: true, // 导航目录
subfield: true, // 单双栏模式
preview: true // 预览
preview: true, // 预览
imagelink: true // 图片链接
}
export { toolbars }

View File

@ -290,6 +290,7 @@ export default {
this.photo['takeTime'] = new Date().getTime()
photoApi.create(this.photo).then(response => {
this.$message.success('添加成功!')
this.photo = {}
})
},
onClose() {

View File

@ -92,14 +92,34 @@
@click="handleEditCategory(record)"
>编辑</a>
<a-divider type="vertical" />
<a-popconfirm
:title="'你确定要删除【' + record.name + '】分类?'"
@confirm="handleDeleteCategory(record.id)"
okText="确定"
cancelText="取消"
>
<a href="javascript:;">删除</a>
</a-popconfirm>
<a-dropdown :trigger="['click']">
<a
href="javascript:void(0);"
class="ant-dropdown-link"
>更多</a>
<a-menu slot="overlay">
<a-menu-item key="1">
<a-popconfirm
:title="'你确定要添加【' + record.name + '】到菜单?'"
@confirm="handleCategoryToMenu(record)"
okText="确定"
cancelText="取消"
>
<a href="javascript:void(0);">添加到菜单</a>
</a-popconfirm>
</a-menu-item>
<a-menu-item key="2">
<a-popconfirm
:title="'你确定要删除【' + record.name + '】分类?'"
@confirm="handleDeleteCategory(record.id)"
okText="确定"
cancelText="取消"
>
<a href="javascript:void(0);">删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</a-card>
@ -111,6 +131,7 @@
<script>
import CategorySelectTree from './components/CategorySelectTree'
import categoryApi from '@/api/category'
import menuApi from '@/api/menu'
const columns = [
{
@ -142,6 +163,7 @@ export default {
formType: 'create',
categories: [],
categoryToCreate: {},
menu: {},
loading: false,
columns
}
@ -198,6 +220,14 @@ export default {
})
}
this.handleAddCategory()
},
handleCategoryToMenu(category) {
this.menu['name'] = category.name
this.menu['url'] = `/categories/${category.slugName}`
menuApi.create(this.menu).then(response => {
this.$message.success('添加到菜单成功!')
this.menu = {}
})
}
}
}

View File

@ -13,11 +13,13 @@
<div id="editor">
<mavon-editor
ref="md"
v-model="postToStage.originalContent"
:boxShadow="false"
:toolbars="toolbars"
:ishljs="true"
:autofocus="false"
@imgAdd="pictureUploadHandle"
/>
</div>
</a-col>
@ -42,6 +44,19 @@
>
<a-input v-model="postToStage.url" />
</a-form-item>
<a-form-item
label="发表时间:"
>
<a-date-picker
showTime
:defaultValue="pickerDefaultValue"
format="YYYY-MM-DD HH:mm:ss"
placeholder="Select Publish Time"
@change="onChange"
@ok="onOk"
/>
</a-form-item>
<a-form-item label="开启评论:">
<a-radio-group
v-model="postToStage.disallowComment"
@ -202,6 +217,8 @@ import 'mavon-editor/dist/css/index.css'
import categoryApi from '@/api/category'
import postApi from '@/api/post'
import optionApi from '@/api/option'
import attachmentApi from '@/api/attachment'
import moment from 'moment'
export default {
components: {
TagSelect,
@ -269,6 +286,15 @@ export default {
}
})
},
computed: {
pickerDefaultValue() {
if (this.postToStage.createTime) {
var date = new Date(this.postToStage.createTime)
return moment(date, 'YYYY-MM-DD HH:mm:ss')
}
return moment(new Date(), 'YYYY-MM-DD HH:mm:ss')
}
},
methods: {
loadCategories() {
categoryApi.listAll().then(response => {
@ -338,7 +364,7 @@ export default {
})
},
handleSelectPostThumb(data) {
this.postToStage.thumbnail = data.path
this.postToStage.thumbnail = encodeURI(data.path)
this.thumDrawerVisible = false
},
autoSaveTimer() {
@ -347,6 +373,27 @@ export default {
this.autoSavePost()
}, 15000)
}
},
pictureUploadHandle(pos, $file) {
var formdata = new FormData()
formdata.append('file', $file)
attachmentApi.upload(formdata).then((response) => {
var responseObject = response.data
if (responseObject.status === 200) {
var MavonEditor = this.$refs.md
MavonEditor.$img2Url(pos, encodeURI(responseObject.data.path))
this.$message.success('图片上传成功')
} else {
this.$message.error('图片上传失败:' + responseObject.message)
}
})
},
onChange(value, dateString) {
this.postToStage.createTime = value.valueOf()
},
onOk(value) {
this.postToStage.createTime = value.valueOf()
}
}
}

View File

@ -180,9 +180,9 @@
</span>
<span
slot="updateTime"
slot-scope="updateTime"
>{{ updateTime | timeAgo }}</span>
slot="createTime"
slot-scope="createTime"
>{{ createTime | timeAgo }}</span>
<span
slot="action"
@ -436,9 +436,9 @@ const columns = [
dataIndex: 'visits'
},
{
title: '更新时间',
dataIndex: 'updateTime',
scopedSlots: { customRender: 'updateTime' }
title: '发布时间',
dataIndex: 'createTime',
scopedSlots: { customRender: 'createTime' }
},
{
title: '操作',
@ -620,7 +620,7 @@ export default {
})
},
handleSelectPostThumb(data) {
this.selectedPost.thumbnail = data.path
this.selectedPost.thumbnail = encodeURI(data.path)
this.thumDrawerVisible = false
},
handlerRemoveThumb() {

View File

@ -12,11 +12,13 @@
</div>
<div id="editor">
<mavon-editor
ref="md"
v-model="sheetToStage.originalContent"
:boxShadow="false"
:toolbars="toolbars"
:ishljs="true"
:autofocus="false"
@imgAdd="pictureUploadHandle"
/>
</div>
</a-col>
@ -46,6 +48,16 @@
>
<a-input v-model="sheetToStage.url" />
</a-form-item>
<a-form-item label="发表时间:">
<a-date-picker
showTime
:defaultValue="pickerDefaultValue"
format="YYYY-MM-DD HH:mm:ss"
placeholder="Select Publish Time"
@change="onChange"
@ok="onOk"
/>
</a-form-item>
<a-form-item label="开启评论:">
<a-radio-group
v-model="sheetToStage.disallowComment"
@ -136,6 +148,8 @@ import 'mavon-editor/dist/css/index.css'
import sheetApi from '@/api/sheet'
import themeApi from '@/api/theme'
import optionApi from '@/api/option'
import attachmentApi from '@/api/attachment'
import moment from 'moment'
export default {
components: {
mavonEditor,
@ -194,6 +208,15 @@ export default {
}
})
},
computed: {
pickerDefaultValue() {
if (this.sheetToStage.createTime) {
var date = new Date(this.sheetToStage.createTime)
return moment(date, 'YYYY-MM-DD HH:mm:ss')
}
return moment(new Date(), 'YYYY-MM-DD HH:mm:ss')
}
},
methods: {
loadCustomTpls() {
themeApi.customTpls().then(response => {
@ -247,7 +270,7 @@ export default {
}
},
handleSelectSheetThumb(data) {
this.sheetToStage.thumbnail = data.path
this.sheetToStage.thumbnail = encodeURI(data.path)
this.thumDrawerVisible = false
},
autoSaveTimer() {
@ -256,6 +279,27 @@ export default {
this.autoSaveSheet()
}, 15000)
}
},
pictureUploadHandle(pos, $file) {
var formdata = new FormData()
formdata.append('file', $file)
attachmentApi.upload(formdata).then(response => {
var responseObject = response.data
if (responseObject.status === 200) {
var MavonEditor = this.$refs.md
MavonEditor.$img2Url(pos, encodeURI(responseObject.data.path))
this.$message.success('图片上传成功')
} else {
this.$message.error('图片上传失败:' + responseObject.message)
}
})
},
onChange(value, dateString) {
this.sheetToStage.createTime = value.valueOf()
},
onOk(value) {
this.sheetToStage.createTime = value.valueOf()
}
}
}

View File

@ -105,7 +105,10 @@
:href="options.blog_url+'/s/'+record.url"
target="_blank"
>
<a-tooltip placement="topLeft" :title="'点击预览 '+text">{{ text }}</a-tooltip>
<a-tooltip
placement="topLeft"
:title="'点击预览 '+text"
>{{ text }}</a-tooltip>
</a>
</span>
<span
@ -116,9 +119,9 @@
{{ statusProperty.text }}
</span>
<span
slot="updateTime"
slot-scope="updateTime"
>{{ updateTime | timeAgo }}</span>
slot="createTime"
slot-scope="createTime"
>{{ createTime | timeAgo }}</span>
<span
slot="action"
@ -161,7 +164,25 @@
>
<a href="javascript:;">删除</a>
</a-popconfirm>
<a-divider type="vertical" />
<a-dropdown :trigger="['click']">
<a
href="javascript:void(0);"
class="ant-dropdown-link"
>更多</a>
<a-menu slot="overlay">
<a-menu-item key="1">
<a-popconfirm
:title="'你确定要添加【' + sheet.title + '】到菜单?'"
@confirm="handleSheetToMenu(sheet)"
okText="确定"
cancelText="取消"
>
<a href="javascript:void(0);">添加到菜单</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</a-tab-pane>
@ -176,6 +197,8 @@
import { mixin, mixinDevice } from '@/utils/mixin.js'
import sheetApi from '@/api/sheet'
import optionApi from '@/api/option'
import menuApi from '@/api/menu'
const internalColumns = [
{
title: '页面名称',
@ -218,13 +241,13 @@ const customColumns = [
dataIndex: 'visits'
},
{
title: '更新时间',
dataIndex: 'updateTime',
scopedSlots: { customRender: 'updateTime' }
title: '发布时间',
dataIndex: 'createTime',
scopedSlots: { customRender: 'createTime' }
},
{
title: '操作',
width: '150px',
width: '180px',
scopedSlots: { customRender: 'action' }
}
]
@ -238,6 +261,7 @@ export default {
internalSheets: [],
sheets: [],
options: [],
menu: {},
keys: ['blog_url']
}
},
@ -284,15 +308,23 @@ export default {
this.$message.success('删除成功!')
this.loadSheets()
})
},
handleSheetToMenu(sheet) {
this.menu['name'] = sheet.title
this.menu['url'] = `/s/${sheet.url}`
menuApi.create(this.menu).then(response => {
this.$message.success('添加到菜单成功!')
this.menu = {}
})
}
}
}
</script>
<style scoped>
a{
a {
text-decoration: none;
}
.sheet-title{
.sheet-title {
max-width: 300px;
display: block;
white-space: nowrap;

View File

@ -364,7 +364,7 @@ export default {
this.thumDrawerVisible = true
},
selectPhotoThumb(data) {
this.photo.url = data.path
this.photo.url = encodeURI(data.path)
this.thumDrawerVisible = false
},
resetParam() {

View File

@ -388,6 +388,82 @@
<a-input v-model="options.oss_aliyun_style_rule" />
</a-form-item>
</div>
<div
class="baiduyunForm"
v-show="baiduyunFormHidden"
>
<a-form-item
label="Bucket"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_baiduyun_bucket_name" />
</a-form-item>
<a-form-item
label="EndPoint地域节点"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_baiduyun_endpoint" />
</a-form-item>
<a-form-item
label="Access Key"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_baiduyun_access_key" />
</a-form-item>
<a-form-item
label="Access Secret"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_baiduyun_access_secret" />
</a-form-item>
<a-form-item
label="缩略图处理策略:"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_baiduyun_style_rule" />
</a-form-item>
</div>
<div
class="tencentyunForm"
v-show="tencentyunFormHidden"
>
<a-form-item
label="Bucket"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_tencentyun_bucket_name" />
</a-form-item>
<a-form-item
label="区域:"
:wrapper-col="wrapperCol"
>
<a-select v-model="oss_tencentyun_region">
<a-select-option value="ap-beijing-1">北京一区</a-select-option>
<a-select-option value="ap-beijing">北京</a-select-option>
<a-select-option value="ap-shanghai">上海华东</a-select-option>
<a-select-option value="ap-guangzhou">广州华南</a-select-option>
<a-select-option value="ap-chengdu">成都西南</a-select-option>
<a-select-option value="ap-chongqing">重庆</a-select-option>
</a-select>
<a-form-item
label="SecretId"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_tencentyun_access_key" />
</a-form-item>
<a-form-item
label="SecretKey"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_tencentyun_access_secret" />
</a-form-item>
<a-form-item
label="缩略图处理策略:"
:wrapper-col="wrapperCol"
>
<a-input v-model="options.oss_tencentyun_style_rule" />
</a-form-item>
</div>
<a-form-item>
<a-button
type="primary"
@ -599,6 +675,8 @@ export default {
upyunFormHidden: false,
qnyunFormHidden: false,
aliyunFormHidden: false,
baiduyunFormHidden: false,
tencentyunFormHidden: false,
logoDrawerVisible: false,
faviconDrawerVisible: false,
options: [],
@ -630,26 +708,48 @@ export default {
this.upyunFormHidden = false
this.qnyunFormHidden = false
this.aliyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break
case 'UPYUN':
this.upyunFormHidden = true
this.qnyunFormHidden = false
this.aliyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break
case 'QNYUN':
this.qnyunFormHidden = true
this.upyunFormHidden = false
this.aliyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break
case 'ALIYUN':
this.aliyunFormHidden = true
this.qnyunFormHidden = false
this.upyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break
case 'BAIDUYUN':
this.aliyunFormHidden = false
this.qnyunFormHidden = false
this.upyunFormHidden = false
this.baiduyunFormHidden = true
this.tencentyunFormHidden = false
break
case 'TENCENTYUN':
this.aliyunFormHidden = false
this.qnyunFormHidden = false
this.upyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = true
break
}
},
handleSelectLogo(data) {
this.options.blog_logo = data.path
this.options.blog_logo = encodeURI(data.path)
this.logoDrawerVisible = false
},
handleTestMailClick() {
@ -658,7 +758,7 @@ export default {
})
},
handleSelectFavicon(data) {
this.options.blog_favicon = data.path
this.options.blog_favicon = encodeURI(data.path)
this.faviconDrawerVisible = false
}
}

View File

@ -218,7 +218,7 @@ export default {
})
},
handleSelectAvatar(data) {
this.user.avatar = data.path
this.user.avatar = encodeURI(data.path)
this.attachmentDrawerVisible = false
},
handleSelectGravatar() {