better-staridc-MNBT
1import { apiGn, parseResult, default as http } from '@/shared/api/http'
2import { MessagePlugin } from 'tdesign-vue-next'
3
4/** 网站设置: gg / qq / yzm / zjyxbd */
5export function setWebsite(data) {
6 return apiGn('setwz', data)
7}
8
9/** API 设置: apikey / apiqk / linux / windows */
10export function setApi(data) {
11 return apiGn('setapi', data)
12}
13
14/** 控制面板: name / ftp / yzm / kg / bq + 文件上传 loa/lob/loc */
15export function setPanel(data) {
16 return apiGn('setkzmb', data)
17}
18
19/** 管理账号: yuser / ypass / xuser / xpass */
20export function setAdmin(data) {
21 return apiGn('gl', data)
22}
23
24/** 邮箱: host / user / password / port */
25export function setMail(data) {
26 return apiGn('mailmode', data)
27}
28
29/** 监控设置: ymkg / ymyjkg / ymtsyz / wjkg / wjyjkg / wjtsyz / option */
30export function setMonitor(data) {
31 return apiGn('jkscsz', data)
32}
33
34/** 主题切换: usertheme / admintheme / dockertheme / hometheme */
35export function setTheme(usertheme, admintheme, dockertheme = '', hometheme = '') {
36 return apiGn('settheme', { usertheme, admintheme, dockertheme, hometheme })
37}
38
39/** 支付方式列表(走 panel API,如启用支付插件) */
40export function listPaymentMethods() {
41 return apiGn('list_payment_methods', {}, { silent: true })
42}
43
44/** 保存支付方式 */
45export function savePaymentMethods(methods) {
46 return apiGn('setpaymethods', { methods })
47}
48
49/** 主页设置: home_enable / home_title / home_hero / home_primary / home_logo / home_favicon / home_footer / home_show_notice / home_show_plans */
50export function setHome(data) {
51 return apiGn('save_home_settings', data)
52}
53
54/** 上传主页 Logo/Favicon: target=logo|favicon */
55export async function uploadHomeIcon(target, file) {
56 const boot = window.__TD_BOOT__ || {}
57 const url = boot.ajaxBase || './ajax.php'
58 const fd = new FormData()
59 fd.append('gn', 'home_upload_icon')
60 fd.append('target', target)
61 fd.append('icon', file)
62 const res = await http.post(url, fd)
63 const r = parseResult(res.data)
64 if (!r.ok) MessagePlugin.error(r.message || '上传失败')
65 return r
66}
67
68/** 上传主页自定义图片字段: key 为 image 类型字段 key */
69export async function uploadHomeImage(key, file) {
70 const boot = window.__TD_BOOT__ || {}
71 const url = boot.ajaxBase || './ajax.php'
72 const fd = new FormData()
73 fd.append('gn', 'home_upload_image')
74 fd.append('key', key)
75 fd.append('image', file)
76 const res = await http.post(url, fd)
77 const r = parseResult(res.data)
78 if (!r.ok) MessagePlugin.error(r.message || '上传失败')
79 return r
80}