1 parent
36f5dc04d1
commit
0e93a2b945
141 files changed
+7410
-1485
No files matched your search
@@ -46,6 +46,8 @@ import {
|
||||
ROUTE_PIXVERSE_HISTORY,
|
||||
ROUTE_VEO_INDEX,
|
||||
ROUTE_VEO_HISTORY,
|
||||
ROUTE_SORA_INDEX,
|
||||
ROUTE_SORA_HISTORY,
|
||||
ROUTE_NANOBANANA_INDEX
|
||||
} from '@/router/constants';
|
||||
import { CHAT_MODEL_ICON_CHATGPT, CHAT_MODEL_ICON_DEEPSEEK, CHAT_MODEL_ICON_GROK } from '@/constants/chat';
|
||||
@@ -220,6 +222,17 @@ export default defineComponent({
|
||||
routes: [ROUTE_VEO_INDEX, ROUTE_VEO_HISTORY]
|
||||
});
|
||||
}
|
||||
// Add sora's leftmost icon
|
||||
if (this.$store?.state?.site?.features?.sora?.enabled) {
|
||||
result.push({
|
||||
route: {
|
||||
name: ROUTE_SORA_INDEX
|
||||
},
|
||||
displayName: this.$t('common.nav.sora'),
|
||||
logo: 'https://cdn.acedata.cloud/z5id1u.png',
|
||||
routes: [ROUTE_SORA_INDEX, ROUTE_SORA_HISTORY]
|
||||
});
|
||||
}
|
||||
// Add pixverse's leftmost icon
|
||||
if (this.$store?.state?.site?.features?.pixverse?.enabled) {
|
||||
result.push({
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
'pika',
|
||||
'kling',
|
||||
'veo',
|
||||
'sora',
|
||||
'pixverse',
|
||||
'flux',
|
||||
'hailuo',
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<div class="flex flex-col h-full">
|
||||
<div class="flex-1 overflow-y-auto p-[15px]">
|
||||
<model-selector class="mb-4" />
|
||||
<action-selector class="mb-4" />
|
||||
<duration-selector class="mb-4" />
|
||||
<size-selector class="mb-4" />
|
||||
<orientation-selector class="mb-4" />
|
||||
<prompt-input class="mb-4" />
|
||||
<start-end-image v-show="config?.action === 'image2video'" class="mb-2" />
|
||||
</div>
|
||||
<div class="flex flex-col items-center justify-center px-[15px] pb-[15px]">
|
||||
<consumption :value="consumption" :service="service" />
|
||||
<el-button type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('sora.button.generate') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import ModelSelector from './config/ModelSelector.vue';
|
||||
import ActionSelector from './config/ActionSelector.vue';
|
||||
import DurationSelector from './config/DurationSelector.vue';
|
||||
import OrientationSelector from './config/OrientationSelector.vue';
|
||||
import StartEndImage from './config/StartEndImage.vue';
|
||||
import SizeSelector from './config/SizeSelector.vue';
|
||||
import Consumption from '../common/Consumption.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
import { getConsumption } from '@/utils';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConfigPanel',
|
||||
components: {
|
||||
ElButton,
|
||||
Consumption,
|
||||
FontAwesomeIcon,
|
||||
PromptInput,
|
||||
ModelSelector,
|
||||
StartEndImage,
|
||||
SizeSelector,
|
||||
ActionSelector,
|
||||
OrientationSelector,
|
||||
DurationSelector
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
config() {
|
||||
return this.$store.state.sora?.config;
|
||||
},
|
||||
consumption() {
|
||||
return getConsumption(this.config, this.service?.metadata?.price);
|
||||
},
|
||||
service() {
|
||||
return this.$store.state.sora?.service;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onGenerate() {
|
||||
this.$emit('generate');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div v-if="tasks?.items === undefined">
|
||||
<bot-placeholder />
|
||||
</div>
|
||||
<div v-else-if="tasks?.items?.length && tasks?.items?.length > 0" class="tasks h-full w-full overflow-y-auto">
|
||||
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" />
|
||||
</div>
|
||||
<div v-if="tasks?.items?.length === 0" class="w-full h-full flex items-center justify-center">
|
||||
<no-tasks />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './task/Preview.vue';
|
||||
import BotPlaceholder from '@/components/common/BotPlaceholder.vue';
|
||||
import NoTasks from '@/components/common/NoTasks.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RecentPanel',
|
||||
components: {
|
||||
TaskPreview,
|
||||
NoTasks,
|
||||
BotPlaceholder
|
||||
},
|
||||
emits: ['reach-top'],
|
||||
data() {
|
||||
return {
|
||||
job: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
tasks() {
|
||||
// reverse the order of the tasks.items
|
||||
return {
|
||||
...this.$store.state.sora?.tasks,
|
||||
items: this.$store.state.sora?.tasks?.items?.slice()
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onHandleScroll() {
|
||||
const el = this.$refs.panel as HTMLElement;
|
||||
console.log('reach-top reach-top reach-top');
|
||||
if (el.scrollTop === 0) {
|
||||
this.$emit('reach-top');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('sora.name.action') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('sora.placeholder.select')" clearable>
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
||||
<span class="float-left">{{ item.label }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import { SORA_DEFAULT_ACTION } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ActionSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
options() {
|
||||
return [
|
||||
{
|
||||
value: 'text2video',
|
||||
label: this.$t('sora.button.action1')
|
||||
},
|
||||
{
|
||||
value: 'image2video',
|
||||
label: this.$t('sora.button.action2')
|
||||
}
|
||||
];
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.sora?.config?.action;
|
||||
},
|
||||
set(val: string) {
|
||||
this.$store.commit('sora/setConfig', {
|
||||
...this.$store.state.sora?.config,
|
||||
action: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = SORA_DEFAULT_ACTION;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<h2 class="title font-bold">{{ $t('sora.name.duration') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('sora.placeholder.select')" :disabled="isLocked">
|
||||
<el-option v-for="item in optionsForModel" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
<p v-if="isLocked" class="hint">{{ $t('sora.tip.proOnly') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import { SORA_ALLOWED_DURATIONS, SORA_DEFAULT_DURATION, SORA_DEFAULT_MODEL, SORA_MODEL_PRO } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DurationSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
options: SORA_ALLOWED_DURATIONS.map((duration) => ({
|
||||
value: duration,
|
||||
label: `${duration}s`
|
||||
}))
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
model(): string {
|
||||
return this.$store.state.sora?.config?.model || SORA_DEFAULT_MODEL;
|
||||
},
|
||||
isLocked(): boolean {
|
||||
return this.model !== SORA_MODEL_PRO;
|
||||
},
|
||||
optionsForModel(): Array<{ value: number; label: string }> {
|
||||
if (this.isLocked) {
|
||||
return this.options.filter((option) => option.value === SORA_DEFAULT_DURATION);
|
||||
}
|
||||
return this.options;
|
||||
},
|
||||
value: {
|
||||
get(): number | undefined {
|
||||
return this.$store.state.sora?.config?.duration;
|
||||
},
|
||||
set(val: number | undefined) {
|
||||
const currentConfig = this.$store.state.sora?.config || {};
|
||||
this.$store.commit('sora/setConfig', {
|
||||
...currentConfig,
|
||||
duration: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isLocked(newValue: boolean) {
|
||||
if (newValue && this.value !== SORA_DEFAULT_DURATION) {
|
||||
this.value = SORA_DEFAULT_DURATION;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = SORA_DEFAULT_DURATION;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.control {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.value {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title font-bold">{{ $t('sora.name.model') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('sora.placeholder.select')">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import {
|
||||
SORA_DEFAULT_DURATION,
|
||||
SORA_DEFAULT_MODEL,
|
||||
SORA_DEFAULT_SIZE,
|
||||
SORA_MODEL_PRO,
|
||||
SORA_MODEL_STANDARD
|
||||
} from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ModelSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: SORA_MODEL_STANDARD,
|
||||
label: 'sora-2'
|
||||
},
|
||||
{
|
||||
value: SORA_MODEL_PRO,
|
||||
label: 'sora-2-pro'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.sora?.config?.model;
|
||||
},
|
||||
set(val: string) {
|
||||
const currentConfig = this.$store.state.sora?.config || {};
|
||||
const nextConfig = {
|
||||
...currentConfig,
|
||||
model: val
|
||||
} as Record<string, any>;
|
||||
|
||||
if (val === SORA_MODEL_STANDARD) {
|
||||
nextConfig.duration = SORA_DEFAULT_DURATION;
|
||||
nextConfig.size = SORA_DEFAULT_SIZE;
|
||||
} else if (val === SORA_MODEL_PRO) {
|
||||
nextConfig.duration = nextConfig.duration || SORA_DEFAULT_DURATION;
|
||||
nextConfig.size = nextConfig.size || SORA_DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
this.$store.commit('sora/setConfig', nextConfig);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = SORA_DEFAULT_MODEL;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div>
|
||||
<span class="text-sm font-bold mb-2 block">{{ $t('sora.name.orientation') }}</span>
|
||||
<div class="items">
|
||||
<div
|
||||
v-for="(option, optionKey) in options"
|
||||
:key="optionKey"
|
||||
:class="{ active: active === optionKey, item: true }"
|
||||
@click="value = option.value"
|
||||
>
|
||||
<div class="preview" :class="option.value">
|
||||
<div class="rect" :style="{ width: option.width + 'px', height: option.height + 'px' }"></div>
|
||||
</div>
|
||||
<p class="name">
|
||||
{{ option.label }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { SORA_DEFAULT_ORIENTATION } from '@/constants';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OrientationSelector',
|
||||
data() {
|
||||
return {
|
||||
options: [
|
||||
{
|
||||
value: 'portrait',
|
||||
label: '竖屏',
|
||||
width: 13,
|
||||
height: 25
|
||||
},
|
||||
{
|
||||
value: 'landscape',
|
||||
label: '横屏',
|
||||
width: 25,
|
||||
height: 13
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
active() {
|
||||
return this.options.findIndex((option) => option.value === this.value) || 0;
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.sora?.config?.orientation;
|
||||
},
|
||||
set(val: string) {
|
||||
console.debug('set orientation', val);
|
||||
this.$store.commit('sora/setConfig', {
|
||||
...this.$store.state?.sora?.config,
|
||||
orientation: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = SORA_DEFAULT_ORIENTATION;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.items {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 12px;
|
||||
|
||||
.item {
|
||||
width: 48px;
|
||||
height: 65px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
border-radius: var(--el-border-radius-base);
|
||||
|
||||
.preview {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 3px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.rect {
|
||||
border: 1px solid var(--el-border-color);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--el-color-primary);
|
||||
.rect {
|
||||
border-color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<div class="box">
|
||||
<h2 class="title font-bold">{{ $t('sora.name.prompt') }}</h2>
|
||||
<info-icon :content="$t('sora.description.prompt')" class="info" />
|
||||
</div>
|
||||
<el-input
|
||||
v-model="prompt"
|
||||
:rows="3"
|
||||
type="textarea"
|
||||
class="prompt"
|
||||
:placeholder="$t('sora.placeholder.prompt')"
|
||||
:maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElInput } from 'element-plus';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
|
||||
export const DEFAULT_PROMPT = '';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PromptInput',
|
||||
components: {
|
||||
ElInput,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
prompt: {
|
||||
get() {
|
||||
return this.$store.state.sora?.config?.prompt;
|
||||
},
|
||||
set(val: string) {
|
||||
console.debug('set prompt', val);
|
||||
this.$store.commit('sora/setConfig', {
|
||||
...this.$store.state.sora?.config,
|
||||
prompt: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.prompt) {
|
||||
this.prompt = DEFAULT_PROMPT;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // Add this line to move the icon to the right
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
margin-left: auto; // Ensure the icon stays on the right
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<h2 class="title font-bold">{{ $t('sora.name.size') }}</h2>
|
||||
<el-select v-model="value" class="value" :placeholder="$t('sora.placeholder.select')" :disabled="isLocked">
|
||||
<el-option v-for="item in optionsForModel" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
<p v-if="isLocked" class="hint">{{ $t('sora.tip.proOnly') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSelect, ElOption } from 'element-plus';
|
||||
import { SORA_ALLOWED_SIZES, SORA_DEFAULT_MODEL, SORA_DEFAULT_SIZE, SORA_MODEL_PRO } from '@/constants';
|
||||
|
||||
const formatSizeLabel = (value: string): string => {
|
||||
if (!value) {
|
||||
return value;
|
||||
}
|
||||
return value.charAt(0).toUpperCase() + value.slice(1);
|
||||
};
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SizeSelector',
|
||||
components: {
|
||||
ElSelect,
|
||||
ElOption
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
options: SORA_ALLOWED_SIZES.map((size) => ({
|
||||
value: size,
|
||||
label: formatSizeLabel(size)
|
||||
}))
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
model(): string {
|
||||
return this.$store.state.sora?.config?.model || SORA_DEFAULT_MODEL;
|
||||
},
|
||||
isLocked(): boolean {
|
||||
return this.model !== SORA_MODEL_PRO;
|
||||
},
|
||||
optionsForModel(): Array<{ value: string; label: string }> {
|
||||
if (this.isLocked) {
|
||||
return this.options.filter((option) => option.value === SORA_DEFAULT_SIZE);
|
||||
}
|
||||
return this.options;
|
||||
},
|
||||
value: {
|
||||
get(): string | undefined {
|
||||
return this.$store.state.sora?.config?.size;
|
||||
},
|
||||
set(val: string | undefined) {
|
||||
const currentConfig = this.$store.state.sora?.config || {};
|
||||
this.$store.commit('sora/setConfig', {
|
||||
...currentConfig,
|
||||
size: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isLocked(newValue: boolean) {
|
||||
if (newValue && this.value !== SORA_DEFAULT_SIZE) {
|
||||
this.value = SORA_DEFAULT_SIZE;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = SORA_DEFAULT_SIZE;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.control {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.value {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div class="relative">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex justify-start items-center">
|
||||
<span class="text-sm font-bold">{{ $t('sora.name.startEndImage') }}</span>
|
||||
<info-icon :content="$t('sora.description.uploadStartEndImage')" />
|
||||
</div>
|
||||
</div>
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
name="file"
|
||||
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
|
||||
:limit="2"
|
||||
class="upload-wrapper"
|
||||
:multiple="false"
|
||||
:action="uploadUrl"
|
||||
list-type="picture"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:on-success="onSuccess"
|
||||
:headers="headers"
|
||||
>
|
||||
<template #file="{ file }">
|
||||
<image-preview
|
||||
v-if="file.url && file.percentage !== undefined"
|
||||
:url="file.url"
|
||||
:name="file.name"
|
||||
:percentage="file.percentage"
|
||||
@remove="fileList.splice(fileList.indexOf(file), 1)"
|
||||
/>
|
||||
</template>
|
||||
<el-button round type="primary" size="small" class="btn btn-upload">
|
||||
<font-awesome-icon icon="fa-solid fa-upload" class="icon mr-1" />
|
||||
{{ $t('sora.button.uploadReferences') }}
|
||||
</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElUpload, ElButton, UploadFiles, UploadFile, ElMessage } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { getBaseUrlPlatform } from '@/utils';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
import ImagePreview from '@/components/common/ImagePreview.vue';
|
||||
|
||||
interface IData {
|
||||
fileList: UploadFiles;
|
||||
uploadUrl: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'StartEndImage',
|
||||
components: {
|
||||
ElUpload,
|
||||
ElButton,
|
||||
InfoIcon,
|
||||
FontAwesomeIcon,
|
||||
ImagePreview
|
||||
},
|
||||
emits: ['change'],
|
||||
data(): IData {
|
||||
return {
|
||||
fileList: [],
|
||||
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${this.$store.state.token.access}`
|
||||
};
|
||||
},
|
||||
urls() {
|
||||
// @ts-ignore
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state?.sora?.config?.image_urls;
|
||||
},
|
||||
set() {
|
||||
// this.$store.commit('sora/setConfig', {
|
||||
// ...this.$store.state?.sora?.config,
|
||||
// image_urls: val
|
||||
// });
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
this.onSetStartEndImageUrl();
|
||||
},
|
||||
methods: {
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('sora.message.uploadReferencesExceed'));
|
||||
},
|
||||
onError() {
|
||||
ElMessage.error(this.$t('sora.message.uploadReferencesError'));
|
||||
},
|
||||
onSetStartEndImageUrl() {
|
||||
const urls = this.urls;
|
||||
this.$store.commit('sora/setConfig', {
|
||||
...this.$store.state?.sora?.config,
|
||||
image_urls: urls
|
||||
});
|
||||
},
|
||||
async onSuccess() {
|
||||
this.onSetStartEndImageUrl();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.btn.btn-upload {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.upload-wrapper {
|
||||
height: auto;
|
||||
display: flex;
|
||||
.el-upload-list {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,245 @@
|
||||
<template>
|
||||
<div class="preview">
|
||||
<div class="left">
|
||||
<el-image src="https://cdn.acedata.cloud/z5id1u.png" class="avatar" />
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="bot">
|
||||
{{ $t('sora.name.soraBot') }}
|
||||
<span class="datetime">
|
||||
{{ $dayjs.format('' + new Date(parseFloat((modelValue?.created_at || '').toString()) * 1000)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
|
||||
{{ modelValue?.request?.prompt }}
|
||||
<span v-if="!modelValue?.response"> - ({{ $t('sora.status.pending') }}) </span>
|
||||
<span v-if="Array.isArray(modelValue?.response?.data) && modelValue?.response?.data[0]?.state === 'pending'">
|
||||
- ({{ $t('sora.status.processing') }})
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Display success message -->
|
||||
<div
|
||||
v-if="modelValue?.response?.success === true && modelValue?.response?.data"
|
||||
:class="{ content: true, failed: true }"
|
||||
>
|
||||
<div v-if="modelValue?.response?.data[0]?.video_url" class="mb-4">
|
||||
<video-player :src="modelValue?.response?.data[0]?.video_url" />
|
||||
</div>
|
||||
<div v-if="modelValue?.response.success" :class="{ operations: true, 'mt-2': true }">
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('sora.message.downloadVideo')" placement="top-start">
|
||||
<el-button
|
||||
v-if="modelValue?.response?.data[0]?.video_url"
|
||||
type="info"
|
||||
size="small"
|
||||
class="btn-action"
|
||||
@click="onDownload($event, modelValue?.response?.data[0]?.video_url)"
|
||||
>
|
||||
{{ $t('sora.button.download') }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<el-alert :closable="false" class="mt-2 success">
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('sora.name.model') }}:
|
||||
{{ modelValue?.request?.model }}
|
||||
</p>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('sora.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div v-if="modelValue?.response?.success === false" :class="{ content: true }">
|
||||
<el-alert :closable="false" class="failure">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('sora.name.failure') }}
|
||||
</template>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('sora.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('sora.name.failureReason') }}:
|
||||
{{ modelValue?.response?.error?.message }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.error?.message!" />
|
||||
</p>
|
||||
<p v-if="modelValue?.response?.trace_id" class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('sora.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
<!-- Display error message -->
|
||||
<div v-if="modelValue?.response?.success === undefined" :class="{ content: true }">
|
||||
<el-alert :closable="false" class="info">
|
||||
<template #template>
|
||||
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
|
||||
{{ $t('sora.name.failure') }}
|
||||
</template>
|
||||
<p class="text-[var(--el-text-color-regular)] text-xs mb-2">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
|
||||
{{ $t('sora.name.taskId') }}:
|
||||
{{ modelValue?.id }}
|
||||
<copy-to-clipboard :content="modelValue?.id!" />
|
||||
</p>
|
||||
<p v-if="modelValue?.response?.trace_id" class="text-[var(--el-text-color-regular)] text-xs mb-0">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
{{ $t('sora.name.traceId') }}:
|
||||
{{ modelValue?.response?.trace_id }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.trace_id" />
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElAlert, ElButton, ElTooltip } from 'element-plus';
|
||||
import { ISoraTask } from '@/models';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import VideoPlayer from '@/components/common/VideoPlayer.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskPreview',
|
||||
components: {
|
||||
ElImage,
|
||||
CopyToClipboard,
|
||||
FontAwesomeIcon,
|
||||
ElAlert,
|
||||
VideoPlayer,
|
||||
ElTooltip,
|
||||
ElButton
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => ISoraTask | undefined,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.sora?.application;
|
||||
},
|
||||
config() {
|
||||
return this.$store.state.sora?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onDownload(event: MouseEvent, video_url: string) {
|
||||
event.stopPropagation();
|
||||
console.log('on download');
|
||||
// download url here
|
||||
window.open(video_url, '_blank');
|
||||
},
|
||||
onOpenVideo(url: string) {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$left-width: 70px;
|
||||
.preview {
|
||||
width: 100%;
|
||||
height: fit-content;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-bottom: 15px;
|
||||
.left {
|
||||
width: $left-width;
|
||||
.avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
flex: 1;
|
||||
width: calc(100% - $left-width);
|
||||
padding: 10px 10px 0 10px;
|
||||
|
||||
.bot {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: rgb(46, 204, 113);
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
.datetime {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
.prompt {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.el-alert {
|
||||
border-left-width: 2px;
|
||||
border-left-style: solid;
|
||||
&.failure {
|
||||
border-color: var(--el-color-danger);
|
||||
}
|
||||
&.success {
|
||||
border-color: var(--el-color-success);
|
||||
}
|
||||
&.info {
|
||||
border-color: var(--el-color-info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 14px;
|
||||
overflow-y: scroll;
|
||||
|
||||
&.full {
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user