mirror of https://github.com/halo-dev/halo-admin
动态生成主题设置选项表单
parent
c580207c4f
commit
16808e17c4
|
@ -39,4 +39,10 @@ themeApi.delete = key => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
themeApi.listOptions = theme => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/configurations?name=${theme}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default themeApi
|
export default themeApi
|
||||||
|
|
|
@ -16,12 +16,10 @@
|
||||||
:alt="theme.properties.name"
|
:alt="theme.properties.name"
|
||||||
:src="'http://localhost:8090/' + theme.key + '/screenshot.png'"
|
:src="'http://localhost:8090/' + theme.key + '/screenshot.png'"
|
||||||
slot="cover"
|
slot="cover"
|
||||||
/>
|
>
|
||||||
<a-divider></a-divider>
|
<a-divider></a-divider>
|
||||||
<div class="theme-control">
|
<div class="theme-control">
|
||||||
<span class="theme-title">
|
<span class="theme-title">{{ theme.properties.name }}</span>
|
||||||
{{ theme.properties.name }}
|
|
||||||
</span>
|
|
||||||
<a-button-group class="theme-button">
|
<a-button-group class="theme-button">
|
||||||
<a-button type="primary" v-if="activatedTheme == theme.key" disabled>已启用</a-button>
|
<a-button type="primary" v-if="activatedTheme == theme.key" disabled>已启用</a-button>
|
||||||
<a-button type="primary" @click="activeTheme(theme.key)" v-else>启用</a-button>
|
<a-button type="primary" @click="activeTheme(theme.key)" v-else>启用</a-button>
|
||||||
|
@ -41,22 +39,84 @@
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-modal :title="optionTheme + ' 主题设置'" width="90%" v-model="visible">
|
<a-modal :title="optionTheme + ' 主题设置'" width="90%" v-model="visible">
|
||||||
<iframe :src="optionUrl" height="560" width="100%" frameborder="0" scrolling="auto"></iframe>
|
<a-row>
|
||||||
|
<a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
|
||||||
|
<div class="card-container">
|
||||||
|
<a-tabs type="card">
|
||||||
|
<a-tab-pane
|
||||||
|
v-for="(group,index) in themeOptions"
|
||||||
|
:key="index"
|
||||||
|
:tab="group.description"
|
||||||
|
>
|
||||||
|
<a-form layout="vertical">
|
||||||
|
<a-form-item
|
||||||
|
v-for="(item,index1) in group.items"
|
||||||
|
:label="item.description+':'"
|
||||||
|
:key="index1"
|
||||||
|
:wrapper-col="wrapperCol"
|
||||||
|
>
|
||||||
|
<a-input :v-model="'options.'+item.description" v-if="item.type=='text'"/>
|
||||||
|
<a-input
|
||||||
|
type="textarea"
|
||||||
|
:autosize="{ minRows: 5 }"
|
||||||
|
:v-model="'options.'+item.description"
|
||||||
|
v-else-if="item.type=='textarea'"
|
||||||
|
/>
|
||||||
|
<a-radio-group
|
||||||
|
v-decorator="['radio-group']"
|
||||||
|
defaultValue="false"
|
||||||
|
:v-model="'options.'+item.description"
|
||||||
|
v-else-if="item.type=='radio'"
|
||||||
|
>
|
||||||
|
<a-radio
|
||||||
|
v-for="(option,index2) in item.options"
|
||||||
|
:key="index2"
|
||||||
|
:value="option.value"
|
||||||
|
>{{ option.label }}</a-radio>
|
||||||
|
</a-radio-group>
|
||||||
|
<a-select
|
||||||
|
:v-model="'options.'+item.description"
|
||||||
|
v-else-if="item.type=='select'"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="(option,index3) in item.options"
|
||||||
|
:key="index3"
|
||||||
|
:value="option.value"
|
||||||
|
>{{ option.label }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-button type="primary" @click="saveOptions">保存</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-tab-pane>
|
||||||
|
</a-tabs>
|
||||||
|
</div>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import themeApi from '@/api/theme'
|
import themeApi from '@/api/theme'
|
||||||
|
import optionApi from '@/api/option'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
wrapperCol: {
|
||||||
|
xl: { span: 8 },
|
||||||
|
sm: { span: 8 },
|
||||||
|
xs: { span: 24 }
|
||||||
|
},
|
||||||
themes: [],
|
themes: [],
|
||||||
visible: false,
|
visible: false,
|
||||||
optionTheme: '',
|
optionTheme: '',
|
||||||
optionUrl: 'https://ryanc.cc',
|
optionUrl: 'https://ryanc.cc',
|
||||||
// TODO 从api获取当前使用的主题
|
// TODO 从api获取当前使用的主题
|
||||||
activatedTheme: 'anatole'
|
activatedTheme: 'anatole',
|
||||||
|
themeOptions: [],
|
||||||
|
options: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -69,8 +129,12 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
optionModal(theme) {
|
optionModal(theme) {
|
||||||
|
themeApi.listOptions('anatole').then(response => {
|
||||||
|
this.themeOptions = response.data.data
|
||||||
this.optionTheme = theme
|
this.optionTheme = theme
|
||||||
this.visible = true
|
this.visible = true
|
||||||
|
this.loadOptions()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
activeTheme(theme) {
|
activeTheme(theme) {
|
||||||
themeApi.active(theme).then(response => {
|
themeApi.active(theme).then(response => {
|
||||||
|
@ -84,6 +148,17 @@ export default {
|
||||||
this.$message.success('删除成功!')
|
this.$message.success('删除成功!')
|
||||||
this.loadThemes()
|
this.loadThemes()
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
saveOptions() {
|
||||||
|
optionApi.save(this.options).then(response => {
|
||||||
|
this.loadOptions()
|
||||||
|
this.$message.success('保存成功!')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadOptions() {
|
||||||
|
optionApi.listAll().then(response => {
|
||||||
|
this.options = response.data.data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue