better-staridc-MNBT
1<template>
2 <div class="td-page">
3 <div class="td-page-head">
4 <div>
5 <h3 class="td-page-title"><i class="mdi mdi-earth"></i>网站设置</h3>
6 <p class="td-page-subtitle">公告、联系方式与登录安全</p>
7 </div>
8 </div>
9
10 <div class="td-set-card">
11 <div class="td-set-card-hd">
12 <div class="td-set-icon"><i class="mdi mdi-earth"></i></div>
13 <div>
14 <h4>网站配置</h4>
15 <p>公告、联系方式与登录安全</p>
16 </div>
17 </div>
18 <div class="td-set-card-bd">
19 <t-loading :loading="loading" text="保存中…" size="small">
20 <div class="td-form">
21 <div class="td-form-row">
22 <label>网站公告</label>
23 <t-textarea
24 v-model="form.gg"
25 :autosize="{ minRows: 4, maxRows: 10 }"
26 placeholder="请在这填写网站公告"
27 />
28 <div class="td-form-hint">显示在用户端首页公告区域,支持纯文本</div>
29 </div>
30
31 <div class="td-form-row">
32 <label>站长 QQ</label>
33 <t-input v-model="form.qqh" placeholder="请在这填写您的QQ号" clearable>
34 <template #prefix-icon><i class="mdi mdi-account"></i></template>
35 </t-input>
36 </div>
37
38 <div class="td-form-switch">
39 <div class="td-form-switch-txt">
40 <strong>后台登录验证码</strong>
41 <span>开启后管理员登录需填写验证码</span>
42 </div>
43 <t-switch v-model="form.yzm" />
44 </div>
45
46 <div class="td-form-switch">
47 <div class="td-form-switch-txt">
48 <strong>主机邮箱绑定</strong>
49 <span>要求用户绑定邮箱后方可使用部分功能</span>
50 </div>
51 <t-switch v-model="form.zjyxbd" />
52 </div>
53
54 <div class="td-form-actions">
55 <t-button theme="primary" :loading="loading" @click="save">
56 <i class="mdi mdi-content-save-outline"></i> 保存修改
57 </t-button>
58 </div>
59 </div>
60 </t-loading>
61 </div>
62 </div>
63 </div>
64</template>
65
66<script setup>
67import { reactive, ref } from 'vue'
68import { MessagePlugin } from 'tdesign-vue-next'
69import { setWebsite } from '@/admin/api/settings'
70
71const boot = window.__TD_BOOT__ || {}
72const conf = boot.conf || {}
73const loading = ref(false)
74
75const form = reactive({
76 gg: conf.gg || '',
77 qqh: conf.qqh || '',
78 yzm: conf.yzm === 'true',
79 zjyxbd: conf.zjyxbd === 'true',
80})
81
82async function save() {
83 loading.value = true
84 const r = await setWebsite({
85 gg: form.gg,
86 qq: form.qqh,
87 yzm: form.yzm ? 'true' : 'false',
88 zjyx: form.zjyxbd ? 'true' : 'false',
89 })
90 loading.value = false
91 if (r.ok) MessagePlugin.success('保存成功')
92}
93</script>