Files
hjsq_h5/src/views/lldmine/aiUndress/aiText/index.vue
T
2026-11-05 12:01:36 +07:00

209 lines
5.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="ai-text overflow-y-auto">
<div class="ai-text__content">
<section v-for="(io, i) in inputOptions" :key="i">
<label for="">
{{ io.label }}
<span v-if="io.required">*</span>
</label>
<van-field
v-model="io.text"
:maxlength="io.limit"
:placeholder="io.placeholder"
rows="3"
autosize
type="textarea"
show-word-limit
/>
</section>
<section class="model-types">
<label for="">选择模型</label>
<div class="model-types__value">
<van-button
v-for="(mo, i) in modelOptions"
:key="i"
:type="modelIndex === i ? 'primary' : 'default'"
@click="modelIndex = i"
>
{{ mo.label }}
</van-button>
</div>
</section>
<footer>
<p class="price">
生成一次AI小说费用是
<span>{{ store.appConfig.aiTextToNovelPrice }}金币</span>
</p>
<van-button class="submit-btn" type="primary" @click="submit">立即提交</van-button>
</footer>
</div>
</div>
</template>
<script setup lang="ts">
import MineApi from '@/service/mine';
import { useConfigStore } from '@/stores/config';
import { showToast } from 'vant';
import { useRouter } from 'vue-router';
import { reactive, ref } from 'vue';
const store = useConfigStore();
const router = useRouter();
const inputOptions = reactive([
{
label: '人物设定(选填)',
placeholder: '示例:“总裁、公主、小萝莉.”',
limit: 20,
required: false,
key: 'characterSetting',
text: '',
},
{
label: '地点场景(选填)',
placeholder: '示例:“办公室、酒吧”',
limit: 20,
required: false,
key: 'locationScene',
text: '',
},
{
label: '故事情节(必填)',
placeholder: '故事大致情节,例如:35岁女强人在酒吧遇到跳钢管舞的男模后,欲火焚身、欲罢不能。',
limit: 200,
required: true,
key: 'description',
text: '',
},
{
label: '细节说明(选填)',
placeholder: '例如:请详细描写女主身材美貌,与霸总的做爱过程',
limit: 200,
required: false,
key: 'details',
text: '',
},
]);
const modelIndex = ref(0);
const modelOptions = [
{ label: 'AI小艺', value: 1 },
{ label: 'AI小萌', value: 2 },
];
const validateInputInfo = () => {
const inputObj: Record<string, any> = {};
for (const io of inputOptions) {
if (io.required && !io.text) {
showToast('请输入' + io.label);
return false;
}
if (io.text) inputObj[io.key] = io.text;
}
return inputObj;
};
const resetInputs = () => {
inputOptions.forEach((io) => (io.text = ''));
};
const submit = async () => {
try {
const pms = validateInputInfo();
if (!pms) return;
pms.modelType = modelOptions[modelIndex.value].value;
await MineApi.generateTextToNovel(pms);
resetInputs();
showToast('提交成功,等待生成');
} catch (error) {
console.error('generate text to novel error:', error);
router.push('/wallet');
}
};
</script>
<style scoped lang="scss">
.ai-text {
padding: 0 10px 120px;
height: calc(100vh - 78px - 48px * 2);
&__content {
padding: 12px 0;
label {
display: block;
color: #fff;
font-size: 14px;
margin: 12px 0;
span {
color: $themeColor;
}
}
.van-field {
--van-cell-vertical-padding: 5px;
--van-cell-background: #1e1d1d;
--van-field-word-limit-color: #999;
--van-field-input-text-color: #fff;
--van-field-placeholder-text-color: #747171;
--van-cell-vertical-padding: 11px;
border-radius: 8px;
font-size: 12px;
line-height: 1.5;
&::after {
border: none;
}
}
.model-types {
&__value {
display: flex;
flex-wrap: wrap;
gap: 10px;
.van-button {
--van-button-default-background: rgba(255, 255, 255, 0.05);
--van-button-primary-background: #ffc000;
--van-button-primary-border-color: #ffc000;
--van-button-primary-color: #1f2029;
--van-button-default-border-color: transparent;
--van-button-border-width: 0;
--van-button-normal-padding: 0 10px;
--van-button-default-color: #fff;
--van-button-default-color: rgba(255, 255, 255, 0.5);
height: 28px;
font-size: 14px;
}
}
}
}
.price {
font-size: 12px;
color: #747171;
text-align: center;
margin-top: 18px;
span {
color: $themeColor;
}
}
.submit-btn {
margin: 20px auto 0;
display: block;
width: 343px;
height: 44px;
border: none;
background-color: $themeColor;
border-radius: 88px;
color: #1f2029;
font-weight: 500;
}
footer {
//position: sticky;
//padding-top: 10px;
//padding-bottom: calc(50px + env(safe-area-inset-bottom));
//bottom: 0;
//background-color: #0f0f0f;
}
}
</style>