refactor : meta variable (halo-dev/console#92)

* 1.3.0-beta.2

* refactor: metas variable.

* refactor: metas variable.
pull/3445/head
Ryan Wang 2020-03-11 13:49:00 +08:00 committed by GitHub
parent ea0b2df06d
commit e0b7da7a77
6 changed files with 52 additions and 52 deletions

View File

@ -31,7 +31,7 @@
:post="postToStage"
:tagIds="selectedTagIds"
:categoryIds="selectedCategoryIds"
:postMetas="selectedPostMetas"
:metas="selectedMetas"
:visible="postSettingVisible"
@close="onPostSettingsClose"
@onRefreshPost="onRefreshPostFromSetting"
@ -95,7 +95,7 @@ export default {
postToStage: {},
selectedTagIds: [],
selectedCategoryIds: [],
selectedPostMetas: [],
selectedMetas: [],
isSaved: false,
contentChanges: 0,
saving: false
@ -111,7 +111,7 @@ export default {
vm.postToStage = post
vm.selectedTagIds = post.tagIds
vm.selectedCategoryIds = post.categoryIds
vm.selectedPostMetas = post.postMetas
vm.selectedMetas = post.metas
})
}
})
@ -276,8 +276,8 @@ export default {
onRefreshCategoryIdsFromSetting(categoryIds) {
this.selectedCategoryIds = categoryIds
},
onRefreshPostMetasFromSetting(postMetas) {
this.selectedPostMetas = postMetas
onRefreshPostMetasFromSetting(metas) {
this.selectedMetas = metas
},
onSaved(isSaved) {
this.isSaved = isSaved

View File

@ -487,7 +487,7 @@
:post="selectedPost"
:tagIds="selectedTagIds"
:categoryIds="selectedCategoryIds"
:postMetas="selectedPostMetas"
:metas="selectedMetas"
:needTitle="true"
:saveDraftButton="false"
:savePublishButton="false"
@ -600,7 +600,7 @@ export default {
columns,
selectedRowKeys: [],
categories: [],
selectedPostMetas: [
selectedMetas: [
{
key: '',
value: ''
@ -749,7 +749,7 @@ export default {
this.selectedPost = response.data.data
this.selectedTagIds = this.selectedPost.tagIds
this.selectedCategoryIds = this.selectedPost.categoryIds
this.selectedPostMetas = this.selectedPost.postMetas
this.selectedMetas = this.selectedPost.metas
this.postSettingVisible = true
})
},
@ -791,8 +791,8 @@ export default {
onRefreshCategoryIdsFromSetting(categoryIds) {
this.selectedCategoryIds = categoryIds
},
onRefreshPostMetasFromSetting(postMetas) {
this.selectedPostMetas = postMetas
onRefreshPostMetasFromSetting(metas) {
this.selectedMetas = metas
}
}
}

View File

@ -238,21 +238,21 @@
<h3 class="post-setting-drawer-title">元数据</h3>
<a-form layout="vertical">
<a-form-item
v-for="(postMeta, index) in selectedPostMetas"
v-for="(meta, index) in selectedMetas"
:key="index"
:prop="'postMetas.' + index + '.value'"
:prop="'metas.' + index + '.value'"
>
<a-row :gutter="5">
<a-col :span="12">
<a-input v-model="postMeta.key"><i slot="addonBefore">K</i></a-input>
<a-input v-model="meta.key"><i slot="addonBefore">K</i></a-input>
</a-col>
<a-col :span="12">
<a-input v-model="postMeta.value">
<a-input v-model="meta.value">
<i slot="addonBefore">V</i>
<a
href="javascript:void(0);"
slot="addonAfter"
@click.prevent="handleRemovePostMeta(postMeta)"
@click.prevent="handleRemovePostMeta(meta)"
>
<a-icon type="close" />
</a>
@ -347,7 +347,7 @@ export default {
type: Array,
required: true
},
postMetas: {
metas: {
type: Array,
required: true
},
@ -396,7 +396,7 @@ export default {
selectedCategoryIds(val) {
this.$emit('onRefreshCategoryIds', val)
},
selectedPostMetas(val) {
selectedMetas(val) {
this.$emit('onRefreshPostMetas', val)
},
visible: function(newValue, oldValue) {
@ -409,10 +409,10 @@ export default {
}
},
computed: {
selectedPostMetas() {
// selectedPostMetasdata
// ,使postMetas
return this.postMetas
selectedMetas() {
// selectedMetasdata
// ,使metas
return this.metas
},
pickerDefaultValue() {
if (this.selectedPost.createTime) {
@ -436,12 +436,12 @@ export default {
})
},
loadPresetMetasField() {
if (this.postMetas.length <= 0) {
if (this.metas.length <= 0) {
themeApi.getActivatedTheme().then(response => {
const fields = response.data.data.postMetaField
if (fields && fields.length > 0) {
for (let i = 0, len = fields.length; i < len; i++) {
this.selectedPostMetas.push({
this.selectedMetas.push({
value: '',
key: fields[i]
})
@ -507,7 +507,7 @@ export default {
// Set tag ids
this.selectedPost.tagIds = this.selectedTagIds
// Set post metas
this.selectedPost.postMetas = this.selectedPostMetas
this.selectedPost.metas = this.selectedMetas
this.saving = true
if (this.selectedPost.id) {
// Update the post
@ -555,13 +555,13 @@ export default {
this.selectedPost.createTime = value.valueOf()
},
handleRemovePostMeta(item) {
var index = this.selectedPostMetas.indexOf(item)
var index = this.selectedMetas.indexOf(item)
if (index !== -1) {
this.selectedPostMetas.splice(index, 1)
this.selectedMetas.splice(index, 1)
}
},
handleInsertPostMeta() {
this.selectedPostMetas.push({
this.selectedMetas.push({
value: '',
key: ''
})

View File

@ -29,7 +29,7 @@
<SheetSettingDrawer
:sheet="sheetToStage"
:sheetMetas="selectedSheetMetas"
:metas="selectedMetas"
:visible="sheetSettingVisible"
@close="onSheetSettingsClose"
@onRefreshSheet="onRefreshSheetFromSetting"
@ -88,7 +88,7 @@ export default {
attachmentDrawerVisible: false,
sheetSettingVisible: false,
sheetToStage: {},
selectedSheetMetas: [],
selectedMetas: [],
isSaved: false,
contentChanges: 0,
saving: false
@ -103,7 +103,7 @@ export default {
sheetApi.get(sheetId).then(response => {
const sheet = response.data.data
vm.sheetToStage = sheet
vm.selectedSheetMetas = sheet.sheetMetas
vm.selectedMetas = sheet.metas
})
}
})
@ -256,8 +256,8 @@ export default {
onRefreshSheetFromSetting(sheet) {
this.sheetToStage = sheet
},
onRefreshSheetMetasFromSetting(sheetMetas) {
this.selectedSheetMetas = sheetMetas
onRefreshSheetMetasFromSetting(metas) {
this.selectedMetas = metas
},
onSaved(isSaved) {
this.isSaved = isSaved

View File

@ -318,7 +318,7 @@
</div>
<SheetSettingDrawer
:sheet="selectedSheet"
:sheetMetas="selectedSheetMetas"
:metas="selectedMetas"
:visible="sheetSettingVisible"
:needTitle="true"
@close="onSheetSettingsClose"
@ -404,7 +404,7 @@ export default {
sheetStatus: sheetApi.sheetStatus,
customColumns,
selectedSheet: {},
selectedSheetMetas: [],
selectedMetas: [],
sheetSettingVisible: false,
sheetCommentVisible: false,
internalSheets: [],
@ -472,7 +472,7 @@ export default {
handleShowSheetSettings(sheet) {
sheetApi.get(sheet.id).then(response => {
this.selectedSheet = response.data.data
this.selectedSheetMetas = this.selectedSheet.sheetMetas
this.selectedMetas = this.selectedSheet.metas
this.sheetSettingVisible = true
})
},
@ -510,8 +510,8 @@ export default {
onRefreshSheetFromSetting(sheet) {
this.selectedSheet = sheet
},
onRefreshSheetMetasFromSetting(sheetMetas) {
this.selectedSheetMetas = sheetMetas
onRefreshSheetMetasFromSetting(metas) {
this.selectedMetas = metas
}
}
}

View File

@ -156,21 +156,21 @@
<h3 class="post-setting-drawer-title">元数据</h3>
<a-form layout="vertical">
<a-form-item
v-for="(sheetMeta, index) in selectedSheetMetas"
v-for="(meta, index) in selectedMetas"
:key="index"
:prop="'sheetMeta.' + index + '.value'"
:prop="'meta.' + index + '.value'"
>
<a-row :gutter="5">
<a-col :span="12">
<a-input v-model="sheetMeta.key"><i slot="addonBefore">K</i></a-input>
<a-input v-model="meta.key"><i slot="addonBefore">K</i></a-input>
</a-col>
<a-col :span="12">
<a-input v-model="sheetMeta.value">
<a-input v-model="meta.value">
<i slot="addonBefore">V</i>
<a
href="javascript:void(0);"
slot="addonAfter"
@click.prevent="handleRemoveSheetMeta(sheetMeta)"
@click.prevent="handleRemoveSheetMeta(meta)"
>
<a-icon type="close" />
</a>
@ -237,7 +237,7 @@ export default {
type: Object,
required: true
},
sheetMetas: {
metas: {
type: Array,
required: true
},
@ -263,7 +263,7 @@ export default {
selectedSheet(val) {
this.$emit('onRefreshSheet', val)
},
selectedSheetMetas(val) {
selectedMetas(val) {
this.$emit('onRefreshSheetMetas', val)
},
visible: function(newValue, oldValue) {
@ -274,8 +274,8 @@ export default {
}
},
computed: {
selectedSheetMetas() {
return this.sheetMetas
selectedMetas() {
return this.metas
},
pickerDefaultValue() {
if (this.selectedSheet.createTime) {
@ -294,12 +294,12 @@ export default {
}, 500)
},
loadPresetMetasField() {
if (this.sheetMetas.length <= 0) {
if (this.metas.length <= 0) {
themeApi.getActivatedTheme().then(response => {
const fields = response.data.data.sheetMetaField
if (fields && fields.length > 0) {
for (let i = 0, len = fields.length; i < len; i++) {
this.selectedSheetMetas.push({
this.selectedMetas.push({
value: '',
key: fields[i]
})
@ -343,7 +343,7 @@ export default {
})
return
}
this.selectedSheet.sheetMetas = this.selectedSheetMetas
this.selectedSheet.metas = this.selectedMetas
this.saving = true
if (this.selectedSheet.id) {
sheetApi
@ -389,13 +389,13 @@ export default {
this.selectedSheet.createTime = value.valueOf()
},
handleRemoveSheetMeta(item) {
var index = this.selectedSheetMetas.indexOf(item)
var index = this.selectedMetas.indexOf(item)
if (index !== -1) {
this.selectedSheetMetas.splice(index, 1)
this.selectedMetas.splice(index, 1)
}
},
handleInsertSheetMeta() {
this.selectedSheetMetas.push({
this.selectedMetas.push({
value: '',
key: ''
})