Skip to content

Commit

Permalink
Merge branch 'pr/143'
Browse files Browse the repository at this point in the history
  • Loading branch information
linhaojun857 committed Aug 27, 2023
2 parents dfbb50a + 0e2f607 commit f4ef19b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,16 @@ public class WebsiteConfigDTO {

private String alipayQRCode;

private String favicon;

/**
* 网页标题
*/
private String websiteTitle;

/**
* 公安部备案编号
*/
private String gonganBeianNumber;

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@ public class WebsiteConfigVO {
@ApiModelProperty(name = "alipayQRCode", value = "支付宝二维码", required = true, dataType = "String")
private String alipayQRCode;

@ApiModelProperty(name = "favicon", value = "favicon", required = true, dataType = "String")
private String favicon;

@ApiModelProperty(name = "websiteTitle", value = "网页标题", required = true, dataType = "String")
private String websiteTitle;

@ApiModelProperty(name = "gonganBeianNumber", value = "公安部备案编号", required = true, dataType = "String")
private String gonganBeianNumber;

}
23 changes: 22 additions & 1 deletion aurora-vue/aurora-admin/src/views/website/Website.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
<el-form-item label="favicon">
<el-upload
class="avatar-uploader"
action="/api/admin/config/images"
:headers="headers"
:show-file-list="false"
:before-upload="beforeUpload"
:on-success="handleFaviconSuccess">
<img v-if="websiteConfigForm.favicon" :src="websiteConfigForm.favicon" class="avatar" />
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
<el-form-item label="网站名称">
<el-input v-model="websiteConfigForm.name" size="small" style="width: 400px" />
</el-form-item>
Expand All @@ -36,6 +48,9 @@
<el-form-item label="网站作者">
<el-input v-model="websiteConfigForm.author" size="small" style="width: 400px" />
</el-form-item>
<el-form-item label="网页标题">
<el-input v-model="websiteConfigForm.websiteTitle" size="small" style="width: 400px" />
</el-form-item>
<el-form-item label="作者介绍">
<el-input v-model="websiteConfigForm.authorIntro" size="small" style="width: 400px" />
</el-form-item>
Expand All @@ -61,9 +76,12 @@
type="textarea"
:rows="5" />
</el-form-item>
<el-form-item label="备案号">
<el-form-item label="工信部备案号">
<el-input v-model="websiteConfigForm.beianNumber" size="small" style="width: 400px" />
</el-form-item>
<el-form-item label="公安部备案号">
<el-input v-model="websiteConfigForm.gonganBeianNumber" size="small" style="width: 400px" />
</el-form-item>
<el-form-item label="qq登录">
<el-radio-group v-model="websiteConfigForm.qqLogin">
<el-radio :label="0">关闭</el-radio>
Expand Down Expand Up @@ -225,6 +243,9 @@ export default {
handleAuthorAvatarSuccess(response) {
this.websiteConfigForm.authorAvatar = response.data
},
handleFaviconSuccess(response) {
this.websiteConfigForm.favicon = response.favicon
},
handleLogoSuccess(response) {
this.websiteConfigForm.logo = response.data
},
Expand Down
26 changes: 25 additions & 1 deletion aurora-vue/aurora-blog/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default defineComponent({
appStore.categoryCount = data.data.categoryCount
appStore.tagCount = data.data.tagCount
appStore.websiteConfig = data.data.websiteConfigDTO
initFavicon(data.data.websiteConfigDTO.favicon)
})
}
const copyEventHandler = (event: any) => {
Expand Down Expand Up @@ -130,8 +131,31 @@ export default defineComponent({
}, 10)
}
}
const initFavicon = (faviconUrl: string) => {
if (!faviconUrl) {
return
}
// 获取 head 标签
var head = document.getElementsByTagName('head')[0];
// 获取当前 favicon 元素
var favicon = document.querySelector("link[rel*='icon']") || document.createElement('link');
// Cast favicon to HTMLLinkElement
var faviconLink = favicon as HTMLLinkElement;
faviconLink.type = 'image/x-icon';
faviconLink.rel = 'shortcut icon';
// 设置新的 favicon 地址
faviconLink.href = faviconUrl;
// 如果当前 head 标签中不存在 favicon 元素,则将新的 favicon 添加到 head 标签中
if (!document.querySelector("link[rel*='icon']")) {
head.appendChild(faviconLink);
}
}
console.log(computed(() => appStore.themeConfig.theme))
return {
title: metaStore.title,
title: computed(() => appStore.websiteConfig.websiteTitle || metaStore.title),
theme: computed(() => appStore.themeConfig.theme),
headerImage: computed(() => {
return {
Expand Down
6 changes: 4 additions & 2 deletions aurora-vue/aurora-blog/src/components/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
</template>

<script lang="ts">
import { defineComponent, toRefs } from 'vue'
import { defineComponent, toRefs, computed } from 'vue'
import { useAppStore } from '@/stores/app'
export default defineComponent({
name: 'Avatar',
props: ['url'],
setup(props) {
const appStore = useAppStore()
return {
url: toRefs(props).url,
default: 'https://static.linhaojun.top/aurora/config/52a81cd2772167b645569342e81ce312.jpg'
default: computed(() => appStore.websiteConfig.touristAvatar || 'https://static.linhaojun.top/aurora/config/52a81cd2772167b645569342e81ce312.jpg')
}
}
})
Expand Down
12 changes: 9 additions & 3 deletions aurora-vue/aurora-blog/src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
<div
class="flex flex-col lg:flex-row gap-6 lg:gap-12 row-span-1 lg:col-span-5 text-center lg:text-left mx-auto">
<ul class="flex flex-col gap-2 mx-auto">
<li>
<li class="flex flex-row mx-auto">
Copyright © 2022 - {{ currentYear }}
<b class="font-extrabold">{{ websiteConfig.author }}</b>
<b class="font-extrabold">&nbsp;{{ websiteConfig.author }}</b>
</li>
<li v-if="websiteConfig.beian_number != ''" class="flex flex-row mx-auto">
<li v-if="websiteConfig.gonganBeianNumber != '' && websiteConfig.gonganBeianNumber != undefined" class="flex flex-row mx-auto">
<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11011402013558" target="_blank">
<img src="https://oss.supermouse.cn/aurora/config/gongan-beian-icon.png" style="float:left;"/> &nbsp;
<b class="font-extrabold border-b-2 border-ob hover:text-ob"> {{ websiteConfig.gonganBeianNumber }} </b>
</a>
</li>
<li v-if="websiteConfig.beianNumber != '' && websiteConfig.beianNumber != undefined" class="flex flex-row mx-auto">
<a href="https://beian.miit.gov.cn/" target="_blank">
<b class="font-extrabold border-b-2 border-ob hover:text-ob"> {{ websiteConfig.beianNumber }} </b>
</a>
Expand Down

0 comments on commit f4ef19b

Please sign in to comment.