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

Bug: Schema.dynamic 设置为数组多选项时不工作 #1475

Open
dingyi222666 opened this issue Oct 29, 2024 · 0 comments
Open

Bug: Schema.dynamic 设置为数组多选项时不工作 #1475

dingyi222666 opened this issue Oct 29, 2024 · 0 comments
Labels
bug BUG

Comments

@dingyi222666
Copy link

dingyi222666 commented Oct 29, 2024

Describe the bug

image

如图,上面 1,2,3 是动态设置的 schema,其中 2,3 是多选的数组,无法显示。4,5是手动设置的 schema,正常显示。

Steps to reproduce

import { Context, Schema } from "koishi";

export const name = "test";

export interface Config {}

enum Intents {
  FOO = 1,
  BAR = 2,
  QUX = 4,
}

export const Config: Schema<Config> = Schema.object({
  dynamicBitset: Schema.dynamic("dynamicBitset"),
  dynamicArray: Schema.dynamic("dynamicArray").role("checkbox"),
  dynamicSelect: Schema.dynamic("dynamicSelect").role("select"),
  bitset: Schema.bitset(Intents)
    .default(Intents.FOO | Intents.QUX)
    .role("checkbox"),
  array: Schema.array(Schema.union(["FOO", "BAR", "QUX"]))
    .default(["FOO", "QUX"])
    .role("select"),
});

export function apply(ctx: Context, config: Config) {
  ctx.schema.set(
    "dynamicBitset",
    Schema.bitset(Intents)
      .default(Intents.FOO | Intents.QUX)
      .role("checkbox")
  );
  ctx.schema.set(
    "dynamicArray",
    Schema.array(Schema.union(["FOO", "BAR", "QUX"]))
  );
  ctx.schema.set(
    "dynamicSelect",
    Schema.array(Schema.union(["FOO", "BAR", "QUX"])).role("select")
  );
}

Expected behavior

全部正常显示。

Screenshots

No response

Versions

  • OS: Windows 11
  • Platform: sandbox
  • Node version: 20.15.0
  • Koishi version: 4.18.0
  • @koishijs/plugin-config: 2.8.6
  • @koishijs/client: 5.30.0
  • @koishijs/plugin-console: 5.30.0

Additional context

yarn dev 模式下运行,则所有用 dynamic 设置的 schema 都无法正常显示。

image

@dingyi222666 dingyi222666 added the bug BUG label Oct 29, 2024
@dingyi222666 dingyi222666 changed the title Bug: Schema.dynamic 设置为数组多选项时不工作。 Bug: Schema.dynamic 设置为数组多选项时不工作 Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug BUG
Projects
None yet
Development

No branches or pull requests

1 participant