Skip to content

Commit

Permalink
feat(manager): enhance hints for workspace plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 13, 2022
1 parent 7b863fa commit 4363eb2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
11 changes: 4 additions & 7 deletions plugins/frontend/components/client/form/form.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<template>
<k-comment v-if="!schema" type="warning">
此插件未声明配置项,这可能并非预期行为,请联系插件作者。
</k-comment>
<k-comment v-else-if="!isValid(schema)" type="warning">
部分配置项无法正常显示,这可能并非预期行为,请联系插件作者。
<k-comment v-if="!isValid(schema)" type="warning">
部分配置项无法正常显示,这可能并非预期行为<slot name="hint"></slot>。
</k-comment>
<form class="k-form">
<h2 v-if="showHeader ?? !hasTitle(schema)">基础设置</h2>
<slot name="header"></slot>
<slot name="prolog"></slot>
<k-schema v-if="schema" :schema="schema" :disabled="disabled" v-model="config"></k-schema>
<slot name="footer"></slot>
<slot name="epilog"></slot>
</form>
</template>

Expand Down
22 changes: 10 additions & 12 deletions plugins/frontend/manager/client/bots/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
</template>
</h1>
<k-view name="manager:bot-prolog" :data="data"></k-view>
<k-form :schema="store.protocols[key]" v-model="data.config" :show-header="true">
<template #header>
<k-schema :schema="adapterSchema" v-model="data.adapter" :disabled="!!current">
<h3 class="required">adapter</h3>
<p>选择要使用的适配器。</p>
</k-schema>
<k-schema :schema="protocolSchema" v-model="data.config.protocol">
<h3 class="required">protocol</h3>
<p>选择要使用的协议。</p>
</k-schema>
<k-view name="manager:bot-config" :data="data"></k-view>
</template>
<k-form :schema="store.protocols[key]" v-model="data.config" :show-header="true" #prolog>
<k-schema :schema="adapterSchema" v-model="data.adapter" :disabled="!!current">
<h3 class="required">adapter</h3>
<p>选择要使用的适配器。</p>
</k-schema>
<k-schema :schema="protocolSchema" v-model="data.config.protocol">
<h3 class="required">protocol</h3>
<p>选择要使用的协议。</p>
</k-schema>
<k-view name="manager:bot-config" :data="data"></k-view>
</k-form>
<k-view name="manager:bot-epilog" :data="data"></k-view>
</template>
Expand Down
14 changes: 9 additions & 5 deletions plugins/frontend/manager/client/settings/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@
</template>

<!-- schema -->
<template v-if="data.root || !data.id">
<k-form :schema="data.schema" v-model="data.config"></k-form>
</template>
<k-comment v-if="!data.root && data.id" type="warning">
此插件已被加载,但并非是在配置文件中。你无法修改其配置。
</k-comment>
<template v-else>
<k-comment type="warning">
<template #header>此插件已被加载,但并非是在配置文件中。你无法修改其配置。</template>
<k-comment v-if="!data.schema" type="warning">
此插件未声明配置项,这可能并非预期行为{{ hint }}。
</k-comment>
<k-form :schema="data.schema" v-model="data.config">
<template #hint>{{ hint }}</template>
</k-form>
</template>
</k-content>
</template>
Expand All @@ -80,6 +83,7 @@ const props = defineProps<{
const data = computed(() => getMixedMeta(props.current))
const env = computed(() => envMap.value[props.current])
const hint = computed(() => data.value.workspace ? ',请检查源代码' : ',请联系插件作者')
const version = ref('')
Expand Down
8 changes: 7 additions & 1 deletion plugins/frontend/manager/client/settings/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ function getEnvInfo(name: string) {
}
}

// check implementations
const data = getMixedMeta(name)
const result: EnvInfo = { impl: [], using: {}, deps: {} }

// nested plugins
if (!data.root && data.id) {
result.invalid = true
}

// check implementations
for (const name of getKeywords('impl', data)) {
if (name === 'adapter') continue
result.impl.push(name)
Expand Down

0 comments on commit 4363eb2

Please sign in to comment.