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: { ALIYUN: {
type: 'aliyun', type: 'aliyun',
text: '阿里云' text: '阿里云'
},
BAIDUYUN: {
type: 'baiduyun',
text: '百度云'
},
TENCENTYUN: {
type: 'tencentyun',
text: '百度云'
} }
} }

View File

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

View File

@ -709,3 +709,7 @@ body {
margin-top: 16px; margin-top: 16px;
} }
} }
.ant-calendar-picker{
width: 100%!important;
}

View File

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

View File

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

View File

@ -92,14 +92,34 @@
@click="handleEditCategory(record)" @click="handleEditCategory(record)"
>编辑</a> >编辑</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a-popconfirm <a-dropdown :trigger="['click']">
:title="'你确定要删除【' + record.name + '】分类?'" <a
@confirm="handleDeleteCategory(record.id)" href="javascript:void(0);"
okText="确定" class="ant-dropdown-link"
cancelText="取消" >更多</a>
> <a-menu slot="overlay">
<a href="javascript:;">删除</a> <a-menu-item key="1">
</a-popconfirm> <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> </span>
</a-table> </a-table>
</a-card> </a-card>
@ -111,6 +131,7 @@
<script> <script>
import CategorySelectTree from './components/CategorySelectTree' import CategorySelectTree from './components/CategorySelectTree'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import menuApi from '@/api/menu'
const columns = [ const columns = [
{ {
@ -142,6 +163,7 @@ export default {
formType: 'create', formType: 'create',
categories: [], categories: [],
categoryToCreate: {}, categoryToCreate: {},
menu: {},
loading: false, loading: false,
columns columns
} }
@ -198,6 +220,14 @@ export default {
}) })
} }
this.handleAddCategory() 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"> <div id="editor">
<mavon-editor <mavon-editor
ref="md"
v-model="postToStage.originalContent" v-model="postToStage.originalContent"
:boxShadow="false" :boxShadow="false"
:toolbars="toolbars" :toolbars="toolbars"
:ishljs="true" :ishljs="true"
:autofocus="false" :autofocus="false"
@imgAdd="pictureUploadHandle"
/> />
</div> </div>
</a-col> </a-col>
@ -42,6 +44,19 @@
> >
<a-input v-model="postToStage.url" /> <a-input v-model="postToStage.url" />
</a-form-item> </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-form-item label="开启评论:">
<a-radio-group <a-radio-group
v-model="postToStage.disallowComment" v-model="postToStage.disallowComment"
@ -202,6 +217,8 @@ import 'mavon-editor/dist/css/index.css'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
import optionApi from '@/api/option' import optionApi from '@/api/option'
import attachmentApi from '@/api/attachment'
import moment from 'moment'
export default { export default {
components: { components: {
TagSelect, 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: { methods: {
loadCategories() { loadCategories() {
categoryApi.listAll().then(response => { categoryApi.listAll().then(response => {
@ -338,7 +364,7 @@ export default {
}) })
}, },
handleSelectPostThumb(data) { handleSelectPostThumb(data) {
this.postToStage.thumbnail = data.path this.postToStage.thumbnail = encodeURI(data.path)
this.thumDrawerVisible = false this.thumDrawerVisible = false
}, },
autoSaveTimer() { autoSaveTimer() {
@ -347,6 +373,27 @@ export default {
this.autoSavePost() this.autoSavePost()
}, 15000) }, 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>
<span <span
slot="updateTime" slot="createTime"
slot-scope="updateTime" slot-scope="createTime"
>{{ updateTime | timeAgo }}</span> >{{ createTime | timeAgo }}</span>
<span <span
slot="action" slot="action"
@ -436,9 +436,9 @@ const columns = [
dataIndex: 'visits' dataIndex: 'visits'
}, },
{ {
title: '更新时间', title: '发布时间',
dataIndex: 'updateTime', dataIndex: 'createTime',
scopedSlots: { customRender: 'updateTime' } scopedSlots: { customRender: 'createTime' }
}, },
{ {
title: '操作', title: '操作',
@ -620,7 +620,7 @@ export default {
}) })
}, },
handleSelectPostThumb(data) { handleSelectPostThumb(data) {
this.selectedPost.thumbnail = data.path this.selectedPost.thumbnail = encodeURI(data.path)
this.thumDrawerVisible = false this.thumDrawerVisible = false
}, },
handlerRemoveThumb() { handlerRemoveThumb() {

View File

@ -12,11 +12,13 @@
</div> </div>
<div id="editor"> <div id="editor">
<mavon-editor <mavon-editor
ref="md"
v-model="sheetToStage.originalContent" v-model="sheetToStage.originalContent"
:boxShadow="false" :boxShadow="false"
:toolbars="toolbars" :toolbars="toolbars"
:ishljs="true" :ishljs="true"
:autofocus="false" :autofocus="false"
@imgAdd="pictureUploadHandle"
/> />
</div> </div>
</a-col> </a-col>
@ -46,6 +48,16 @@
> >
<a-input v-model="sheetToStage.url" /> <a-input v-model="sheetToStage.url" />
</a-form-item> </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-form-item label="开启评论:">
<a-radio-group <a-radio-group
v-model="sheetToStage.disallowComment" v-model="sheetToStage.disallowComment"
@ -136,6 +148,8 @@ import 'mavon-editor/dist/css/index.css'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
import themeApi from '@/api/theme' import themeApi from '@/api/theme'
import optionApi from '@/api/option' import optionApi from '@/api/option'
import attachmentApi from '@/api/attachment'
import moment from 'moment'
export default { export default {
components: { components: {
mavonEditor, 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: { methods: {
loadCustomTpls() { loadCustomTpls() {
themeApi.customTpls().then(response => { themeApi.customTpls().then(response => {
@ -247,7 +270,7 @@ export default {
} }
}, },
handleSelectSheetThumb(data) { handleSelectSheetThumb(data) {
this.sheetToStage.thumbnail = data.path this.sheetToStage.thumbnail = encodeURI(data.path)
this.thumDrawerVisible = false this.thumDrawerVisible = false
}, },
autoSaveTimer() { autoSaveTimer() {
@ -256,6 +279,27 @@ export default {
this.autoSaveSheet() this.autoSaveSheet()
}, 15000) }, 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" :href="options.blog_url+'/s/'+record.url"
target="_blank" target="_blank"
> >
<a-tooltip placement="topLeft" :title="'点击预览 '+text">{{ text }}</a-tooltip> <a-tooltip
placement="topLeft"
:title="'点击预览 '+text"
>{{ text }}</a-tooltip>
</a> </a>
</span> </span>
<span <span
@ -116,9 +119,9 @@
{{ statusProperty.text }} {{ statusProperty.text }}
</span> </span>
<span <span
slot="updateTime" slot="createTime"
slot-scope="updateTime" slot-scope="createTime"
>{{ updateTime | timeAgo }}</span> >{{ createTime | timeAgo }}</span>
<span <span
slot="action" slot="action"
@ -161,7 +164,25 @@
> >
<a href="javascript:;">删除</a> <a href="javascript:;">删除</a>
</a-popconfirm> </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> </span>
</a-table> </a-table>
</a-tab-pane> </a-tab-pane>
@ -176,6 +197,8 @@
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
import optionApi from '@/api/option' import optionApi from '@/api/option'
import menuApi from '@/api/menu'
const internalColumns = [ const internalColumns = [
{ {
title: '页面名称', title: '页面名称',
@ -218,13 +241,13 @@ const customColumns = [
dataIndex: 'visits' dataIndex: 'visits'
}, },
{ {
title: '更新时间', title: '发布时间',
dataIndex: 'updateTime', dataIndex: 'createTime',
scopedSlots: { customRender: 'updateTime' } scopedSlots: { customRender: 'createTime' }
}, },
{ {
title: '操作', title: '操作',
width: '150px', width: '180px',
scopedSlots: { customRender: 'action' } scopedSlots: { customRender: 'action' }
} }
] ]
@ -238,6 +261,7 @@ export default {
internalSheets: [], internalSheets: [],
sheets: [], sheets: [],
options: [], options: [],
menu: {},
keys: ['blog_url'] keys: ['blog_url']
} }
}, },
@ -284,15 +308,23 @@ export default {
this.$message.success('删除成功!') this.$message.success('删除成功!')
this.loadSheets() 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> </script>
<style scoped> <style scoped>
a{ a {
text-decoration: none; text-decoration: none;
} }
.sheet-title{ .sheet-title {
max-width: 300px; max-width: 300px;
display: block; display: block;
white-space: nowrap; white-space: nowrap;

View File

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

View File

@ -388,6 +388,82 @@
<a-input v-model="options.oss_aliyun_style_rule" /> <a-input v-model="options.oss_aliyun_style_rule" />
</a-form-item> </a-form-item>
</div> </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-form-item>
<a-button <a-button
type="primary" type="primary"
@ -599,6 +675,8 @@ export default {
upyunFormHidden: false, upyunFormHidden: false,
qnyunFormHidden: false, qnyunFormHidden: false,
aliyunFormHidden: false, aliyunFormHidden: false,
baiduyunFormHidden: false,
tencentyunFormHidden: false,
logoDrawerVisible: false, logoDrawerVisible: false,
faviconDrawerVisible: false, faviconDrawerVisible: false,
options: [], options: [],
@ -630,26 +708,48 @@ export default {
this.upyunFormHidden = false this.upyunFormHidden = false
this.qnyunFormHidden = false this.qnyunFormHidden = false
this.aliyunFormHidden = false this.aliyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break break
case 'UPYUN': case 'UPYUN':
this.upyunFormHidden = true this.upyunFormHidden = true
this.qnyunFormHidden = false this.qnyunFormHidden = false
this.aliyunFormHidden = false this.aliyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break break
case 'QNYUN': case 'QNYUN':
this.qnyunFormHidden = true this.qnyunFormHidden = true
this.upyunFormHidden = false this.upyunFormHidden = false
this.aliyunFormHidden = false this.aliyunFormHidden = false
this.baiduyunFormHidden = false
this.tencentyunFormHidden = false
break break
case 'ALIYUN': case 'ALIYUN':
this.aliyunFormHidden = true this.aliyunFormHidden = true
this.qnyunFormHidden = false this.qnyunFormHidden = false
this.upyunFormHidden = 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 break
} }
}, },
handleSelectLogo(data) { handleSelectLogo(data) {
this.options.blog_logo = data.path this.options.blog_logo = encodeURI(data.path)
this.logoDrawerVisible = false this.logoDrawerVisible = false
}, },
handleTestMailClick() { handleTestMailClick() {
@ -658,7 +758,7 @@ export default {
}) })
}, },
handleSelectFavicon(data) { handleSelectFavicon(data) {
this.options.blog_favicon = data.path this.options.blog_favicon = encodeURI(data.path)
this.faviconDrawerVisible = false this.faviconDrawerVisible = false
} }
} }

View File

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