在插件中如何配置数组对象。我尝试了json_schema,但是对象属性配置无法使用 category 这类选择器,只能输入文本。而 type: objects 则根本无法在插件配置中工作。
json_schema 的配置
quectel_online_customer_category_customers:
default: "[]"
client: true
json_schema: QuectelOnlineCustomer::SiteSettings::CategoryCustomersJsonSchema
plugins/quectel-online-customer/lib/quectel_online_customer/site_settings/category_customers_json_schema.rb
# frozen_string_literal: true
module QuectelOnlineCustomer
module SiteSettings
class CategoryCustomersJsonSchema
def self.schema
@schema ||= begin
{
type: "array",
uniqueItems: true,
default: [],
items: {
type: "object",
title: "类别客服配置",
additionalProperties: false, # 禁止提交未定义字段
required: %w[category customers], # 两个字段必填
properties: {
category: {
type: "category",
description: "绑定的论坛分类",
label: "分类"
},
customers: {
type: "usernames", # 多选用户,替代单用户名username
description: "分配至该分类的客服账号,支持多选",
label: "客服用户",
}
}
}
}
end
end
end
end
end