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

View File

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

View File

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

View File

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

1
src/components.d.ts vendored
View File

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