Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array + Union 配置聯動 後 點擊添加項目報錯 #56

Open
eric2788 opened this issue Nov 10, 2023 · 0 comments
Open

Array + Union 配置聯動 後 點擊添加項目報錯 #56

eric2788 opened this issue Nov 10, 2023 · 0 comments

Comments

@eric2788
Copy link

配置範例如下 (使用官方參考的配置聯動2 + Array 形式)

import { Context, Schema } from 'koishi'

export const name = 'test'


export interface ConfigRef {
  shared: string
  type: 'foo' | 'bar' | 'baz'
  value?: number
  text?: string
}

export interface Config {
  configs: ConfigRef[]
}

export const Config: Schema<Config> = Schema.object({
  configs: Schema.array(Schema.intersect([
    Schema.object({
      shared: Schema.string(),
      type: Schema.union(['foo', 'bar', 'baz']).required(),
    }).description('基础配置'),
    Schema.union([
      Schema.object({
        type: Schema.const('foo').required(),
        value: Schema.number().default(114514),
      }).description('特殊配置 1'),
      Schema.object({
        type: Schema.const('bar').required(),
        text: Schema.string(),
      }).description('特殊配置 2'),
      Schema.object({} as any)
    ])
  ]))
})

export function apply(ctx: Context) {
  // write your plugin here
}

使用後,按下 添加項目 沒有反應且在 F12 console 出現如下報錯:

image

此問題只在 dev 出現,build好後從koishi市場下載插件,則沒有這個問題

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant