mirror of https://github.com/halo-dev/halo
主题切换
parent
10e9e91c96
commit
3140152ee1
|
@ -4,6 +4,13 @@ const baseUrl = '/admin/api/themes'
|
||||||
|
|
||||||
const themeApi = {}
|
const themeApi = {}
|
||||||
|
|
||||||
|
themeApi.listAll = () => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
themeApi.listFiles = () => {
|
themeApi.listFiles = () => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/files`,
|
url: `${baseUrl}/files`,
|
||||||
|
@ -18,4 +25,11 @@ themeApi.customTpls = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
themeApi.active = theme => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}/active?theme=${theme}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default themeApi
|
export default themeApi
|
||||||
|
|
|
@ -1,73 +1,95 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="page-header-index-wide">
|
<div class="page-header-index-wide">
|
||||||
<a-row :gutter="12" type="flex" align="middle">
|
<a-row :gutter="12" type="flex" align="middle">
|
||||||
<a-col :xl="6" :lg="6" :md="6" :sm="12" :xs="24">
|
<a-col
|
||||||
<a-card>
|
class="theme-item"
|
||||||
<img alt="example" src="https://ryanc.cc/material/screenshot.png" slot="cover">
|
:xl="6"
|
||||||
<template class="ant-card-actions" slot="actions">
|
:lg="6"
|
||||||
<a-icon type="check"/>
|
:md="12"
|
||||||
<a-icon type="setting"/>
|
:sm="12"
|
||||||
</template>
|
:xs="24"
|
||||||
<a-card-meta title="Anatole"></a-card-meta>
|
v-for="(theme, index) in themes"
|
||||||
</a-card>
|
:key="index">
|
||||||
</a-col>
|
<a-card :bodyStyle="{ padding: '14px' }">
|
||||||
<a-col :xl="6" :lg="6" :md="6" :sm="12" :xs="24">
|
<img
|
||||||
<a-card>
|
:alt="theme.properties.name"
|
||||||
<img alt="example" src="https://ryanc.cc/material/screenshot.png" slot="cover">
|
:src="'http://localhost:8090/' + theme.key + '/screenshot.png'"
|
||||||
<template class="ant-card-actions" slot="actions">
|
slot="cover"
|
||||||
<a-icon type="check"/>
|
/>
|
||||||
<a-icon type="setting"/>
|
<a-divider></a-divider>
|
||||||
</template>
|
<div class="theme-control">
|
||||||
<a-card-meta title="Anatole"></a-card-meta>
|
<span class="theme-title">
|
||||||
</a-card>
|
{{ theme.properties.name }}
|
||||||
</a-col>
|
</span>
|
||||||
<a-col :xl="6" :lg="6" :md="6" :sm="12" :xs="24">
|
<a-button-group class="theme-button">
|
||||||
<a-card>
|
<a-button type="primary" v-if="activatedTheme==theme.key" disabled>已启用</a-button>
|
||||||
<img alt="example" src="https://ryanc.cc/material/screenshot.png" slot="cover">
|
<a-button type="primary" @click="activeTheme(theme.key)" v-else>启用</a-button>
|
||||||
<template class="ant-card-actions" slot="actions">
|
<a-button @click="optionModal(theme.key)">设置</a-button>
|
||||||
<a-icon type="check"/>
|
</a-button-group>
|
||||||
<a-icon type="setting"/>
|
</div>
|
||||||
</template>
|
|
||||||
<a-card-meta title="Anatole"></a-card-meta>
|
|
||||||
</a-card>
|
|
||||||
</a-col>
|
|
||||||
<a-col :xl="6" :lg="6" :md="6" :sm="12" :xs="24">
|
|
||||||
<a-card>
|
|
||||||
<img alt="example" src="https://ryanc.cc/material/screenshot.png" slot="cover">
|
|
||||||
<template class="ant-card-actions" slot="actions">
|
|
||||||
<a-icon type="check"/>
|
|
||||||
<a-icon type="setting"/>
|
|
||||||
</template>
|
|
||||||
<a-card-meta title="Anatole"></a-card-meta>
|
|
||||||
</a-card>
|
|
||||||
</a-col>
|
|
||||||
<a-col :xl="6" :lg="6" :md="6" :sm="12" :xs="24">
|
|
||||||
<a-card>
|
|
||||||
<img alt="example" src="https://ryanc.cc/material/screenshot.png" slot="cover">
|
|
||||||
<template class="ant-card-actions" slot="actions">
|
|
||||||
<a-icon type="check"/>
|
|
||||||
<a-icon type="setting"/>
|
|
||||||
</template>
|
|
||||||
<a-card-meta title="Anatole"></a-card-meta>
|
|
||||||
</a-card>
|
|
||||||
</a-col>
|
|
||||||
<a-col :xl="6" :lg="6" :md="6" :sm="12" :xs="24">
|
|
||||||
<a-card>
|
|
||||||
<img alt="example" src="https://ryanc.cc/material/screenshot.png" slot="cover">
|
|
||||||
<template class="ant-card-actions" slot="actions">
|
|
||||||
<a-icon type="check"/>
|
|
||||||
<a-icon type="setting"/>
|
|
||||||
</template>
|
|
||||||
<a-card-meta title="Anatole"></a-card-meta>
|
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
<a-modal
|
||||||
|
:title="optionTheme+' 主题设置'"
|
||||||
|
width="90%"
|
||||||
|
v-model="visible"
|
||||||
|
>
|
||||||
|
<iframe :src="optionUrl" height="560" width="100%" frameborder="0" scrolling="auto"></iframe>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {}
|
import themeApi from '@/api/theme'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
themes: [],
|
||||||
|
visible: false,
|
||||||
|
optionTheme: '',
|
||||||
|
optionUrl: 'https://ryanc.cc',
|
||||||
|
activatedTheme: 'anatole'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.loadThemes()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadThemes() {
|
||||||
|
themeApi.listAll().then(response => {
|
||||||
|
this.themes = response.data.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
optionModal(theme) {
|
||||||
|
this.optionTheme = theme
|
||||||
|
this.visible = true
|
||||||
|
},
|
||||||
|
activeTheme(theme) {
|
||||||
|
themeApi.active(theme).then(response => {
|
||||||
|
this.activatedTheme = theme
|
||||||
|
this.$message.success('设置成功!')
|
||||||
|
this.loadThemes()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.ant-divider-horizontal{
|
||||||
|
margin: 14px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-item {
|
||||||
|
padding-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-item .theme-control .theme-title{
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-item .theme-control .theme-button{
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<a-card>
|
<a-card>
|
||||||
<div id="editor">
|
<div id="editor">
|
||||||
<mavon-editor :toolbars="markdownOption" v-model="value" :boxShadow="false" :ishljs = "true"/>
|
<mavon-editor :toolbars="markdownOption" v-model="value" :boxShadow="false" :ishljs="true"/>
|
||||||
</div>
|
</div>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
Loading…
Reference in New Issue