feat: 添加自定义测试上下文和更新模板设置

- 在 AutoActionEditor 和 TemplateSettings 组件中添加 customTestContext 属性
- 更新 CheckInSettings 组件以使用 customTestContext
- 移除 TemplateEditor 中的操作按钮部分
This commit is contained in:
2025-05-02 02:34:56 +08:00
parent 993107c24c
commit 4bcb966bdc
5 changed files with 38 additions and 32 deletions

View File

@@ -26,6 +26,10 @@ const props = defineProps({
hideEnabled: {
type: Boolean,
default: false
},
customTestContext: {
type: Object,
default: undefined
}
});
@@ -58,7 +62,7 @@ const TriggerSettings = getTriggerSettings();
<div class="auto-action-editor">
<NSpace vertical>
<!-- 模板设置 - 移到最上面 -->
<TemplateSettings :action="action" />
<TemplateSettings :action="action" :custom-test-context="customTestContext" />
<!-- 基本设置 -->
<BasicSettings

View File

@@ -380,21 +380,6 @@ function insertExample(template: string) {
</transition>
</NFlex>
<!-- 操作按钮 -->
<NFlex
justify="end"
:size="12"
>
<NButton
type="default"
size="small"
class="btn-with-transition"
@click="convertPlaceholders"
>
占位符转表达式
</NButton>
</NFlex>
<!-- 模板示例 -->
<NCollapse
class="template-examples"

View File

@@ -188,23 +188,25 @@
</template>
</NAlert>
</div>
<!-- 使用 AutoActionEditor 编辑 action 配置 -->
<NFormItem label="签到成功回复">
<NDivider title-placement="left">
签到成功回复
</NDivider>
<AutoActionEditor
:action="config.successAction"
:hide-name="true"
:hide-enabled="true"
:custom-test-context="customTestContext"
/>
</NFormItem>
<NFormItem label="签到冷却回复">
<NDivider title-placement="left">
签到冷却回复
</NDivider>
<AutoActionEditor
:action="config.cooldownAction"
:hide-name="true"
:hide-enabled="true"
:custom-test-context="customTestContext"
/>
</NFormItem>
</template>
<NFormItem>
@@ -398,6 +400,15 @@ const config = autoActionStore.checkInModule.checkInConfig;
const accountInfo = useAccount();
const isLoading = ref(false);
const customTestContext = ref({
checkin: {
points: 0,
consecutiveDays: 0,
todayRank: 0,
time: new Date()
}
});
// 签到模板的特定占位符
const checkInPlaceholders = [
{ name: '{{checkin.points}}', description: '获得的总积分' },

View File

@@ -8,6 +8,10 @@ const props = defineProps({
action: {
type: Object as () => AutoActionItem,
required: true
},
customTestContext: {
type: Object,
default: undefined
}
});
@@ -61,6 +65,7 @@ function handleTemplateUpdate(payload: { index: number, value: string }) {
:title="templateTitle"
:description="templateDescription"
:check-length="action.actionType === ActionType.SEND_DANMAKU"
:custom-test-context="customTestContext"
class="template-editor"
@update:template="handleTemplateUpdate"
/>

1
src/components.d.ts vendored
View File

@@ -22,6 +22,7 @@ declare module 'vue' {
NAvatar: typeof import('naive-ui')['NAvatar']
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NDi: typeof import('naive-ui')['NDi']
NEmpty: typeof import('naive-ui')['NEmpty']
NFlex: typeof import('naive-ui')['NFlex']
NFormItemGi: typeof import('naive-ui')['NFormItemGi']