2022-04-08 02:42:44 +00:00
|
|
|
|
<!-- 网站信息 -->
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="website-information">
|
|
|
|
|
|
<el-card shadow="never" class="m-t-15">
|
|
|
|
|
|
<el-form
|
|
|
|
|
|
ref="formRef"
|
|
|
|
|
|
:rules="rules"
|
|
|
|
|
|
class="ls-form"
|
|
|
|
|
|
:model="formData"
|
|
|
|
|
|
label-width="150px"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-form-item label="网站名称" prop="name">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="formData.name"
|
|
|
|
|
|
placeholder="请输入网站名称"
|
|
|
|
|
|
maxlength="12"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
></el-input>
|
|
|
|
|
|
</el-form-item>
|
2022-04-14 08:22:13 +00:00
|
|
|
|
<el-form-item label="网站图标" prop="favicon">
|
2022-04-13 09:38:53 +00:00
|
|
|
|
<material-select v-model="formData.favicon" :limit="1" />
|
2022-04-08 02:42:44 +00:00
|
|
|
|
<div class="flex">
|
|
|
|
|
|
<div class="muted xs m-r-16">
|
|
|
|
|
|
建议尺寸:100*100像素,支持jpg,jpeg,png格式
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-popover placement="right" width="200" trigger="hover">
|
|
|
|
|
|
<el-image
|
|
|
|
|
|
src="https://img2.baidu.com/it/u=3357699356,1912406716&fm=26&fmt=auto&gp=0.jpg"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-button slot="reference" type="text">查看示例</el-button>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
2022-04-14 08:22:13 +00:00
|
|
|
|
<el-form-item label="网站LOGO" prop="logo">
|
2022-04-13 09:38:53 +00:00
|
|
|
|
<material-select v-model="formData.logo" :limit="1" />
|
2022-04-08 02:42:44 +00:00
|
|
|
|
<div class="flex">
|
|
|
|
|
|
<div class="muted xs m-r-16">
|
|
|
|
|
|
建议尺寸:100*100像素,支持jpg,jpeg,png格式
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-popover placement="right" width="200" trigger="hover">
|
|
|
|
|
|
<el-image
|
|
|
|
|
|
src="https://img2.baidu.com/it/u=3357699356,1912406716&fm=26&fmt=auto&gp=0.jpg"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-button slot="reference" type="text">查看示例</el-button>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
2022-04-14 08:22:13 +00:00
|
|
|
|
<el-form-item label="登录页广告图" prop="backdrop">
|
2022-04-13 09:38:53 +00:00
|
|
|
|
<material-select v-model="formData.backdrop" :limit="1" />
|
2022-04-08 02:42:44 +00:00
|
|
|
|
<div class="flex">
|
|
|
|
|
|
<div class="muted xs m-r-16">
|
|
|
|
|
|
建议尺寸:100*100像素,支持jpg,jpeg,png格式
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-popover placement="right" width="200" trigger="hover">
|
|
|
|
|
|
<el-image
|
|
|
|
|
|
src="https://img2.baidu.com/it/u=3357699356,1912406716&fm=26&fmt=auto&gp=0.jpg"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-button slot="reference" type="text">查看示例</el-button>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
|
|
<footer-btns>
|
2022-04-20 04:15:33 +00:00
|
|
|
|
<el-button v-perm="['setting:setWebsite']" type="primary" size="small" @click="setWebsite">保存</el-button>
|
2022-04-08 02:42:44 +00:00
|
|
|
|
</footer-btns>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
|
import { defineComponent, reactive, onMounted, Ref, ref } from 'vue'
|
|
|
|
|
|
import { ElInput, ElForm } from 'element-plus'
|
|
|
|
|
|
import MaterialSelect from '@/components/material-select/index.vue'
|
|
|
|
|
|
import FooterBtns from '@/components/footer-btns/index.vue'
|
|
|
|
|
|
import { apiGetWebsite, apiSetWebsite } from '@/api/setting'
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
|
components: {
|
|
|
|
|
|
MaterialSelect,
|
|
|
|
|
|
FooterBtns
|
|
|
|
|
|
},
|
|
|
|
|
|
setup() {
|
|
|
|
|
|
const formRef: Ref<typeof ElForm | null> = ref(null)
|
|
|
|
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
|
|
const formData = reactive({
|
|
|
|
|
|
name: '', // 网站名称
|
2022-04-13 09:38:53 +00:00
|
|
|
|
favicon: '', // 网站图标
|
|
|
|
|
|
logo: '', // 网站logo
|
|
|
|
|
|
backdrop: '' // 登录页广告图
|
2022-04-08 02:42:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 表单验证
|
|
|
|
|
|
const rules = {
|
2022-04-14 08:22:13 +00:00
|
|
|
|
name: [{ required: true, message: '请输入网站名称', trigger: ['blur'] }],
|
|
|
|
|
|
favicon: [{ required: true, message: '上传网站图标', trigger: ['blur'] }],
|
|
|
|
|
|
logo: [{ required: true, message: '上传网站logo', trigger: ['blur'] }],
|
|
|
|
|
|
backdrop: [{ required: true, message: '上传登录页广告图', trigger: ['blur'] }]
|
2022-04-08 02:42:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取备案信息
|
|
|
|
|
|
const getWebsite = () => {
|
|
|
|
|
|
apiGetWebsite().then((res: any) => {
|
|
|
|
|
|
console.log('res', res)
|
|
|
|
|
|
formData.name = res.name
|
2022-04-13 09:38:53 +00:00
|
|
|
|
formData.favicon = res.favicon
|
|
|
|
|
|
formData.logo = res.logo
|
|
|
|
|
|
formData.backdrop = res.backdrop
|
2022-04-08 02:42:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 设置备案信息
|
|
|
|
|
|
const setWebsite = () => {
|
|
|
|
|
|
formRef.value?.validate((valid: boolean) => {
|
|
|
|
|
|
if (!valid) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('fasdfasd')
|
|
|
|
|
|
apiSetWebsite({
|
|
|
|
|
|
name: formData.name,
|
2022-04-13 09:38:53 +00:00
|
|
|
|
favicon: formData.favicon,
|
|
|
|
|
|
logo: formData.logo,
|
|
|
|
|
|
backdrop: formData.backdrop
|
2022-04-08 02:42:44 +00:00
|
|
|
|
})
|
|
|
|
|
|
.then((res: any) => {
|
|
|
|
|
|
console.log('res', res)
|
|
|
|
|
|
getWebsite()
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch((err: any) => {
|
|
|
|
|
|
console.log('err', err)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
getWebsite()
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
formData,
|
|
|
|
|
|
rules,
|
|
|
|
|
|
getWebsite,
|
|
|
|
|
|
setWebsite,
|
|
|
|
|
|
formRef
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|