代码拉取完成,页面将自动刷新
同步操作将从 MEMZ/MEMZ-Plugin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import getconfig from './model/configget.js';
import fs from 'fs';
import yaml from 'yaml';
import lodash from 'lodash'
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export function supportGuoba() {
return {
pluginInfo: {
name: `MEMZ-Plugin`,
title: 'MEMZ插件(MEMZ-Plugin)',
author: '@MEMZ',
authorLink: 'https://gitee.com/memzjs',
link: 'https://gitee.com/memzjs/memz-plugin',
isV3: true,
isV2: false,
description: `组织内部使用插件,基于**ChatGPT** && **Ctrl C+V**`,
// 显示图标,此为个性化配置
// 图标可在 https://icon-sets.iconify.design 这里进行搜索
icon: 'mdi:stove',
// 图标颜色,例:#FF0000 或 rgb(255, 0, 0)
iconColor: '#d19f56',
// 如果想要显示成图片,也可以填写图标路径(绝对路径)
},
configInfo: {
// 配置项 schemas
schemas: [
{
field: 'SMTPUser',
label: 'SMTPUser',
bottomHelpMessage: 'SMTP用户名',
component: 'Input'
},
{
field: 'SMTPPass',
label: 'SMTPPass',
bottomHelpMessage: 'SMTP密码',
component: 'Input'
},
{
field: 'SMTPPort',
label: 'SMTPPort',
bottomHelpMessage: 'SMTP端口号',
component: 'Input'
},
{
field: 'SMTPURL',
label: 'SMTPURL',
bottomHelpMessage: 'SMTP服务器地址 ',
component: 'Input'
},
{
field: 'SMTPAll',
label: 'SMTPAll key',
bottomHelpMessage: 'SMTP是否全部人可用',
component: 'Switch'
},
],
async getConfigData() {
let { config } = getconfig(`config`, `all.config`)
return config;
},
async setConfigData(data, { Result }) {
// 1.读取现有配置文件
const configFilePath = path.join(__dirname,'config','all.config.yaml');
let config = {};
if (fs.existsSync(configFilePath)) {
const configContent = fs.readFileSync(configFilePath, 'utf8');
config = yaml.parse(configContent) || {};
}
// 2. 更新配置对象
for (const [keyPath, value] of Object.entries(data)) {
lodash.set(config, keyPath, value);
}
// 3. 将更新后的配置对象写回文件
const updatedConfigYAML = yaml.stringify(config);
fs.writeFileSync(configFilePath, updatedConfigYAML, 'utf8');
logger.mark(`[MEMZ:配置文件]配置文件更新`)
return Result.ok({}, '保存成功~');
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。