Add price for model (#249)

This commit is contained in:
Germey authored and GitHub committed 2025-08-06 00:50:50 +08:00
1 parent a6b4cecb5d
commit f8ca20981c
15 files changed
+231 -227

No files matched your search

+1 -4
View File
@@ -52,10 +52,7 @@ jobs:
- name: Get Build Number - name: Get Build Number
run: | run: |
BUILD_NUMBER=$(echo $BUILD_NUMBER) echo $BUILD_NUMBER
BUILD_DATE=$(date +'%Y%m%d')
BUILD_TAG="${BUILD_DATE}.${BUILD_NUMBER}"
echo "BUILD_NUMBER=${BUILD_TAG}" >> $GITHUB_ENV
- name: Build Docker images - name: Build Docker images
run: docker-compose build run: docker-compose build
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "add price support",
"packageName": "@acedatacloud/nexior",
"email": "cqc@cuiqingcai.com",
"dependentChangeType": "patch"
}
+2
View File
@@ -53,6 +53,7 @@
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"github-markdown-css": "^5.8.1", "github-markdown-css": "^5.8.1",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"json-logic-js": "^2.0.5",
"katex": "^0.16.22", "katex": "^0.16.22",
"mac-scrollbar": "^0.13.5", "mac-scrollbar": "^0.13.5",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
@@ -78,6 +79,7 @@
"@rollup/plugin-replace": "^3.0.0", "@rollup/plugin-replace": "^3.0.0",
"@transmart/cli": "^0.5.2", "@transmart/cli": "^0.5.2",
"@types/file-saver": "^2.0.7", "@types/file-saver": "^2.0.7",
"@types/json-logic-js": "^2.0.8",
"@types/markdown-it": "^14.1.0", "@types/markdown-it": "^14.1.0",
"@types/node": "^16.7.4", "@types/node": "^16.7.4",
"@types/psl": "^1.1.3", "@types/psl": "^1.1.3",
+33
View File
@@ -0,0 +1,33 @@
<template>
<div v-if="value !== null && value !== undefined" class="text-center text-[var(--el-text-color-secondary)] mb-1">
<font-awesome-icon icon="fa-solid fa-coins" class="text-xs mr-1" />
<span class="text-xs">
{{ value }}
{{ $t(`service.unit.${service?.unit || 'credits'}`) }}
</span>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { IService } from '@/models';
export default defineComponent({
name: 'Consumption',
components: {
FontAwesomeIcon
},
props: {
value: {
type: Number,
required: false,
default: null
},
service: {
type: Object as () => IService | undefined,
required: true
}
}
});
</script>
+19 -33
View File
@@ -1,15 +1,16 @@
<template> <template>
<div class="panel"> <div class="flex flex-col h-full">
<div class="config"> <div class="flex-1 overflow-y-auto p-[15px]">
<prompt-input class="mb-4" /> <prompt-input class="mb-4" />
<model-selector class="mb-4" /> <model-selector class="mb-4" />
<count-selector class="mb-4" /> <count-selector class="mb-4" />
<div class="actions"> </div>
<el-button type="primary" class="btn w-full" round @click="onGenerate"> <div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> <consumption :value="consumption" :service="service" />
{{ $t('flux.button.generate') }} <el-button type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
</div> {{ $t('flux.button.generate') }}
</el-button>
</div> </div>
</div> </div>
</template> </template>
@@ -21,6 +22,8 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ModelSelector from './config/ModelSelector.vue'; import ModelSelector from './config/ModelSelector.vue';
import CountSelector from './config/CountSelector.vue'; import CountSelector from './config/CountSelector.vue';
import PromptInput from './config/PromptInput.vue'; import PromptInput from './config/PromptInput.vue';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'PresetPanel', name: 'PresetPanel',
@@ -29,12 +32,19 @@ export default defineComponent({
FontAwesomeIcon, FontAwesomeIcon,
PromptInput, PromptInput,
ModelSelector, ModelSelector,
CountSelector CountSelector,
Consumption
}, },
emits: ['generate'], emits: ['generate'],
computed: { computed: {
config() { config() {
return this.$store.state.flux?.config; return this.$store.state.flux?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.flux?.service;
} }
}, },
methods: { methods: {
@@ -44,27 +54,3 @@ export default defineComponent({
} }
}); });
</script> </script>
<style lang="scss" scoped>
.panel {
padding: 15px;
display: flex;
flex-direction: column;
flex: 1;
height: calc(100% - 40px);
.config {
width: 100%;
height: calc(100% - 50px);
flex: 1;
}
.actions {
height: 50px;
display: flex;
justify-content: center;
align-items: center;
.btn {
width: 100%;
}
}
}
</style>
+30 -44
View File
@@ -1,25 +1,26 @@
<template> <template>
<div class="panel"> <div class="flex flex-col h-full">
<div class="config"> <div class="flex-1 overflow-y-auto p-[15px]">
<prompt-input class="mb-4" /> <prompt-input class="mb-4" />
<model-selector class="mb-4" /> <model-selector class="mb-4" />
<start-image-url-input v-if="config?.model === 'minimax-i2v'" class="mb-2" /> <start-image-url-input v-if="config?.model === 'minimax-i2v'" class="mb-2" />
<div class="actions"> </div>
<el-button <div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
v-if="config?.video_url !== undefined || config?.custom" <consumption :value="consumption" :service="service" />
type="primary" <el-button
class="btn w-full" v-if="config?.video_url !== undefined || config?.custom"
round type="primary"
@click="onGenerate" class="btn w-full"
> round
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> @click="onGenerate"
{{ $t('hailuo.button.extend') }} >
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate"> {{ $t('hailuo.button.extend') }}
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> </el-button>
{{ $t('hailuo.button.generate') }} <el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
</div> {{ $t('hailuo.button.generate') }}
</el-button>
</div> </div>
</div> </div>
</template> </template>
@@ -31,6 +32,9 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ModelSelector from './config/ModelSelector.vue'; import ModelSelector from './config/ModelSelector.vue';
import StartImageUrlInput from './config/StartImageUrlInput.vue'; import StartImageUrlInput from './config/StartImageUrlInput.vue';
import PromptInput from './config/PromptInput.vue'; import PromptInput from './config/PromptInput.vue';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'PresetPanel', name: 'PresetPanel',
components: { components: {
@@ -38,12 +42,19 @@ export default defineComponent({
FontAwesomeIcon, FontAwesomeIcon,
PromptInput, PromptInput,
StartImageUrlInput, StartImageUrlInput,
ModelSelector ModelSelector,
Consumption
}, },
emits: ['generate'], emits: ['generate'],
computed: { computed: {
config() { config() {
return this.$store.state.hailuo?.config; return this.$store.state.hailuo?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.hailuo?.service;
} }
}, },
methods: { methods: {
@@ -53,28 +64,3 @@ export default defineComponent({
} }
}); });
</script> </script>
<style lang="scss" scoped>
.panel {
height: 100%;
padding: 15px;
display: flex;
flex-direction: column;
flex: 1;
height: calc(100% - 40px);
.config {
width: 100%;
height: calc(100% - 50px);
flex: 1;
}
.actions {
height: 50px;
display: flex;
justify-content: center;
align-items: center;
.btn {
width: 100%;
}
}
}
</style>
+28 -43
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="panel"> <div class="flex flex-col h-full">
<div class="config"> <div class="flex-1 overflow-y-auto p-[15px]">
<prompt-input class="mb-4" /> <prompt-input class="mb-4" />
<model-selector class="mb-4" /> <model-selector class="mb-4" />
<ratio-selector class="mb-4" /> <ratio-selector class="mb-4" />
@@ -10,22 +10,23 @@
<mode-selector class="mb-4" /> <mode-selector class="mb-4" />
<cfg-scale-selector class="mb-4" /> <cfg-scale-selector class="mb-4" />
<negative-prompt-input class="mb-4" /> <negative-prompt-input class="mb-4" />
<div class="actions"> </div>
<el-button <div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
v-if="config?.video_url !== undefined || config?.custom" <consumption :value="consumption" :service="service" />
type="primary" <el-button
class="btn w-full" v-if="config?.video_url !== undefined || config?.custom"
round type="primary"
@click="onGenerate" class="btn w-full"
> round
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> @click="onGenerate"
{{ $t('kling.button.extend') }} >
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate"> {{ $t('kling.button.extend') }}
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> </el-button>
{{ $t('kling.button.generate') }} <el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
</div> {{ $t('kling.button.generate') }}
</el-button>
</div> </div>
</div> </div>
</template> </template>
@@ -40,14 +41,17 @@ import DurationSelector from './config/DurationSelector.vue';
import RatioSelector from './config/RatioSelector.vue'; import RatioSelector from './config/RatioSelector.vue';
import StartImage from './config/StartImage.vue'; import StartImage from './config/StartImage.vue';
import EndImage from './config/EndImage.vue'; import EndImage from './config/EndImage.vue';
import Consumption from '../common/Consumption.vue';
import CfgScaleSelector from './config/CfgScaleSelector.vue'; import CfgScaleSelector from './config/CfgScaleSelector.vue';
import PromptInput from './config/PromptInput.vue'; import PromptInput from './config/PromptInput.vue';
import NegativePromptInput from './config/NegativePromptInput.vue'; import NegativePromptInput from './config/NegativePromptInput.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'ConfigPanel', name: 'ConfigPanel',
components: { components: {
ElButton, ElButton,
Consumption,
FontAwesomeIcon, FontAwesomeIcon,
PromptInput, PromptInput,
NegativePromptInput, NegativePromptInput,
@@ -63,6 +67,12 @@ export default defineComponent({
computed: { computed: {
config() { config() {
return this.$store.state.kling?.config; return this.$store.state.kling?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.kling?.service;
} }
}, },
methods: { methods: {
@@ -72,28 +82,3 @@ export default defineComponent({
} }
}); });
</script> </script>
<style lang="scss" scoped>
.panel {
height: 100%;
padding: 15px;
display: flex;
flex-direction: column;
flex: 1;
height: calc(100% - 40px);
.config {
width: 100%;
height: calc(100% - 50px);
flex: 1;
}
.actions {
height: 50px;
display: flex;
justify-content: center;
align-items: center;
.btn {
width: 100%;
}
}
}
</style>
@@ -89,7 +89,7 @@ export default defineComponent({
width: 30%; width: 30%;
} }
.value { .value {
width: 80px; width: 120px;
} }
} }
</style> </style>
+29 -44
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="panel"> <div class="flex flex-col h-full">
<div class="config"> <div class="flex-1 overflow-y-auto p-[15px]">
<extend-from-input v-if="config?.video_id || config?.video_url" class="mb-4" /> <extend-from-input v-if="config?.video_id || config?.video_url" class="mb-4" />
<prompt-input class="mb-4" /> <prompt-input class="mb-4" />
<custom-selector v-if="!config?.video_id" class="mb-4" /> <custom-selector v-if="!config?.video_id" class="mb-4" />
@@ -9,22 +9,23 @@
<end-image-input class="mb-4" /> <end-image-input class="mb-4" />
<enhancement-selector class="mb-4" /> <enhancement-selector class="mb-4" />
<loop-selector class="mb-4" /> <loop-selector class="mb-4" />
<div class="actions"> </div>
<el-button <div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
v-if="config?.video_url !== undefined || config?.custom" <consumption :value="consumption" :service="service" />
type="primary" <el-button
class="btn w-full" v-if="config?.video_url !== undefined || config?.custom"
round type="primary"
@click="onGenerate" class="btn w-full"
> round
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> @click="onGenerate"
{{ $t('luma.button.extend') }} >
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate"> {{ $t('luma.button.extend') }}
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> </el-button>
{{ $t('luma.button.generate') }} <el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
</div> {{ $t('luma.button.generate') }}
</el-button>
</div> </div>
</div> </div>
</template> </template>
@@ -42,6 +43,8 @@ import StartImageInput from './config/StartImageInput.vue';
import UploadVideo from './config/UploadVideo.vue'; import UploadVideo from './config/UploadVideo.vue';
import PromptInput from './config/PromptInput.vue'; import PromptInput from './config/PromptInput.vue';
import ExtendFromInput from './config/ExtendFromInput.vue'; import ExtendFromInput from './config/ExtendFromInput.vue';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'ConfigPanel', name: 'ConfigPanel',
@@ -55,12 +58,19 @@ export default defineComponent({
PromptInput, PromptInput,
ExtendFromInput, ExtendFromInput,
CustomSelector, CustomSelector,
UploadVideo UploadVideo,
Consumption
}, },
emits: ['generate'], emits: ['generate'],
computed: { computed: {
config() { config() {
return this.$store.state.luma?.config; return this.$store.state.luma?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.luma?.service;
} }
}, },
methods: { methods: {
@@ -70,28 +80,3 @@ export default defineComponent({
} }
}); });
</script> </script>
<style lang="scss" scoped>
.panel {
height: 100%;
padding: 15px;
display: flex;
flex-direction: column;
flex: 1;
height: calc(100% - 40px);
.config {
width: 100%;
height: calc(100% - 50px);
flex: 1;
}
.actions {
height: 50px;
display: flex;
justify-content: center;
align-items: center;
.btn {
width: 100%;
}
}
}
</style>
+14 -11
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="panel flex flex-col"> <div class="flex flex-col h-full">
<div class="flex-1 overflow-y-scroll p-4"> <div class="flex-1 overflow-y-auto p-[15px]">
<is-videos-selector class="mb-2" /> <is-videos-selector class="mb-2" />
<model-selector v-if="!config.is_videos" class="mb-2" /> <model-selector v-if="!config.is_videos" class="mb-2" />
<prompt-input class="mb-2" /> <prompt-input class="mb-2" />
@@ -17,7 +17,8 @@
<image-weight-selector v-show="config.advanced" class="mb-2" /> <image-weight-selector v-show="config.advanced" class="mb-2" />
<style-selector v-show="config.advanced" class="mb-2" /> <style-selector v-show="config.advanced" class="mb-2" />
</div> </div>
<div class="h-12 px-4"> <div class="flex flex-col px-[15px] pb-[15px]">
<consumption :value="consumption" :service="service" />
<div class="flex gap-1"> <div class="flex gap-1">
<mode-selector /> <mode-selector />
<el-button v-if="config.action === 'extend'" type="primary" class="btn w-full" round @click="$emit('generate')"> <el-button v-if="config.action === 'extend'" type="primary" class="btn w-full" round @click="$emit('generate')">
@@ -50,6 +51,8 @@ import ModeSelector from './config/ModeSelector2.vue';
import PromptInput from './config/PromptInput.vue'; import PromptInput from './config/PromptInput.vue';
import ReferenceImage from './config/ReferenceImage.vue'; import ReferenceImage from './config/ReferenceImage.vue';
import { ElButton } from 'element-plus'; import { ElButton } from 'element-plus';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'ConfigPanel', name: 'ConfigPanel',
@@ -70,20 +73,20 @@ export default defineComponent({
ImageWeightSelector, ImageWeightSelector,
ReferenceImage, ReferenceImage,
IsVideosSelector, IsVideosSelector,
ImageUrlInput ImageUrlInput,
Consumption
}, },
emits: ['generate'], emits: ['generate'],
computed: { computed: {
config() { config() {
return this.$store.state.midjourney.config; return this.$store.state.midjourney.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.midjourney?.service;
} }
} }
}); });
</script> </script>
<style lang="scss" scoped>
.panel {
flex: 1;
height: calc(100% - 40px);
}
</style>
+19 -34
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="panel"> <div class="flex flex-col h-full">
<div class="config"> <div class="flex-1 overflow-y-auto p-[15px]">
<prompt-input class="mb-4" /> <prompt-input class="mb-4" />
<model-selector class="mb-4" /> <model-selector class="mb-4" />
<style-selector class="mb-4" /> <style-selector class="mb-4" />
@@ -10,12 +10,13 @@
<start-image class="mb-2" /> <start-image class="mb-2" />
<seed-selector class="mb-4" /> <seed-selector class="mb-4" />
<duration-selector class="mb-4" /> <duration-selector class="mb-4" />
<div class="actions"> </div>
<el-button type="primary" class="btn w-full" round @click="onGenerate"> <div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> <consumption :value="consumption" :service="service" />
{{ $t('pixverse.button.generate') }} <el-button type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
</div> {{ $t('pixverse.button.generate') }}
</el-button>
</div> </div>
</div> </div>
</template> </template>
@@ -33,6 +34,8 @@ import DurationSelector from './config/DurationSelector.vue';
import RatioSelector from './config/RatioSelector.vue'; import RatioSelector from './config/RatioSelector.vue';
import StartImage from './config/StartImage.vue'; import StartImage from './config/StartImage.vue';
import PromptInput from './config/PromptInput.vue'; import PromptInput from './config/PromptInput.vue';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'ConfigPanel', name: 'ConfigPanel',
@@ -47,12 +50,19 @@ export default defineComponent({
DurationSelector, DurationSelector,
StartImage, StartImage,
SeedSelector, SeedSelector,
RatioSelector RatioSelector,
Consumption
}, },
emits: ['generate'], emits: ['generate'],
computed: { computed: {
config() { config() {
return this.$store.state.pixverse?.config; return this.$store.state.pixverse?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.pixverse?.service;
} }
}, },
methods: { methods: {
@@ -62,28 +72,3 @@ export default defineComponent({
} }
}); });
</script> </script>
<style lang="scss" scoped>
.panel {
height: 100%;
padding: 15px;
display: flex;
flex-direction: column;
flex: 1;
height: calc(100% - 40px);
.config {
width: 100%;
height: calc(100% - 50px);
flex: 1;
}
.actions {
height: 50px;
display: flex;
justify-content: center;
align-items: center;
.btn {
width: 100%;
}
}
}
</style>
+23 -13
View File
@@ -1,6 +1,6 @@
<template> <template>
<div class="panel"> <div class="flex flex-col h-full">
<div class="config"> <div class="flex-1 overflow-y-auto p-[15px]">
<type-selector class="mb-4" /> <type-selector class="mb-4" />
<upload-audio class="mb-4" /> <upload-audio class="mb-4" />
<prompt-input v-if="!config?.custom" class="mb-4" /> <prompt-input v-if="!config?.custom" class="mb-4" />
@@ -9,16 +9,17 @@
<title-input v-if="config?.custom" class="mb-4" /> <title-input v-if="config?.custom" class="mb-4" />
<extend-from-input v-if="config?.action === 'extend'" class="mb-4" /> <extend-from-input v-if="config?.action === 'extend'" class="mb-4" />
<cover-from-input v-if="config?.action === 'cover'" class="mb-4" /> <cover-from-input v-if="config?.action === 'cover'" class="mb-4" />
<div class="actions"> </div>
<el-button v-if="config?.action !== 'extend'" type="primary" class="btn w-full" round @click="onGenerate"> <div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> <consumption :value="consumption" :service="service" />
{{ $t('suno.button.generate') }} <el-button v-if="config?.action !== 'extend'" type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate"> {{ $t('suno.button.generate') }}
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" /> </el-button>
{{ $t('suno.button.extend') }} <el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
</el-button> <font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
</div> {{ $t('suno.button.extend') }}
</el-button>
</div> </div>
</div> </div>
</template> </template>
@@ -35,6 +36,8 @@ import TitleInput from './config/TitleInput.vue';
import ExtendFromInput from './config/ExtendFromInput.vue'; import ExtendFromInput from './config/ExtendFromInput.vue';
import CoverFromInput from './config/CoverFromInput.vue'; import CoverFromInput from './config/CoverFromInput.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({ export default defineComponent({
name: 'PresetPanel', name: 'PresetPanel',
@@ -48,12 +51,19 @@ export default defineComponent({
CoverFromInput, CoverFromInput,
UploadAudio, UploadAudio,
FontAwesomeIcon, FontAwesomeIcon,
ElButton ElButton,
Consumption
}, },
emits: ['generate'], emits: ['generate'],
computed: { computed: {
config() { config() {
return this.$store.state.suno?.config; return this.$store.state.suno?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.suno?.service;
} }
}, },
methods: { methods: {
+1
View File
@@ -10,6 +10,7 @@ export interface IService {
applied_count?: number; applied_count?: number;
applied?: boolean; applied?: boolean;
tags?: string[]; tags?: string[];
metadata?: any;
thumbnail?: string; thumbnail?: string;
introduction?: string; introduction?: string;
apis?: IApi[]; apis?: IApi[];
+14
View File
@@ -1,5 +1,6 @@
import { CURRENCY_LABEL_MAPPING } from '@/constants/mapping'; import { CURRENCY_LABEL_MAPPING } from '@/constants/mapping';
import store from '@/store'; import store from '@/store';
import jsonLogic from 'json-logic-js';
/** /**
* Input a value and target currency (e.g. cny), return the price which the current locale * Input a value and target currency (e.g. cny), return the price which the current locale
@@ -45,3 +46,16 @@ export const getPriceString = (payload: {
}); });
return `${price.label}${price.value?.toFixed(fractionDigits)}`; return `${price.label}${price.value?.toFixed(fractionDigits)}`;
}; };
export const getConsumption = (payload: any, rules: any): number | undefined => {
if (!rules || !Array.isArray(rules)) {
return undefined;
}
for (const rule of rules) {
const conditions = rule.conditions;
if (jsonLogic.apply(conditions, payload)) {
return jsonLogic.apply(rule.consumption) as number;
}
}
return 0;
};
+10
View File
@@ -1122,6 +1122,11 @@
"@types/minimatch" "^5.1.2" "@types/minimatch" "^5.1.2"
"@types/node" "*" "@types/node" "*"
"@types/json-logic-js@^2.0.8":
version "2.0.8"
resolved "https://registry.yarnpkg.com/@types/json-logic-js/-/json-logic-js-2.0.8.tgz#a1108452069a498981813e32dd081754ae6b3395"
integrity sha512-WgNsDPuTPKYXl0Jh0IfoCoJoAGGYZt5qzpmjuLSEg7r0cKp/kWtWp0HAsVepyPSPyXiHo6uXp/B/kW/2J1fa2Q==
"@types/json-schema@^7.0.9": "@types/json-schema@^7.0.9":
version "7.0.15" version "7.0.15"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
@@ -3677,6 +3682,11 @@ json-buffer@3.0.1:
resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13"
integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==
json-logic-js@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/json-logic-js/-/json-logic-js-2.0.5.tgz#55f0c687dd6f56b02ccdcfdd64171ed998ab5499"
integrity sha512-rTT2+lqcuUmj4DgWfmzupZqQDA64AdmYqizzMPWj3DxGdfFNsxPpcNVSaTj4l8W2tG/+hg7/mQhxjU3aPacO6g==
json-parse-even-better-errors@^2.3.0: json-parse-even-better-errors@^2.3.0:
version "2.3.1" version "2.3.1"
resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d"