forked from guoba-yunzai/guoba-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguoba.support.js
More file actions
152 lines (151 loc) · 5.59 KB
/
guoba.support.js
File metadata and controls
152 lines (151 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import path from 'path'
import lodash from 'lodash'
import {_paths, cfg} from "#guoba.platform";
// 支持锅巴
export function supportGuoba() {
return {
// 插件信息,将会显示在前端页面
// 如果你的插件没有在插件库里,那么需要填上补充信息
// 如果存在的话,那么填不填就无所谓了,填了就以你的信息为准
pluginInfo: {
// name 为插件唯一标识,尽量不要与其他插件重复
name: 'guoba-plugin',
// title 为显示名称
title: 'Guoba-Plugin',
// 插件描述
description: '主要提供后台管理界面',
// 作者可以为字符串也可以为数组,当有多个作者时建议使用数组
author: [
'@zolay-poi',
'@Guoba-Yunzai',
],
// 作者主页地址。若author为数组,则authorLink也需要为数组,且需要与author一一对应
authorLink: [
'https://github.com/zolay-poi',
'https://github.com/guoba-yunzai',
],
// 仓库地址
link: 'https://github.com/guoba-yunzai/guoba-plugin',
isV3: true,
isV2: false,
// 是否显示在左侧菜单,可选值:auto、true、false
// 当为 auto 时,如果配置项大于等于 3 个,则显示在左侧菜单
showInMenu: 'auto',
// 显示图标,此为个性化配置
// 图标可在 https://icon-sets.iconify.design 这里进行搜索
icon: 'mdi:stove',
// 图标颜色,例:#FF0000 或 rgb(255, 0, 0)
iconColor: '#d19f56',
// 如果想要显示成图片,也可以填写图标路径(绝对路径)
iconPath: path.join(_paths.pluginRoot, 'resources/images/icon.png'),
},
// 配置项信息
configInfo: {
// 配置项 schemas
schemas: [
// {
// field: 'base.checkUpdate',
// label: '检查更新',
// helpMessage: '启动时和每天凌晨4点自动检查更新,并发送消息提醒(每个版本只提醒一次)',
// bottomHelpMessage: '是否自动检查更新,并发送消息提醒',
// component: 'Switch',
// },
{
field: 'base.loginInGroup',
label: '允许群聊登录',
bottomHelpMessage: '允许在群聊里使用`#锅巴登录`,有一定风险,酌情开启',
component: 'Switch',
},
// {
// field: 'base.city',
// label: '天气城市',
// helpMessage: '修改后需要刷新页面才能生效',
// bottomHelpMessage: '配置首页天气显示的城市',
// // 组件类型,可参考 https://vvbin.cn/doc-next/components/introduction.html
// // https://antdv.com/components/overview-cn/
// component: 'Input',
// required: true,
// componentProps: {
// placeholder: '请输入天气城市',
// },
// },
{
label: '服务器配置',
component: 'Divider',
},
{
field: 'server.host',
label: '服务器地址',
bottomHelpMessage: 'auto 为自动获取本机IP地址,仅用于“#锅巴登录”和控制台中',
component: 'Input',
required: true,
componentProps: {
placeholder: '请输入服务器地址',
},
},
{
field: 'server.port',
label: '监听端口号',
helpMessage: '修改后需要重启才能生效',
bottomHelpMessage: '如果不想要端口号,请输入 80',
component: 'InputNumber',
required: true,
componentProps: {
min: 1,
max: 65535,
placeholder: '请输入监听端口号',
},
},
{
field: 'server.splicePort',
label: '拼接端口号',
bottomHelpMessage: '是否需要在服务器地址后拼接端口号',
component: 'Switch',
},
// {
// field: 'server.showAllIp',
// label: '显示所有IP',
// bottomHelpMessage: '当host为auto时,是否在使用"#锅巴登录"时显示所有IP地址',
// component: 'Switch',
// },
{
field: 'server.ICPNo',
label: 'ICP备案号',
helpMessage: '如果要将网站放到公网上使用「域名」访问,则需要填写备案号,否则可能会面临被禁止访问的风险!',
bottomHelpMessage: '填写你的域名ICP备案号,会显示在页面底部',
component: 'Input',
componentProps: {
placeholder: '请输入ICP备案号',
},
},
],
// 获取配置数据方法(用于前端填充显示数据)
getConfigData() {
let config = lodash.omit(cfg.merged, 'jwt')
let host = lodash.get(config, 'server.host')
if (Array.isArray(host)) {
lodash.set(config, 'server.host', host[0])
}
return config
},
// 设置配置的方法(前端点确定后调用的方法)
setConfigData(data, {Result}) {
let config = {}
for (let [keyPath, value] of Object.entries(data)) {
// 特殊处理 server.host
if (keyPath === 'server.host') {
let host = cfg.get('server.host')
if (Array.isArray(host)) {
host[0] = value
value = host
}
}
lodash.set(config, keyPath, value)
}
config = lodash.merge({}, cfg.merged, config)
cfg.config.reader.setData(config)
return Result.ok({}, '保存成功~')
},
},
}
}