mirror of https://github.com/halo-dev/halo
refactor : meta variable (halo-dev/console#92)
* 1.3.0-beta.2 * refactor: metas variable. * refactor: metas variable.pull/3445/head
parent
ea0b2df06d
commit
e0b7da7a77
|
@ -31,7 +31,7 @@
|
||||||
:post="postToStage"
|
:post="postToStage"
|
||||||
:tagIds="selectedTagIds"
|
:tagIds="selectedTagIds"
|
||||||
:categoryIds="selectedCategoryIds"
|
:categoryIds="selectedCategoryIds"
|
||||||
:postMetas="selectedPostMetas"
|
:metas="selectedMetas"
|
||||||
:visible="postSettingVisible"
|
:visible="postSettingVisible"
|
||||||
@close="onPostSettingsClose"
|
@close="onPostSettingsClose"
|
||||||
@onRefreshPost="onRefreshPostFromSetting"
|
@onRefreshPost="onRefreshPostFromSetting"
|
||||||
|
@ -95,7 +95,7 @@ export default {
|
||||||
postToStage: {},
|
postToStage: {},
|
||||||
selectedTagIds: [],
|
selectedTagIds: [],
|
||||||
selectedCategoryIds: [],
|
selectedCategoryIds: [],
|
||||||
selectedPostMetas: [],
|
selectedMetas: [],
|
||||||
isSaved: false,
|
isSaved: false,
|
||||||
contentChanges: 0,
|
contentChanges: 0,
|
||||||
saving: false
|
saving: false
|
||||||
|
@ -111,7 +111,7 @@ export default {
|
||||||
vm.postToStage = post
|
vm.postToStage = post
|
||||||
vm.selectedTagIds = post.tagIds
|
vm.selectedTagIds = post.tagIds
|
||||||
vm.selectedCategoryIds = post.categoryIds
|
vm.selectedCategoryIds = post.categoryIds
|
||||||
vm.selectedPostMetas = post.postMetas
|
vm.selectedMetas = post.metas
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -276,8 +276,8 @@ export default {
|
||||||
onRefreshCategoryIdsFromSetting(categoryIds) {
|
onRefreshCategoryIdsFromSetting(categoryIds) {
|
||||||
this.selectedCategoryIds = categoryIds
|
this.selectedCategoryIds = categoryIds
|
||||||
},
|
},
|
||||||
onRefreshPostMetasFromSetting(postMetas) {
|
onRefreshPostMetasFromSetting(metas) {
|
||||||
this.selectedPostMetas = postMetas
|
this.selectedMetas = metas
|
||||||
},
|
},
|
||||||
onSaved(isSaved) {
|
onSaved(isSaved) {
|
||||||
this.isSaved = isSaved
|
this.isSaved = isSaved
|
||||||
|
|
|
@ -487,7 +487,7 @@
|
||||||
:post="selectedPost"
|
:post="selectedPost"
|
||||||
:tagIds="selectedTagIds"
|
:tagIds="selectedTagIds"
|
||||||
:categoryIds="selectedCategoryIds"
|
:categoryIds="selectedCategoryIds"
|
||||||
:postMetas="selectedPostMetas"
|
:metas="selectedMetas"
|
||||||
:needTitle="true"
|
:needTitle="true"
|
||||||
:saveDraftButton="false"
|
:saveDraftButton="false"
|
||||||
:savePublishButton="false"
|
:savePublishButton="false"
|
||||||
|
@ -600,7 +600,7 @@ export default {
|
||||||
columns,
|
columns,
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
categories: [],
|
categories: [],
|
||||||
selectedPostMetas: [
|
selectedMetas: [
|
||||||
{
|
{
|
||||||
key: '',
|
key: '',
|
||||||
value: ''
|
value: ''
|
||||||
|
@ -749,7 +749,7 @@ export default {
|
||||||
this.selectedPost = response.data.data
|
this.selectedPost = response.data.data
|
||||||
this.selectedTagIds = this.selectedPost.tagIds
|
this.selectedTagIds = this.selectedPost.tagIds
|
||||||
this.selectedCategoryIds = this.selectedPost.categoryIds
|
this.selectedCategoryIds = this.selectedPost.categoryIds
|
||||||
this.selectedPostMetas = this.selectedPost.postMetas
|
this.selectedMetas = this.selectedPost.metas
|
||||||
this.postSettingVisible = true
|
this.postSettingVisible = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -791,8 +791,8 @@ export default {
|
||||||
onRefreshCategoryIdsFromSetting(categoryIds) {
|
onRefreshCategoryIdsFromSetting(categoryIds) {
|
||||||
this.selectedCategoryIds = categoryIds
|
this.selectedCategoryIds = categoryIds
|
||||||
},
|
},
|
||||||
onRefreshPostMetasFromSetting(postMetas) {
|
onRefreshPostMetasFromSetting(metas) {
|
||||||
this.selectedPostMetas = postMetas
|
this.selectedMetas = metas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,21 +238,21 @@
|
||||||
<h3 class="post-setting-drawer-title">元数据</h3>
|
<h3 class="post-setting-drawer-title">元数据</h3>
|
||||||
<a-form layout="vertical">
|
<a-form layout="vertical">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
v-for="(postMeta, index) in selectedPostMetas"
|
v-for="(meta, index) in selectedMetas"
|
||||||
:key="index"
|
:key="index"
|
||||||
:prop="'postMetas.' + index + '.value'"
|
:prop="'metas.' + index + '.value'"
|
||||||
>
|
>
|
||||||
<a-row :gutter="5">
|
<a-row :gutter="5">
|
||||||
<a-col :span="12">
|
<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>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-input v-model="postMeta.value">
|
<a-input v-model="meta.value">
|
||||||
<i slot="addonBefore">V</i>
|
<i slot="addonBefore">V</i>
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
slot="addonAfter"
|
slot="addonAfter"
|
||||||
@click.prevent="handleRemovePostMeta(postMeta)"
|
@click.prevent="handleRemovePostMeta(meta)"
|
||||||
>
|
>
|
||||||
<a-icon type="close" />
|
<a-icon type="close" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -347,7 +347,7 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
postMetas: {
|
metas: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
@ -396,7 +396,7 @@ export default {
|
||||||
selectedCategoryIds(val) {
|
selectedCategoryIds(val) {
|
||||||
this.$emit('onRefreshCategoryIds', val)
|
this.$emit('onRefreshCategoryIds', val)
|
||||||
},
|
},
|
||||||
selectedPostMetas(val) {
|
selectedMetas(val) {
|
||||||
this.$emit('onRefreshPostMetas', val)
|
this.$emit('onRefreshPostMetas', val)
|
||||||
},
|
},
|
||||||
visible: function(newValue, oldValue) {
|
visible: function(newValue, oldValue) {
|
||||||
|
@ -409,10 +409,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
selectedPostMetas() {
|
selectedMetas() {
|
||||||
// 不能将selectedPostMetas直接定义在data里
|
// 不能将selectedMetas直接定义在data里
|
||||||
// 还没有获取到值就渲染视图,可以直接使用postMetas
|
// 还没有获取到值就渲染视图,可以直接使用metas
|
||||||
return this.postMetas
|
return this.metas
|
||||||
},
|
},
|
||||||
pickerDefaultValue() {
|
pickerDefaultValue() {
|
||||||
if (this.selectedPost.createTime) {
|
if (this.selectedPost.createTime) {
|
||||||
|
@ -436,12 +436,12 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadPresetMetasField() {
|
loadPresetMetasField() {
|
||||||
if (this.postMetas.length <= 0) {
|
if (this.metas.length <= 0) {
|
||||||
themeApi.getActivatedTheme().then(response => {
|
themeApi.getActivatedTheme().then(response => {
|
||||||
const fields = response.data.data.postMetaField
|
const fields = response.data.data.postMetaField
|
||||||
if (fields && fields.length > 0) {
|
if (fields && fields.length > 0) {
|
||||||
for (let i = 0, len = fields.length; i < len; i++) {
|
for (let i = 0, len = fields.length; i < len; i++) {
|
||||||
this.selectedPostMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: fields[i]
|
key: fields[i]
|
||||||
})
|
})
|
||||||
|
@ -507,7 +507,7 @@ export default {
|
||||||
// Set tag ids
|
// Set tag ids
|
||||||
this.selectedPost.tagIds = this.selectedTagIds
|
this.selectedPost.tagIds = this.selectedTagIds
|
||||||
// Set post metas
|
// Set post metas
|
||||||
this.selectedPost.postMetas = this.selectedPostMetas
|
this.selectedPost.metas = this.selectedMetas
|
||||||
this.saving = true
|
this.saving = true
|
||||||
if (this.selectedPost.id) {
|
if (this.selectedPost.id) {
|
||||||
// Update the post
|
// Update the post
|
||||||
|
@ -555,13 +555,13 @@ export default {
|
||||||
this.selectedPost.createTime = value.valueOf()
|
this.selectedPost.createTime = value.valueOf()
|
||||||
},
|
},
|
||||||
handleRemovePostMeta(item) {
|
handleRemovePostMeta(item) {
|
||||||
var index = this.selectedPostMetas.indexOf(item)
|
var index = this.selectedMetas.indexOf(item)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.selectedPostMetas.splice(index, 1)
|
this.selectedMetas.splice(index, 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleInsertPostMeta() {
|
handleInsertPostMeta() {
|
||||||
this.selectedPostMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: ''
|
key: ''
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
<SheetSettingDrawer
|
<SheetSettingDrawer
|
||||||
:sheet="sheetToStage"
|
:sheet="sheetToStage"
|
||||||
:sheetMetas="selectedSheetMetas"
|
:metas="selectedMetas"
|
||||||
:visible="sheetSettingVisible"
|
:visible="sheetSettingVisible"
|
||||||
@close="onSheetSettingsClose"
|
@close="onSheetSettingsClose"
|
||||||
@onRefreshSheet="onRefreshSheetFromSetting"
|
@onRefreshSheet="onRefreshSheetFromSetting"
|
||||||
|
@ -88,7 +88,7 @@ export default {
|
||||||
attachmentDrawerVisible: false,
|
attachmentDrawerVisible: false,
|
||||||
sheetSettingVisible: false,
|
sheetSettingVisible: false,
|
||||||
sheetToStage: {},
|
sheetToStage: {},
|
||||||
selectedSheetMetas: [],
|
selectedMetas: [],
|
||||||
isSaved: false,
|
isSaved: false,
|
||||||
contentChanges: 0,
|
contentChanges: 0,
|
||||||
saving: false
|
saving: false
|
||||||
|
@ -103,7 +103,7 @@ export default {
|
||||||
sheetApi.get(sheetId).then(response => {
|
sheetApi.get(sheetId).then(response => {
|
||||||
const sheet = response.data.data
|
const sheet = response.data.data
|
||||||
vm.sheetToStage = sheet
|
vm.sheetToStage = sheet
|
||||||
vm.selectedSheetMetas = sheet.sheetMetas
|
vm.selectedMetas = sheet.metas
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -256,8 +256,8 @@ export default {
|
||||||
onRefreshSheetFromSetting(sheet) {
|
onRefreshSheetFromSetting(sheet) {
|
||||||
this.sheetToStage = sheet
|
this.sheetToStage = sheet
|
||||||
},
|
},
|
||||||
onRefreshSheetMetasFromSetting(sheetMetas) {
|
onRefreshSheetMetasFromSetting(metas) {
|
||||||
this.selectedSheetMetas = sheetMetas
|
this.selectedMetas = metas
|
||||||
},
|
},
|
||||||
onSaved(isSaved) {
|
onSaved(isSaved) {
|
||||||
this.isSaved = isSaved
|
this.isSaved = isSaved
|
||||||
|
|
|
@ -318,7 +318,7 @@
|
||||||
</div>
|
</div>
|
||||||
<SheetSettingDrawer
|
<SheetSettingDrawer
|
||||||
:sheet="selectedSheet"
|
:sheet="selectedSheet"
|
||||||
:sheetMetas="selectedSheetMetas"
|
:metas="selectedMetas"
|
||||||
:visible="sheetSettingVisible"
|
:visible="sheetSettingVisible"
|
||||||
:needTitle="true"
|
:needTitle="true"
|
||||||
@close="onSheetSettingsClose"
|
@close="onSheetSettingsClose"
|
||||||
|
@ -404,7 +404,7 @@ export default {
|
||||||
sheetStatus: sheetApi.sheetStatus,
|
sheetStatus: sheetApi.sheetStatus,
|
||||||
customColumns,
|
customColumns,
|
||||||
selectedSheet: {},
|
selectedSheet: {},
|
||||||
selectedSheetMetas: [],
|
selectedMetas: [],
|
||||||
sheetSettingVisible: false,
|
sheetSettingVisible: false,
|
||||||
sheetCommentVisible: false,
|
sheetCommentVisible: false,
|
||||||
internalSheets: [],
|
internalSheets: [],
|
||||||
|
@ -472,7 +472,7 @@ export default {
|
||||||
handleShowSheetSettings(sheet) {
|
handleShowSheetSettings(sheet) {
|
||||||
sheetApi.get(sheet.id).then(response => {
|
sheetApi.get(sheet.id).then(response => {
|
||||||
this.selectedSheet = response.data.data
|
this.selectedSheet = response.data.data
|
||||||
this.selectedSheetMetas = this.selectedSheet.sheetMetas
|
this.selectedMetas = this.selectedSheet.metas
|
||||||
this.sheetSettingVisible = true
|
this.sheetSettingVisible = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -510,8 +510,8 @@ export default {
|
||||||
onRefreshSheetFromSetting(sheet) {
|
onRefreshSheetFromSetting(sheet) {
|
||||||
this.selectedSheet = sheet
|
this.selectedSheet = sheet
|
||||||
},
|
},
|
||||||
onRefreshSheetMetasFromSetting(sheetMetas) {
|
onRefreshSheetMetasFromSetting(metas) {
|
||||||
this.selectedSheetMetas = sheetMetas
|
this.selectedMetas = metas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,21 +156,21 @@
|
||||||
<h3 class="post-setting-drawer-title">元数据</h3>
|
<h3 class="post-setting-drawer-title">元数据</h3>
|
||||||
<a-form layout="vertical">
|
<a-form layout="vertical">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
v-for="(sheetMeta, index) in selectedSheetMetas"
|
v-for="(meta, index) in selectedMetas"
|
||||||
:key="index"
|
:key="index"
|
||||||
:prop="'sheetMeta.' + index + '.value'"
|
:prop="'meta.' + index + '.value'"
|
||||||
>
|
>
|
||||||
<a-row :gutter="5">
|
<a-row :gutter="5">
|
||||||
<a-col :span="12">
|
<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>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-input v-model="sheetMeta.value">
|
<a-input v-model="meta.value">
|
||||||
<i slot="addonBefore">V</i>
|
<i slot="addonBefore">V</i>
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
slot="addonAfter"
|
slot="addonAfter"
|
||||||
@click.prevent="handleRemoveSheetMeta(sheetMeta)"
|
@click.prevent="handleRemoveSheetMeta(meta)"
|
||||||
>
|
>
|
||||||
<a-icon type="close" />
|
<a-icon type="close" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -237,7 +237,7 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
sheetMetas: {
|
metas: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
@ -263,7 +263,7 @@ export default {
|
||||||
selectedSheet(val) {
|
selectedSheet(val) {
|
||||||
this.$emit('onRefreshSheet', val)
|
this.$emit('onRefreshSheet', val)
|
||||||
},
|
},
|
||||||
selectedSheetMetas(val) {
|
selectedMetas(val) {
|
||||||
this.$emit('onRefreshSheetMetas', val)
|
this.$emit('onRefreshSheetMetas', val)
|
||||||
},
|
},
|
||||||
visible: function(newValue, oldValue) {
|
visible: function(newValue, oldValue) {
|
||||||
|
@ -274,8 +274,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
selectedSheetMetas() {
|
selectedMetas() {
|
||||||
return this.sheetMetas
|
return this.metas
|
||||||
},
|
},
|
||||||
pickerDefaultValue() {
|
pickerDefaultValue() {
|
||||||
if (this.selectedSheet.createTime) {
|
if (this.selectedSheet.createTime) {
|
||||||
|
@ -294,12 +294,12 @@ export default {
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
loadPresetMetasField() {
|
loadPresetMetasField() {
|
||||||
if (this.sheetMetas.length <= 0) {
|
if (this.metas.length <= 0) {
|
||||||
themeApi.getActivatedTheme().then(response => {
|
themeApi.getActivatedTheme().then(response => {
|
||||||
const fields = response.data.data.sheetMetaField
|
const fields = response.data.data.sheetMetaField
|
||||||
if (fields && fields.length > 0) {
|
if (fields && fields.length > 0) {
|
||||||
for (let i = 0, len = fields.length; i < len; i++) {
|
for (let i = 0, len = fields.length; i < len; i++) {
|
||||||
this.selectedSheetMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: fields[i]
|
key: fields[i]
|
||||||
})
|
})
|
||||||
|
@ -343,7 +343,7 @@ export default {
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.selectedSheet.sheetMetas = this.selectedSheetMetas
|
this.selectedSheet.metas = this.selectedMetas
|
||||||
this.saving = true
|
this.saving = true
|
||||||
if (this.selectedSheet.id) {
|
if (this.selectedSheet.id) {
|
||||||
sheetApi
|
sheetApi
|
||||||
|
@ -389,13 +389,13 @@ export default {
|
||||||
this.selectedSheet.createTime = value.valueOf()
|
this.selectedSheet.createTime = value.valueOf()
|
||||||
},
|
},
|
||||||
handleRemoveSheetMeta(item) {
|
handleRemoveSheetMeta(item) {
|
||||||
var index = this.selectedSheetMetas.indexOf(item)
|
var index = this.selectedMetas.indexOf(item)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.selectedSheetMetas.splice(index, 1)
|
this.selectedMetas.splice(index, 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleInsertSheetMeta() {
|
handleInsertSheetMeta() {
|
||||||
this.selectedSheetMetas.push({
|
this.selectedMetas.push({
|
||||||
value: '',
|
value: '',
|
||||||
key: ''
|
key: ''
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue