Co-authored-by: Germey <cqc@cuiqingcai.com>
This commit is contained in:
HCodeandGermey authored and GitHub committed 2024-08-16 17:49:20 +00:00
1 parent 2e0665f09c
commit 6be9299532
42 files changed
+2342 -5

No files matched your search

@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "finish luma ui",
"packageName": "@acedatacloud/nexior",
"email": "1348977728@qq.com",
"dependentChangeType": "patch"
}
+14 -1
View File
@@ -108,8 +108,10 @@ import {
ROUTE_INDEX,
ROUTE_MIDJOURNEY_INDEX,
ROUTE_QRART_INDEX,
ROUTE_SUNO_INDEX,
ROUTE_QRART_HISTORY,
ROUTE_LUMA_INDEX,
ROUTE_LUMA_HISTORY,
ROUTE_SUNO_INDEX,
ROUTE_SUNO_HISTORY,
ROUTE_SITE_INDEX
} from '@/router/constants';
@@ -200,6 +202,17 @@ export default defineComponent({
routes: [ROUTE_SUNO_INDEX, ROUTE_SUNO_HISTORY]
});
}
// Add luma's leftmost icon
if (this.$store?.state?.site?.features?.luma?.enabled) {
result.push({
route: {
name: ROUTE_LUMA_INDEX
},
displayName: this.$t('common.nav.luma'),
icon: 'fa-solid fa-film',
routes: [ROUTE_LUMA_INDEX, ROUTE_LUMA_HISTORY]
});
}
if (this.direction === 'row') {
result.push({
+1
View File
@@ -13,6 +13,7 @@
></el-menu-item>
<el-menu-item v-if="site?.features?.qrart?.enabled" v-t="'index.title.qrart'" index="/qrart"></el-menu-item>
<el-menu-item v-if="site?.features?.suno?.enabled" v-t="'index.title.suno'" index="/suno"></el-menu-item>
<el-menu-item v-if="site?.features?.qrart?.enabled" v-t="'index.title.luma'" index="/luma"></el-menu-item>
</el-menu>
</el-col>
<el-col :md="4" :xs="11">
+78
View File
@@ -0,0 +1,78 @@
<template>
<div class="panel">
<div class="config">
<prompt-input class="mb-4" />
<start-image-url-input class="mb-4" />
<end-image-url-input class="mb-4" />
<enhancement-selector class="mb-4" />
<loop-selector class="mb-4" />
<div class="actions">
<el-button v-if="config?.action !== 'extend'" type="primary" class="btn w-full" round @click="onGenerate">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
{{ $t('luma.button.generate') }}
</el-button>
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
{{ $t('luma.button.extend') }}
</el-button>
</div>
</div>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import EnhancementSelector from './config/EnhancementSelector.vue';
import LoopSelector from './config/LoopSelector.vue';
import EndImageUrlInput from './config/EndImageUrlInput.vue';
import StartImageUrlInput from './config/StartImageUrlInput.vue';
import PromptInput from './config/PromptInput.vue';
export default defineComponent({
name: 'PresetPanel',
components: {
LoopSelector,
StartImageUrlInput,
EndImageUrlInput,
EnhancementSelector,
ElButton,
FontAwesomeIcon,
PromptInput
},
emits: ['generate'],
computed: {
config() {
return this.$store.state.luma?.config;
}
},
methods: {
onGenerate() {
this.$emit('generate');
}
}
});
</script>
<style lang="scss" scoped>
.panel {
height: 100%;
padding: 15px;
display: flex;
flex-direction: column;
.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
View File
@@ -0,0 +1,23 @@
<template>
<div class="panel detail">
<task-detail />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import TaskDetail from './task/Detail.vue';
export default defineComponent({
name: 'DetailPanel',
components: {
TaskDetail
},
data() {
return {
job: 0
};
},
computed: {}
});
</script>
+77
View File
@@ -0,0 +1,77 @@
<template>
<div>
<el-card v-show="operating">
<content-input class="mb-4" />
<prompt-input class="mb-4" />
<preset-selector class="mb-4" />
<div class="actions">
<el-button type="primary" class="btn w-full" round @click="onGenerate">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
{{ $t('qrart.button.generate') }}
</el-button>
</div>
</el-card>
<div>
<el-button type="primary" class="btn btn-operate" @click="operating = !operating">+</el-button>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElButton, ElCard } from 'element-plus';
import PresetSelector from './config/PresetSelector2.vue';
import ContentInput from './config/ContentInput.vue';
import PromptInput from './config/PromptInput.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'OperationPanel',
components: {
ElButton,
ElCard,
PresetSelector,
ContentInput,
PromptInput,
FontAwesomeIcon
},
emits: ['generate'],
data() {
return {
operating: false
};
},
methods: {
onGenerate() {
this.$emit('generate');
this.operating = false;
}
}
});
</script>
<style lang="scss" scoped>
.el-card {
width: 580px;
height: fit-content;
overflow-y: scroll;
position: absolute;
bottom: 70px;
left: calc(50% - 300px);
@media (max-width: 767px) {
width: 100%;
left: 0;
}
}
.btn-operate {
width: 50px;
height: 50px;
border-radius: 50%;
font-size: 24px;
line-height: 40px;
padding: 0;
margin: auto;
display: block;
}
</style>
+131
View File
@@ -0,0 +1,131 @@
<template>
<div class="panel recent">
<div v-if="tasks?.items === undefined" class="tasks">
<div v-for="_ in 3" :key="_" class="task placeholder">
<div class="left">
<el-skeleton animated>
<template #template>
<el-skeleton-item variant="image" class="avatar" />
</template>
</el-skeleton>
</div>
<div class="main">
<el-skeleton animated>
<template #template>
<el-skeleton-item variant="p" class="title" />
<el-skeleton-item variant="image" class="icon" />
</template>
</el-skeleton>
</div>
</div>
</div>
<div v-else-if="tasks?.items?.length && tasks?.items?.length > 0" class="tasks">
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" class="preview" />
</div>
<p v-if="tasks?.items?.length === 0" class="description">
{{ $t('luma.message.noTasks') }}
</p>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import TaskPreview from './task/Preview.vue';
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
export default defineComponent({
name: 'RecentPanel',
components: {
TaskPreview,
ElSkeleton,
ElSkeletonItem
},
data() {
return {
job: 0
};
},
computed: {
tasks() {
// reverse the order of the tasks.items
return {
...this.$store.state.luma?.tasks,
items: this.$store.state.luma?.tasks?.items?.slice().reverse()
};
}
}
});
</script>
<style lang="scss" scoped>
.panel {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
&.recent {
width: 100%;
height: 100%;
display: flex;
overflow-y: auto;
flex-direction: column;
.preview {
margin-right: 15px;
}
.description {
text-align: left;
font-size: 14px;
color: var(--el-text-color-secondary);
}
.tasks {
width: 100%;
.task {
margin-bottom: 15px;
width: 100%;
height: fit-content;
text-align: left;
&.placeholder {
display: flex;
flex-direction: row;
.left {
width: 70px;
padding: 10px;
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
}
}
.main {
width: calc(100% - 70px);
flex: 1;
padding: 10px;
margin-bottom: 10px;
.icon {
display: flex;
height: 200px;
width: 300px;
}
.title {
display: block;
width: 200px;
height: 20px;
margin-bottom: 15px;
}
}
}
.operations {
height: fit-content !important;
}
}
}
}
}
</style>
@@ -0,0 +1,59 @@
<template>
<div class="field">
<h2 class="title">{{ $t('luma.name.endImageUrl') }}</h2>
<el-input v-model="value" class="value" :placeholder="$t('luma.placeholder.endImageUrl')" />
<info-icon :content="$t('luma.description.endImageUrl')" class="info" />
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElInput } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
export default defineComponent({
name: 'EndImageUrlInput',
components: {
ElInput,
InfoIcon
},
data() {
return {};
},
computed: {
value: {
get() {
return this.$store.state.luma?.config?.end_image_url;
},
set(val) {
console.debug('set end_image_url', val);
this.$store.commit('luma/setConfig', {
...this.$store.state.luma?.config,
end_image_url: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = undefined;
}
}
});
</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,58 @@
<template>
<div class="field">
<h2 class="title">{{ $t('luma.name.enhancement') }}</h2>
<el-switch v-model="value" class="value" />
<info-icon :content="$t('luma.description.enhancement')" class="info" />
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSwitch } from 'element-plus';
import { LUMA_DEFAULT_ENHANCEMENT } from '@/constants';
import InfoIcon from '@/components/common/InfoIcon.vue';
export default defineComponent({
name: 'EnhancementSelector',
components: {
ElSwitch,
InfoIcon
},
computed: {
value: {
get() {
return this.$store.state.luma?.config?.enhancement;
},
set(val) {
console.debug('set enhancement', val);
this.$store.commit('luma/setConfig', {
...this.$store.state.luma?.config,
enhancement: val
});
}
}
},
mounted() {
if (this.value === undefined) {
this.value = LUMA_DEFAULT_ENHANCEMENT;
}
}
});
</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;
margin-left: 60px; // Adjust this value as needed
}
}
</style>
@@ -0,0 +1,58 @@
<template>
<div class="field">
<h2 class="title">{{ $t('luma.name.loop') }}</h2>
<el-switch v-model="value" class="value" />
<info-icon :content="$t('luma.description.loop')" class="info" />
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElSwitch } from 'element-plus';
import { LUMA_DEFAULT_LOOP } from '@/constants';
import InfoIcon from '@/components/common/InfoIcon.vue';
export default defineComponent({
name: 'LoopSelector',
components: {
ElSwitch,
InfoIcon
},
computed: {
value: {
get() {
return this.$store.state.luma?.config?.loop;
},
set(val) {
console.debug('set loop', val);
this.$store.commit('luma/setConfig', {
...this.$store.state.luma?.config,
loop: val
});
}
}
},
mounted() {
if (this.value === undefined) {
this.value = LUMA_DEFAULT_LOOP;
}
}
});
</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;
margin-left: 60px; // Adjust this value as needed
}
}
</style>
@@ -0,0 +1,70 @@
<template>
<div class="field">
<div class="box">
<h2 class="title">{{ $t('luma.name.prompt') }}</h2>
<info-icon :content="$t('luma.description.prompt')" class="info" />
</div>
<el-input
v-model="prompt"
:rows="3"
type="textarea"
class="prompt"
:placeholder="$t('luma.placeholder.prompt')"
:maxlength="300"
show-word-limit
/>
</div>
</template>
<script>
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
},
data() {
return {};
},
computed: {
prompt: {
get() {
return this.$store.state.suno?.config?.prompt;
},
set(val) {
console.debug('set prompt', val);
this.$store.commit('suno/setConfig', {
...this.$store.state.suno?.config,
prompt: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = DEFAULT_PROMPT;
}
}
});
</script>
<style lang="scss" scoped>
.field {
.box {
display: flex;
flex-direction: row;
align-items: center;
position: relative;
.title {
font-size: 14px;
margin-bottom: 10px;
}
}
}
</style>
@@ -0,0 +1,59 @@
<template>
<div class="field">
<h2 class="title">{{ $t('luma.name.startImageUrl') }}</h2>
<el-input v-model="value" class="value" :placeholder="$t('luma.placeholder.startImageUrl')" />
<info-icon :content="$t('luma.description.startImageUrl')" class="info" />
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { ElInput } from 'element-plus';
import InfoIcon from '@/components/common/InfoIcon.vue';
export default defineComponent({
name: 'StartImageUrlInput',
components: {
ElInput,
InfoIcon
},
data() {
return {};
},
computed: {
value: {
get() {
return this.$store.state.luma?.config?.start_image_url;
},
set(val) {
console.debug('set start_image_url', val);
this.$store.commit('luma/setConfig', {
...this.$store.state.luma?.config,
start_image_url: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = undefined;
}
}
});
</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>
+176
View File
@@ -0,0 +1,176 @@
<template>
<div v-if="task" class="detail">
<el-row class="h-full">
<el-col :span="24" class="h-full">
<el-row class="h-full main">
<el-col :span="12" class="h-full p-4">
<el-image
v-if="task?.response?.image_url"
:src="task?.response?.image_url"
:preview-src-list="[task?.response?.image_url as string]"
class="image"
fit="contain"
@error="onReload($event)"
/>
<el-alert v-else-if="task?.response?.success === false" :closable="false" class="failure">
<template #template>
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
{{ $t('qrart.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
{{ $t('qrart.name.failureReason') }}:
{{ task?.response?.error?.message }}
<copy-to-clipboard :content="task?.response?.error?.message!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
{{ $t('qrart.name.traceId') }}:
{{ task?.response?.trace_id }}
<copy-to-clipboard :content="task?.response?.trace_id" class="btn-copy" />
</p>
</el-alert>
<el-image v-else class="image error">
<template #error>
<div class="image-slot">{{ $t('qrart.message.generating') }}</div>
</template>
</el-image>
</el-col>
<el-col :span="12" class="h-full overflow-scroll">
<el-descriptions title="" :column="1">
<el-descriptions-item :label="$t('qrart.name.taskId')">
{{ task?.id }}
<copy-to-clipboard :content="task?.id" class="btn-copy" />
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.type')">
{{ task?.request?.type }}
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.content')">
{{ task?.request?.content }}
<copy-to-clipboard :content="task?.request?.content!" class="btn-copy" />
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.prompt')">
{{ task?.request?.prompt }}
<copy-to-clipboard v-if="task?.request?.prompt" :content="task?.request?.prompt" class="btn-copy" />
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.size')">
{{ task?.response?.image_width }} x {{ task?.response?.image_height }}
</el-descriptions-item>
<el-descriptions-item v-if="task?.created_at" :label="$t('qrart.name.createdAt')">
{{ $dayjs.format('' + new Date(parseFloat(task?.created_at) * 1000)) }}
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.seed')">
{{ task?.request?.seed || task?.response?.seed }}
<copy-to-clipboard
v-if="task?.request?.seed || task?.response?.seed"
:content="task?.request?.seed || task?.response?.seed"
class="btn-copy"
/>
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.steps')">
{{ task?.request?.steps }}
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.qrw')">
{{ task?.request?.qrw }}
</el-descriptions-item>
<el-descriptions-item :label="$t('qrart.name.preset')">
{{ task?.request?.preset }}
</el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
</el-col>
</el-row>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElImage, ElRow, ElCol, ElDescriptions, ElDescriptionsItem, ElAlert } from 'element-plus';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'TaskDetail',
components: {
ElImage,
ElAlert,
FontAwesomeIcon,
CopyToClipboard,
ElDescriptions,
ElDescriptionsItem,
ElRow,
ElCol
},
data() {
return {};
},
computed: {
application() {
return this.$store.state.qrart?.application;
},
task() {
return this.$store.state.qrart?.tasks?.active;
}
},
methods: {
onReload(event: Event) {
const target = event.target as HTMLImageElement;
// append a random url query to existing url query, to force reload the image
// extract exiting url query
const url = new URL(target.src);
// extract `retry` query
const retry = url.searchParams.get('retry');
if (!retry) {
// if no retry query, set it as random string
url.searchParams.set('retry', '1');
} else if (parseInt(retry) < 2) {
// if retry < 3, increase it by 1
url.searchParams.set('retry', (parseInt(retry) + 1).toString());
} else {
return;
}
// set the new url
target.src = url.toString();
}
}
});
</script>
<style lang="scss" scoped>
.detail {
height: 100%;
padding: 5px 0;
.main {
padding: 15px;
border: 1px solid var(--el-border-color);
border-radius: 15px;
}
.image {
height: 100%;
display: block;
margin: auto;
}
}
</style>
<style lang="scss">
.detail {
.image.error {
background: var(--el-bg-color-page);
.image-slot {
font-size: 18px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
.failure {
background: var(--el-fill-color-light);
height: 100%;
width: 100%;
}
}
</style>
+292
View File
@@ -0,0 +1,292 @@
<template>
<div class="preview">
<div class="left">
<el-image src="https://cdn.acedata.cloud/bcml67.png" class="avatar" />
</div>
<div class="main">
<div class="bot">
{{ $t('luma.name.lumaBot') }}
<span class="datetime">
<!-- {{ $dayjs.format('' + new Date(parseFloat(modelValue?.created_at || '') * 1000)) }} -->
</span>
</div>
<div class="info">
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
{{ modelValue?.request?.prompt }}
<span v-if="modelValue?.response && Object.keys(modelValue.response).length === 0">
- ({{ $t('luma.status.pending') }})
</span>
</p>
</div>
<!-- Display success message -->
<div v-if="modelValue?.response?.success === true" :class="{ content: true, failed: true }">
<div class="image-wrapper">
<img
v-if="modelValue?.response?.thumbnail_url"
v-loading="!modelValue?.response?.thumbnail_url"
:src="modelValue?.response?.thumbnail_url"
class="image mb-3"
/>
<div v-if="modelValue?.response?.video_url" class="play-icon">
<font-awesome-icon icon="fa-solid fa-play-circle" />
</div>
<el-button
v-if="modelValue?.response?.video_url"
type="info"
round
class="btn-raw"
@click="onOpenUrl(modelValue?.response?.video_url)"
>
{{ $t('common.button.seeRawVideo') }}
</el-button>
</div>
<el-alert :closable="false" class="mt-2 success">
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('luma.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</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('luma.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('luma.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
{{ $t('luma.name.failureReason') }}:
{{ modelValue?.response?.error?.message }}
<copy-to-clipboard :content="modelValue?.response?.error?.message!" class="btn-copy" />
</p>
<p class="description">
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
{{ $t('luma.name.traceId') }}:
{{ modelValue?.response?.trace_id }}
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
</p>
</el-alert>
</div>
<!-- Display error message -->
<div v-if="!modelValue?.response" :class="{ content: true }">
<el-alert :closable="false" class="info">
<template #template>
<font-awesome-icon icon="fa-solid fa-exclamation-triangle" class="mr-1" />
{{ $t('luma.name.failure') }}
</template>
<p class="description">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('luma.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</p>
</el-alert>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElImage, ElAlert, ElButton } from 'element-plus';
import { ILumaTask } from '@/models';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'TaskPreview',
components: {
ElImage,
CopyToClipboard,
FontAwesomeIcon,
ElAlert,
ElButton
},
props: {
modelValue: {
type: Object as () => ILumaTask | undefined,
required: true
}
},
data() {
return {};
},
computed: {
application() {
return this.$store.state.luma?.application;
}
},
methods: {
onOpenLink(url: string) {
window.open(url, '_blank');
},
onReload(event: Event) {
const target = event.target as HTMLImageElement;
// append a random url query to existing url query, to force reload the image
// extract exiting url query
const url = new URL(target.src);
// extract `retry` query
const retry = url.searchParams.get('retry');
if (!retry) {
// if no retry query, set it as random string
url.searchParams.set('retry', '1');
} else if (parseInt(retry) < 2) {
// if retry < 3, increase it by 1
url.searchParams.set('retry', (parseInt(retry) + 1).toString());
} else {
return;
}
// set the new url
target.src = url.toString();
},
onOpenUrl(url: string) {
window.open(url, '_blank');
},
onDownload(url: string) {
// download image using javascript
const link = document.createElement('a');
link.href = url;
link.download = url.split('/').pop() as string;
link.click();
}
}
});
</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 {
background-color: white;
padding: 2px;
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: 14px;
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);
}
}
}
.image-wrapper {
position: relative;
width: fit-content;
min-height: 50px;
min-width: 100px;
.image {
max-height: 400px;
max-width: 500px;
display: block;
width: fit-content;
}
.btn-raw {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
display: none;
}
.play-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 48px;
color: white;
z-index: 500;
pointer-events: none; /* Ensure the icon doesn't interfere with hover */
}
&:hover {
.image {
filter: brightness(0.6);
}
.btn-raw {
display: block;
}
.play-icon {
display: none;
}
}
}
}
}
</style>
<style lang="scss">
.preview {
.image.error {
background: var(--el-bg-color-page);
.image-slot {
font-size: 14px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
.failure {
background: var(--el-fill-color-light);
width: 100%;
}
}
</style>
+1
View File
@@ -5,6 +5,7 @@ export * from './chat';
export * from './chatdoc';
export * from './midjourney';
export * from './qrart';
export * from './luma';
export * from './suno';
export * from './mapping';
export * from './surface';
+4
View File
@@ -0,0 +1,4 @@
export const LUMA_SERVICE_ID = 'dff45a0d-2858-4936-8e2b-3d49c52aff11';
export const LUMA_DEFAULT_ENHANCEMENT = false;
export const LUMA_DEFAULT_LOOP = false;
+1
View File
@@ -71,6 +71,7 @@ export const loadLocaleMessages = async (i18n: I18n, locale: string) => {
'api',
'application',
'qrart',
'luma',
'suno',
'common',
'console',
+8
View File
@@ -19,6 +19,10 @@
"message": "查看原图",
"description": "按钮文本,用于查看原始图片"
},
"button.seeRawVideo": {
"message": "查看视频",
"description": "按钮文本,用于查看原始图片"
},
"button.edit": {
"message": "编辑",
"description": "按钮文本,用于编辑某些内容"
@@ -295,6 +299,10 @@
"message": "Suno",
"description": "网站导航栏中的文本,用于显示Suno页面,请不要翻译此字段,必须保持为'Suno'"
},
"nav.luma": {
"message": "Luma",
"description": "网站导航栏中的文本,用于显示Luma页面,请不要翻译此字段,必须保持为'Suno'"
},
"nav.distribution": {
"message": "推荐收益",
"description": "网站导航栏中的文本,用于显示推荐收益页面"
+4
View File
@@ -15,6 +15,10 @@
"message": "AI 音乐",
"description": "AI 音乐章节标题"
},
"title.luma": {
"message": "AI 视频",
"description": "AI 视频章节标题"
},
"title.comments": {
"message": "客户评价",
"description": "客户评价章节标题"
+482
View File
@@ -0,0 +1,482 @@
{
"name.taskId": {
"message": "任务 ID",
"description": "任务的 ID"
},
"name.type": {
"message": "类型",
"description": "要生成的 QR 码的内容类型,如'链接'、'文本'等"
},
"name.failure": {
"message": "失败",
"description": "任务的失败状态"
},
"name.failureReason": {
"message": "失败原因",
"description": "任务失败的原因"
},
"name.status": {
"message": "状态",
"description": "任务的状态"
},
"name.traceId": {
"message": "追踪 ID",
"description": "任务的追踪 ID"
},
"name.size": {
"message": "尺寸",
"description": "要生成的 QR 码的尺寸"
},
"name.createdAt": {
"message": "创建时间",
"description": "生成 QR 码的日期和时间"
},
"name.pixelStyle": {
"message": "像素风格",
"description": "要生成的 QR 码的像素风格"
},
"name.startImageUrl": {
"message": "首帧图片",
"description": "要生成的 QR 码的种子"
},
"name.endImageUrl": {
"message": "尾帧图片",
"description": "要生成的 QR 码的种子"
},
"name.paddingLevel": {
"message": "填充级别",
"description": "要生成的 QR 码的填充级别"
},
"name.paddingNoise": {
"message": "填充噪音",
"description": "要生成的 QR 码的填充噪音"
},
"name.content": {
"message": "内容",
"description": "要生成的 QR 码的内容"
},
"name.ecl": {
"message": "纠错级别",
"description": "要生成的 QR 码的纠错级别"
},
"name.position": {
"message": "位置",
"description": "要生成的 QR 码的位置"
},
"name.prompt": {
"message": "视频提示",
"description": "内容输入的提示"
},
"name.rotate": {
"message": "旋转角度",
"description": "要生成的 QR 码的旋转"
},
"name.enhancement": {
"message": "提示词增强",
"description": "要生成的 QR 码的高级设置"
},
"name.loop": {
"message": "视频循环播放",
"description": "要生成的 QR 码的高级设置"
},
"name.aspectRatio": {
"message": "宽高比",
"description": "要生成的 QR 码的宽高比"
},
"name.markerShape": {
"message": "标记形状",
"description": "要生成的 QR 码的标记形状"
},
"name.subMarker": {
"message": "子标记",
"description": "要生成的 QR 码的子标记"
},
"name.qrw": {
"message": "可见度",
"description": "QR 码生成器的名称"
},
"name.steps": {
"message": "生成步数",
"description": "生成 QR 码的步数"
},
"name.preset": {
"message": "预设风格",
"description": "要生成的 QR 码的预设"
},
"name.lumaBot": {
"message": "Luma Bot",
"description": "Luma 视频生成器的名称"
},
"name.contentImageUrl": {
"message": "内容图片链接",
"description": "要生成的 QR 码的内容图片 URL"
},
"inputWay.input": {
"message": "输入内容",
"description": "输入方式"
},
"inputWay.upload": {
"message": "上传二维码",
"description": "输入方式"
},
"description.loop": {
"message": "为生成的视频启用循环。",
"description": "参数'qrw'的描述"
},
"description.enhancement": {
"message": "如果您不确定如何书写提示文字,请启用输入提示文字的增强功能。",
"description": "参数'qrw'的描述"
},
"description.startImageUrl": {
"message": "首帧图像的 URL,它将是生成视频的第一帧。",
"description": "参数'steps'的描述"
},
"description.endImageUrl": {
"message": "尾帧图像的 URL,它将是生成视频的最后一帧。",
"description": "参数'steps'的描述"
},
"description.prompt": {
"message": "生成Luma视频的提示词",
"description": "参数'prompt'的描述"
},
"status.pending": {
"message": "等待中",
"description": "任务的等待状态"
},
"placeholder.paddingNoise": {
"message": "请选择...",
"description": "填充噪音输入的占位符"
},
"placeholder.paddingLevel": {
"message": "请选择...",
"description": "填充级别的占位符"
},
"placeholder.prompt": {
"message": "输入要生成的视频风格的提示词,例如:Astronauts shuttle from space to volcano",
"description": "提示字段中的占位文本"
},
"placeholder.startImageUrl": {
"message": "首帧图片链接",
"description": "种子输入的占位符"
},
"placeholder.endImageUrl": {
"message": "尾帧图片链接",
"description": "种子输入的占位符"
},
"placeholder.position": {
"message": "请选择...",
"description": "位置输入的占位符"
},
"placeholder.content": {
"message": "输入要生成的 QR 码的内容,例如:https://www.google.com",
"description": "内容字段中的占位文本"
},
"placeholder.aspectRatio": {
"message": "请选择...",
"description": "宽高比输入的占位符"
},
"placeholder.preset": {
"message": "请选择...",
"description": "预设输入的占位符"
},
"placeholder.markerShape": {
"message": "请选择...",
"description": "标记形状输入的占位符"
},
"placeholder.rotate": {
"message": "请选择...",
"description": "旋转输入的占位符"
},
"placeholder.subMarker": {
"message": "请选择...",
"description": "子标记输入的占位符"
},
"button.generate": {
"message": "生成",
"description": "生成Luma视频的按钮文本"
},
"button.extend": {
"message": "继续生成",
"description": "继续生成按钮文本"
},
"button.uploadQr": {
"message": "上传二维码",
"description": "上传二维码的按钮文本"
},
"preset.sunset": {
"message": "日落",
"description": "要生成的 QR 码的预设风格"
},
"preset.floral": {
"message": "花卉",
"description": "要生成的 QR 码的预设风格"
},
"preset.snowflakes": {
"message": "雪花",
"description": "要生成的 QR 码的预设风格"
},
"preset.feathers": {
"message": "羽毛",
"description": "要生成的 QR 码的预设风格"
},
"preset.raindrops": {
"message": "雨滴",
"description": "要生成的 QR 码的预设风格"
},
"preset.ultraRealism": {
"message": "超现实",
"description": "要生成的 QR 码的预设风格"
},
"preset.epicRealms": {
"message": "史诗王国",
"description": "要生成的 QR 码的预设风格"
},
"preset.intricateStudio": {
"message": "复杂工作室",
"description": "要生成的 QR 码的预设风格"
},
"preset.symmetricMasterpiece": {
"message": "对称杰作",
"description": "要生成的 QR 码的预设风格"
},
"preset.luminousHighway": {
"message": "发光之路",
"description": "要生成的 QR 码的预设风格"
},
"preset.celestialJourney": {
"message": "天体之旅",
"description": "要生成的 QR 码的预设风格"
},
"preset.neonMech": {
"message": "霓虹机械",
"description": "要生成的 QR 码的预设风格"
},
"preset.etherealLowPoly": {
"message": "空灵低多边形",
"description": "要生成的 QR 码的预设风格"
},
"preset.goldenVista": {
"message": "金色景观",
"description": "要生成的 QR 码的预设风格"
},
"preset.cinematicExpanse": {
"message": "电影般的广阔",
"description": "要生成的 QR 码的预设风格"
},
"preset.cinematicWarm": {
"message": "电影般的温暖",
"description": "要生成的 QR 码的预设风格"
},
"preset.desolateWilderness": {
"message": "荒凉荒野",
"description": "要生成的 QR 码的预设风格"
},
"preset.vibrantPalette": {
"message": "充满活力的调色板",
"description": "要生成的 QR 码的预设风格"
},
"preset.enigmaticJourney": {
"message": "神秘之旅",
"description": "要生成的 QR 码的预设风格"
},
"preset.timelessCinematic": {
"message": "永恒的电影",
"description": "要生成的 QR 码的预设风格"
},
"preset.regalGalaxy": {
"message": "华丽星系",
"description": "要生成的 QR 码的预设风格"
},
"preset.illustriousCanvas": {
"message": "杰出画布",
"description": "要生成的 QR 码的预设风格"
},
"preset.expressiveMural": {
"message": "富有表现力的壁画",
"description": "要生成的 QR 码的预设风格"
},
"preset.sereneHaze": {
"message": "宁静薄雾",
"description": "要生成的 QR 码的预设风格"
},
"message.uploadQr": {
"message": "上传二维码图片,可生成和二维码内容一致的艺术二维码",
"description": "上传二维码的说明"
},
"message.promptPlaceholder": {
"message": "请输入描述要生成的图像的句子,例如:一只可爱的猫。额外参数将覆盖默认预设参数",
"description": "提示字段中的占位文本"
},
"message.uploadReferencesExceed": {
"message": "最多可上传 5 张图片",
"description": "上传的图片数量超过限制时的错误消息"
},
"message.uploadReferencesSuccess": {
"message": "成功上传图片",
"description": "成功上传图片时的成功消息"
},
"message.uploadReferencesError": {
"message": "上传图片失败,请稍后重试",
"description": "图片上传失败时的错误消息"
},
"message.startingTask": {
"message": "正在启动任务...",
"description": "绘图任务开始时的消息"
},
"message.startTaskSuccess": {
"message": "成功发起生成任务",
"description": "成功启动任务时的成功消息"
},
"message.startTaskFailed": {
"message": "发起任务失败,请联系管理员",
"description": "启动绘图任务失败时的错误消息"
},
"message.usedUp": {
"message": "您的积分已用完,请购买更多积分后继续使用",
"description": "已用完时的消息"
},
"message.generating": {
"message": "生成中...",
"description": "图像正在生成时的消息"
},
"message.generateFailed": {
"message": "生成图像失败",
"description": "图像生成失败时的消息"
},
"message.noOperations": {
"message": "没有可用操作",
"description": "没有可用操作时的消息"
},
"message.noTasks": {
"message": "没有历史任务,请点击左方生成视频",
"description": "没有任务时的消息"
},
"markerShape.square": {
"message": "正方形",
"description": "用于生成QR码的标记形状"
},
"markerShape.circle": {
"message": "圆形",
"description": "用于生成QR码的标记形状"
},
"markerShape.plus": {
"message": "加号",
"description": "用于生成QR码的标记形状"
},
"markerShape.box": {
"message": "方框",
"description": "用于生成QR码的标记形状"
},
"markerShape.octagon": {
"message": "八边形",
"description": "用于生成QR码的标记形状"
},
"markerShape.tinyPlus": {
"message": "微加号",
"description": "用于生成QR码的标记形状"
},
"markerShape.random": {
"message": "随机",
"description": "用于生成QR码的标记形状"
},
"subMarker.square": {
"message": "正方形",
"description": "用于生成QR码的子标记形状"
},
"subMarker.circle": {
"message": "圆形",
"description": "用于生成QR码的子标记形状"
},
"subMarker.plus": {
"message": "加号",
"description": "用于生成QR码的子标记形状"
},
"subMarker.box": {
"message": "方框",
"description": "用于生成QR码的子标记形状"
},
"subMarker.random": {
"message": "随机",
"description": "用于生成QR码的子标记形状"
},
"position.center": {
"message": "中心",
"description": "用于生成QR码的位置"
},
"position.topLeft": {
"message": "左上",
"description": "用于生成QR码的位置"
},
"position.topRight": {
"message": "右上",
"description": "用于生成QR码的位置"
},
"position.bottomLeft": {
"message": "左下",
"description": "用于生成QR码的位置"
},
"position.bottomRight": {
"message": "右下",
"description": "用于生成QR码的位置"
},
"position.top": {
"message": "顶部",
"description": "用于生成QR码的位置"
},
"position.bottom": {
"message": "底部",
"description": "用于生成QR码的位置"
},
"position.left": {
"message": "左侧",
"description": "用于生成QR码的位置"
},
"position.right": {
"message": "右侧",
"description": "用于生成QR码的位置"
},
"pixelStyle.row": {
"message": "行",
"description": "用于生成QR码的像素风格"
},
"pixelStyle.column": {
"message": "列",
"description": "用于生成QR码的像素风格"
},
"pixelStyle.square": {
"message": "正方形",
"description": "用于生成QR码的像素风格"
},
"pixelStyle.rounded": {
"message": "圆角",
"description": "用于生成QR码的像素风格"
},
"pixelStyle.dot": {
"message": "点",
"description": "用于生成QR码的像素风格"
},
"pixelStyle.squircle": {
"message": "圆角矩形",
"description": "用于生成QR码的像素风格"
},
"type.text": {
"message": "文本",
"description": "用于生成QR码的内容类型"
},
"type.link": {
"message": "链接",
"description": "用于生成QR码的内容类型"
},
"type.email": {
"message": "邮件",
"description": "用于生成QR码的内容类型"
},
"type.phone": {
"message": "电话",
"description": "用于生成QR码的内容类型"
},
"type.sms": {
"message": "短信",
"description": "用于生成QR码的内容类型"
}
}
+8
View File
@@ -59,6 +59,10 @@
"message": "Qrart",
"description": "展示在编辑框的标题"
},
"field.featuresLuma": {
"message": "Luma",
"description": "展示在编辑框的标题"
},
"field.featuresSuno": {
"message": "Suno",
"description": "展示在编辑框的标题"
@@ -251,6 +255,10 @@
"message": "打开或关闭 Suno 功能模块。",
"description": "Suno 功能的描述"
},
"message.featuresLuma": {
"message": "打开或关闭 Luma 功能模块。",
"description": "Luma 功能的描述"
},
"message.featuresSupport": {
"message": "打开或关闭客服支持",
"description": "Support 功能的描述"
+80
View File
@@ -0,0 +1,80 @@
<template>
<div class="main">
<div class="config">
<slot name="config" />
</div>
<div class="result">
<slot name="result" />
</div>
<el-button round class="menu" @click="drawer = true">
<font-awesome-icon icon="fa-solid fa-gear" class="icon-menu" />
</el-button>
<el-drawer v-model="drawer" :with-header="false" size="340px" class="drawer">
<slot name="config" />
</el-drawer>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElDrawer, ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'LayoutLuma',
components: {
ElDrawer,
ElButton,
FontAwesomeIcon
},
data() {
return {
drawer: false
};
}
});
</script>
<style lang="scss" scoped>
.main {
flex: 1;
display: flex;
flex-direction: row;
.config {
width: 300px;
height: 100%;
overflow-y: scroll;
border-right: 1px solid var(--el-border-color);
}
.result {
height: 100%;
padding: 15px;
flex: 1;
width: calc(100% - 300px);
height: 100%;
display: flex;
flex-direction: column;
}
}
.menu {
display: none;
}
@media (max-width: 767px) {
.config {
display: none;
}
.result {
width: 100%;
}
.menu {
display: block;
position: fixed;
left: 15px;
top: 15px;
z-index: 2000;
}
}
</style>
+1
View File
@@ -12,6 +12,7 @@ export * from './user';
export * from './service';
export * from './credential';
export * from './qrart';
export * from './luma';
export * from './suno';
export * from './site';
export * from './exchange';
+55
View File
@@ -0,0 +1,55 @@
export interface ILumaConfig {
action?: string;
video_id?: string;
prompt?: string;
video_url?: string;
start_image_url?: string;
end_image_url?: string;
enhancement?: boolean;
loop?: boolean;
}
export interface ILumaGenerateRequest {
action?: string;
video_id?: string;
prompt?: string;
video_url?: string;
start_image_url?: string;
end_image_url?: string;
enhancement?: boolean;
loop?: boolean;
callback_url?: string;
}
export interface ILumaGenerateResponse {
success: boolean;
task_id: string;
video_id: string;
prompt: string;
video_url: string;
video_height: number;
video_width: number;
state: string;
thumbnail_url: string;
thumbnail_width: number;
thumbnail_height: number;
trace_id: string;
error: {
code?: string;
message?: string;
};
}
export interface ILumaTask {
id: string;
created_at?: string;
request?: ILumaGenerateRequest;
response?: ILumaGenerateResponse;
}
export type ILumaTaskResponse = ILumaTask;
export interface ILumaTasksResponse {
count: number;
items: ILumaTask[];
}
+1
View File
@@ -3,6 +3,7 @@ export interface ISiteFeatures {
midjourney?: any;
chatdoc?: any;
qrart?: any;
luma?: any;
suno?: any;
support?: any;
}
+1
View File
@@ -12,6 +12,7 @@ export * from './auth';
export * from './service';
export * from './credential';
export * from './qrart';
export * from './luma';
export * from './site';
export * from './suno';
export * from './exchange';
+88
View File
@@ -0,0 +1,88 @@
import axios, { AxiosResponse } from 'axios';
import { ILumaGenerateRequest, ILumaGenerateResponse, ILumaTaskResponse, ILumaTasksResponse } from '@/models';
import { BASE_URL_API } from '@/constants';
class LumaOperator {
async task(id: string, options: { token: string }): Promise<AxiosResponse<ILumaTaskResponse>> {
return await axios.post(
`/luma/tasks`,
{
action: 'retrieve',
id: id
},
{
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: `Bearer ${options.token}`,
'x-record-exempt': 'true'
},
baseURL: BASE_URL_API
}
);
}
async tasks(
filter: { ids?: string[]; applicationId?: string; userId?: string; limit?: number; offset?: number },
options: { token: string }
): Promise<AxiosResponse<ILumaTasksResponse>> {
return await axios.post(
`/luma/tasks`,
{
action: 'retrieve_batch',
...(filter.ids
? {
ids: filter.ids
}
: {}),
...(filter.applicationId
? {
application_id: filter.applicationId
}
: {}),
...(filter.userId
? {
user_id: filter.userId
}
: {}),
...(filter.limit !== undefined
? {
limit: filter.limit
}
: {}),
...(filter.offset !== undefined
? {
offset: filter.offset
}
: {})
},
{
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: `Bearer ${options.token}`,
'x-record-exempt': 'true'
},
baseURL: BASE_URL_API
}
);
}
async generate(
data: ILumaGenerateRequest,
options: {
token: string;
}
): Promise<AxiosResponse<ILumaGenerateResponse>> {
return await axios.post('/luma/videos', data, {
headers: {
authorization: `Bearer ${options.token}`,
'content-type': 'application/json',
accept: 'application/x-ndjson'
},
baseURL: BASE_URL_API
});
}
}
export const lumaOperator = new LumaOperator();
+195
View File
@@ -0,0 +1,195 @@
<template>
<layout>
<template #config>
<config-panel @generate="onGenerateVideo" />
</template>
<template #result>
<application-status
:initializing="initializing"
:application="application"
:service="service"
:need-apply="needApply"
class="mb-4"
@refresh="onGetApplication"
/>
<recent-panel class="panel recent" />
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
</template>
</layout>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Layout from '@/layouts/Luma.vue';
import ConfigPanel from '@/components/luma/ConfigPanel.vue';
import { applicationOperator, lumaOperator } from '@/operators';
import { IApplicationDetailResponse, ILumaGenerateRequest, Status } from '@/models';
import { ElMessage } from 'element-plus';
import { ERROR_CODE_DUPLICATION, ERROR_CODE_USED_UP } from '@/constants';
import ApplicationStatus from '@/components/application/Status.vue';
import RecentPanel from '@/components/luma/RecentPanel.vue';
import { ILumaTask } from '@/models';
const CALLBACK_URL = 'https://webhook.acedata.cloud/luma';
interface IData {
task: ILumaTask | undefined;
job: number;
}
export default defineComponent({
name: 'LumaIndex',
components: {
ConfigPanel,
Layout,
ApplicationStatus,
RecentPanel
},
data(): IData {
return {
task: undefined,
job: 0
};
},
computed: {
loading() {
return this.$store.state.luma?.status?.getApplication === Status.Request;
},
service() {
return this.$store.state.luma.service;
},
credential() {
return this.$store.state.luma.credential;
},
config() {
return this.$store.state.luma.config;
},
initializing() {
return this.$store.state.luma.status.getApplication === Status.Request;
},
needApply() {
return this.$store.state.luma.status.getApplication === Status.Success && !this.application;
},
application() {
return this.$store.state.luma.application;
}
},
async mounted() {
await this.onGetService();
await this.onGetApplication();
await this.onScrollDown();
await this.onGetTasks();
await this.onScrollDown();
// @ts-ignore
this.job = setInterval(() => {
this.onGetTasks();
}, 5000);
},
async unmounted() {
clearInterval(this.job);
},
methods: {
async onGetService() {
console.debug('start onGetService');
await this.$store.dispatch('luma/getService');
console.debug('end onGetService');
},
async onGetApplication() {
console.debug('start onGetApplication');
await this.$store.dispatch('luma/getApplication');
console.debug('end onGetApplication');
await this.onGetTasks();
},
onApply() {
applicationOperator
.create({
// @ts-ignore
application: this.application
})
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
this.application = data;
ElMessage.success(this.$t('application.message.applySuccessfully'));
})
.catch((error) => {
if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) {
ElMessage.error(this.$t('application.message.alreadyApplied'));
}
});
},
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.recent`
const el = document.querySelector('.recent');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
},
async onGetTasks() {
if (this.loading) {
console.debug('loading');
return;
}
await this.$store.dispatch('luma/getTasks', {
limit: 30,
offset: 0
});
},
async onGenerateVideo() {
const request = {
...this.config,
callback_url: CALLBACK_URL
} as ILumaGenerateRequest;
const token = this.credential?.token;
if (!token) {
console.error('no token specified');
return;
}
ElMessage.info(this.$t('luma.message.startingTask'));
lumaOperator
.generate(request, {
token
})
.then(() => {
ElMessage.success(this.$t('luma.message.startTaskSuccess'));
})
.catch((error) => {
const response = error?.response?.data;
if (response?.error?.code === ERROR_CODE_USED_UP) {
ElMessage.error(this.$t('luma.message.usedUp'));
} else {
ElMessage.error(this.$t('luma.message.startTaskFailed'));
}
})
.finally(async () => {
await this.onGetTasks();
await this.onScrollDown();
});
}
}
});
</script>
<style lang="scss" scoped>
.status {
margin-bottom: 10px;
}
.panel {
&.detail {
width: 100%;
flex: 1;
overflow-y: scroll;
}
&.recent {
height: 100%;
width: 100%;
margin-bottom: 10px;
position: relative;
justify-content: initial;
}
&.operation {
position: relative;
}
}
</style>
+1 -1
View File
@@ -174,7 +174,7 @@
<el-divider />
<el-form :model="site" class="form" label-width="auto" style="max-width: 600px">
<el-form-item
v-for="(feature, featureIndex) in ['chat', 'midjourney', 'qrart', 'suno', 'support']"
v-for="(feature, featureIndex) in ['chat', 'midjourney', 'qrart', 'suno', 'luma', 'support']"
:key="featureIndex"
:label="$t('site.field.features' + feature.charAt(0).toUpperCase() + feature.slice(1))"
>
+5 -2
View File
@@ -10,8 +10,9 @@ import {
} from '@fortawesome/free-regular-svg-icons';
import { faDiscord as faBrandsDiscord, faWeixin as faBrandsWeixin } from '@fortawesome/free-brands-svg-icons';
import {
faSync as faSolidSync,
faPlayCircle as faSolidPlayCircle,
faDownload as faSolidDownload,
faFilm as faSolidFilm,
faMusic as faSolidMusic,
faLanguage as faSolidLanguage,
faUser as faSolidUser,
@@ -74,7 +75,9 @@ import {
faWandMagic as faSolidWandMagic,
faAngleDown as faSolidAngleDown
} from '@fortawesome/free-solid-svg-icons';
library.add(faSolidSync);
// add icons
library.add(faSolidPlayCircle);
library.add(faSolidFilm);
library.add(faSolidMusic);
library.add(faRegularCopy);
library.add(faRegularMessage);
+3
View File
@@ -13,6 +13,9 @@ export const ROUTE_MIDJOURNEY_INDEX = 'midjourney-index';
export const ROUTE_QRART_INDEX = 'qrart-index';
export const ROUTE_QRART_HISTORY = 'qrart-history';
export const ROUTE_LUMA_INDEX = 'luma-index';
export const ROUTE_LUMA_HISTORY = 'luma-history';
export const ROUTE_CHATDOC_INDEX = 'chatdoc-index';
export const ROUTE_CHATDOC_CONVERSATION = 'chatdoc-conversation';
export const ROUTE_CHATDOC_CONVERSATION_NEW = 'chatdoc-conversation-new';
+2
View File
@@ -6,6 +6,7 @@ import midjourney from './midjourney';
import distribution from './distribution';
import chatdoc from './chatdoc';
import qrart from './qrart';
import luma from './luma';
import suno from './suno';
import site from './site';
import profile from './profile';
@@ -31,6 +32,7 @@ const routes = [
auth,
chat,
qrart,
luma,
suno,
midjourney,
distribution,
+16
View File
@@ -0,0 +1,16 @@
import { ROUTE_LUMA_INDEX } from './constants';
export default {
path: '/luma',
meta: {
auth: true
},
component: () => import('@/layouts/Main.vue'),
children: [
{
path: '',
name: ROUTE_LUMA_INDEX,
component: () => import('@/pages/luma/Index.vue')
}
]
};
+2
View File
@@ -3,6 +3,7 @@ import { IMidjourneyState } from '../midjourney/models';
import { IChatState } from '../chat/models';
import { IChatdocState } from '../chatdoc/models';
import { IQrartState } from '../qrart/models';
import { ILumaState } from '../luma/models';
import { ISunoState } from '../suno/models';
export interface ISetting {}
@@ -29,5 +30,6 @@ export interface IRootState extends ICommonState {
chat: IChatState;
chatdoc: IChatdocState;
qrart: IQrartState;
luma: ILumaState;
suno: ISunoState;
}
+2
View File
@@ -3,6 +3,7 @@ import chatState from '../chat/state';
import midjourneyState from '../midjourney/state';
import chatdocState from '../chatdoc/state';
import qrartState from '../qrart/state';
import lumaState from '../luma/state';
import sunoState from '../suno/state';
export default (): IRootState => {
@@ -25,6 +26,7 @@ export default (): IRootState => {
chat: chatState(),
midjourney: midjourneyState(),
qrart: qrartState(),
luma: lumaState(),
suno: sunoState()
};
};
+12 -1
View File
@@ -4,12 +4,14 @@ import midjourney from './midjourney';
import chat from './chat';
import chatdoc from './chatdoc';
import qrart from './qrart';
import luma from './luma';
import suno from './suno';
import root from './common';
import persistChat from './chat/persist';
import persistMidjourney from './midjourney/persist';
import persistChatdoc from './chatdoc/persist';
import persistQrart from './qrart/persist';
import persistLuma from './luma/persist';
import persistSuno from './suno/persist';
import persistRoot from './common/persist';
@@ -19,12 +21,21 @@ const store = createStore({
midjourney: midjourney,
chat: chat,
qrart: qrart,
luma: luma,
suno: suno,
chatdoc: chatdoc
},
plugins: [
createPersistedState({
paths: [...persistRoot, ...persistChat, ...persistMidjourney, ...persistChatdoc, ...persistQrart, ...persistSuno]
paths: [
...persistRoot,
...persistChat,
...persistMidjourney,
...persistChatdoc,
...persistQrart,
...persistLuma,
...persistSuno
]
})
]
});
+148
View File
@@ -0,0 +1,148 @@
import { applicationOperator, lumaOperator, serviceOperator } from '@/operators';
import { ILumaState } from './models';
import { ActionContext } from 'vuex';
import { IRootState } from '../common/models';
import { IApplication, ICredential, ILumaConfig, ILumaTask, IService, IApplicationType } from '@/models';
import { Status } from '@/models/common';
import { LUMA_SERVICE_ID } from '@/constants';
export const resetAll = ({ commit }: ActionContext<ILumaState, IRootState>): void => {
commit('resetAll');
};
export const setCredential = async ({ commit }: any, payload: ICredential): Promise<void> => {
console.debug('set credential', payload);
commit('setCredential', payload);
};
export const setConfig = ({ commit }: any, payload: ILumaConfig) => {
commit('setConfig', payload);
};
export const setService = async ({ commit }: any, payload: IService): Promise<void> => {
console.debug('set service', payload);
commit('setService', payload);
};
export const setApplication = ({ commit }: any, payload: IApplication[]) => {
commit('setApplication', payload);
};
export const getApplications = async ({
commit,
state,
rootState
}: ActionContext<ILumaState, IRootState>): Promise<IApplication[]> => {
console.debug('start to get applications for qrart');
return new Promise((resolve, reject) => {
state.status.getApplications = Status.Request;
applicationOperator
.getAll({
user_id: rootState?.user?.id,
service_id: LUMA_SERVICE_ID
})
.then((response) => {
console.debug('get applications success', response?.data);
state.status.getApplications = Status.Success;
commit('setApplications', response.data.items);
// check if there is any application with 'Period' type
const application = response.data.items?.find((application) => application?.type === IApplicationType.PERIOD);
const application2 = response.data.items?.find((application) => application?.type === IApplicationType.USAGE);
if (application && application?.remaining_amount) {
console.debug('set application with Period', application);
commit('setApplication', application);
} else if (application2) {
console.debug('set application with Usage', application2);
commit('setApplication', application2);
}
resolve(response.data.items);
console.debug('save applications success', response.data.items);
})
.catch((error) => {
console.error('get applications error', error);
state.status.getApplications = Status.Error;
reject(error);
});
});
};
export const setTasks = ({ commit }: any, payload: any) => {
commit('setTasks', payload);
};
export const setTasksItems = ({ commit }: any, payload: ILumaTask[]) => {
commit('setTasksItems', payload);
};
export const setTasksTotal = ({ commit }: any, payload: number) => {
commit('setTasksTotal', payload);
};
export const setTasksActive = ({ commit }: any, payload: ILumaTask) => {
commit('setTasksActive', payload);
};
export const getService = async ({ commit, state }: ActionContext<ILumaState, IRootState>): Promise<IService> => {
return new Promise((resolve, reject) => {
console.debug('start to get service for luma');
state.status.getService = Status.Request;
serviceOperator
.get(LUMA_SERVICE_ID)
.then((response) => {
state.status.getService = Status.Success;
commit('setService', response.data);
resolve(response.data);
})
.catch((error) => {
state.status.getService = Status.Error;
reject(error);
});
});
};
export const getTasks = async (
{ commit, state }: ActionContext<ILumaState, IRootState>,
{ offset, limit }: { offset?: number; limit?: number }
): Promise<ILumaTask[]> => {
return new Promise((resolve, reject) => {
console.debug('start to get tasks', offset, limit);
const credential = state.credential;
const token = credential?.token;
if (!token) {
return reject('no token');
}
lumaOperator
.tasks(
{
applicationId: state.application?.id
},
{
token
}
)
.then((response) => {
console.debug('get imagine tasks success', response.data.items);
commit('setTasksItems', response.data.items);
commit('setTasksTotal', response.data.count);
resolve(response.data.items);
})
.catch((error) => {
return reject(error);
});
});
};
export default {
setService,
getService,
resetAll,
setCredential,
setConfig,
setApplication,
getApplications,
setTasks,
setTasksItems,
setTasksTotal,
setTasksActive,
getTasks
};
+14
View File
@@ -0,0 +1,14 @@
import { Module } from 'vuex';
import { ILumaState } from './models';
import actions from './actions';
import mutations from './mutations';
import state from './state';
export const luma: Module<ILumaState, any> = {
namespaced: true,
state,
mutations,
actions
};
export default luma;
+21
View File
@@ -0,0 +1,21 @@
import { IApplication, ICredential, IService, Status } from '@/models';
import { ILumaConfig, ILumaTask } from '@/models';
export interface ILumaState {
application: IApplication | undefined;
service: IService | undefined;
credential: ICredential | undefined;
config: ILumaConfig | undefined;
tasks:
| {
items: ILumaTask[] | undefined;
total: number | undefined;
active: ILumaTask | undefined;
}
| undefined;
status: {
getService: Status;
getApplications: Status;
getTasks: Status;
};
}
+66
View File
@@ -0,0 +1,66 @@
import { IApplication, ICredential, ILumaConfig, ILumaTask, IService } from '@/models';
import { ILumaState } from './models';
export const resetAll = (state: ILumaState): void => {
state.service = undefined;
state.application = undefined;
state.config = undefined;
state.credential = undefined;
state.tasks = undefined;
};
export const setService = (state: ILumaState, payload: IService): void => {
state.service = payload;
};
export const setCredential = (state: ILumaState, payload: ICredential): void => {
state.credential = payload;
};
export const setApplication = (state: ILumaState, payload: IApplication): void => {
state.application = payload;
};
export const setConfig = (state: ILumaState, payload: ILumaConfig): void => {
state.config = payload;
};
export const setTasksItems = (state: ILumaState, payload: ILumaTask[]): void => {
const newPayload = {
...state.tasks,
items: payload
} as typeof state.tasks;
state.tasks = newPayload;
};
export const setTasksTotal = (state: ILumaState, payload: number): void => {
const newPayload = {
...state.tasks,
total: payload
} as typeof state.tasks;
state.tasks = newPayload;
};
export const setTasksActive = (state: ILumaState, payload: ILumaTask): void => {
const newPayload = {
...state.tasks,
active: payload
} as typeof state.tasks;
state.tasks = newPayload;
};
export const setTasks = (state: ILumaState, payload: any): void => {
state.tasks = payload;
};
export default {
setTasks,
setApplication,
setConfig,
setCredential,
setService,
setTasksActive,
setTasksItems,
setTasksTotal,
resetAll
};
+1
View File
@@ -0,0 +1 @@
export default ['luma.config', 'luma.credential', 'luma.application', 'luma.tasks'];
+17
View File
@@ -0,0 +1,17 @@
import { ILumaState } from './models';
import { Status } from '@/models';
export default (): ILumaState => {
return {
service: undefined,
application: undefined,
tasks: undefined,
credential: undefined,
config: undefined,
status: {
getService: Status.None,
getApplications: Status.None,
getTasks: Status.None
}
};
};