Add nanobanana (#270)

Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
GermeyandAceDataCloud authored and GitHub committed 2025-09-08 00:50:43 +08:00
1 parent 76f1dc562d
commit 5717b02e12
139 files changed
+4971 -1635

No files matched your search

+13 -1
View File
@@ -45,7 +45,8 @@ import {
ROUTE_PIXVERSE_INDEX,
ROUTE_PIXVERSE_HISTORY,
ROUTE_VEO_INDEX,
ROUTE_VEO_HISTORY
ROUTE_VEO_HISTORY,
ROUTE_NANOBANANA_INDEX
} from '@/router/constants';
import { CHAT_MODEL_ICON_CHATGPT, CHAT_MODEL_ICON_DEEPSEEK, CHAT_MODEL_ICON_GROK } from '@/constants/chat';
import Logo from './Logo.vue';
@@ -132,6 +133,17 @@ export default defineComponent({
routes: [ROUTE_FLUX_INDEX]
});
}
// Add nanobanana's leftmost icon
if (this.$store?.state?.site?.features?.nanobanana?.enabled) {
result.push({
route: {
name: ROUTE_NANOBANANA_INDEX
},
displayName: this.$t('common.nav.nanobanana'),
logo: 'https://cdn.acedata.cloud/859plc.jpg',
routes: [ROUTE_NANOBANANA_INDEX]
});
}
// Add qrart's leftmost icon
// if (this.$store?.state?.site?.features?.qrart?.enabled) {
// result.push({
@@ -6,17 +6,28 @@
v-model:file-list="fileList"
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
name="file"
class="value"
:show-file-list="true"
class="value upload-wrapper"
:limit="2"
:multiple="true"
list-type="picture"
:action="uploadUrl"
:on-exceed="onExceed"
:on-error="onError"
:on-success="onSuccess"
:headers="headers"
>
<el-button size="small" type="primary" round>{{ $t('headshots.button.uploadImageUrls') }}</el-button>
<template #file="{ file }">
<image-preview
:url="file.url || (file.response as any)?.file_url"
:name="file.name"
:percentage="file.percentage"
@remove="fileList.splice(fileList.indexOf(file), 1)"
/>
</template>
<el-button size="small" type="primary" round>
<font-awesome-icon icon="fa-solid fa-upload" class="mr-1" />
{{ $t('headshots.button.uploadImageUrls') }}
</el-button>
</el-upload>
</div>
<info-icon :content="$t('headshots.description.endImageUrls')" class="info" />
@@ -26,8 +37,10 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElButton, ElUpload, ElMessage, UploadFiles } 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';
export const DEFAULT_CONTENT = '';
interface IData {
@@ -40,7 +53,9 @@ export default defineComponent({
components: {
ElUpload,
ElButton,
InfoIcon
InfoIcon,
ImagePreview,
FontAwesomeIcon
},
data(): IData {
return {
@@ -116,7 +131,10 @@ export default defineComponent({
margin-left: 60px; // Adjust this value as needed
}
.upload-wrapper {
transform: translate(-26px, 5px); // Move left and down
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
.info {
margin-left: auto; // Pushes the info icon to the right
+56
View File
@@ -0,0 +1,56 @@
<template>
<div class="flex flex-col h-full">
<div class="flex-1 overflow-y-auto p-[15px]">
<action-selector class="mb-4" />
<prompt-input class="mb-4" />
<image-urls-input v-if="config?.action === 'edit'" class="mb-4" />
</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('nanobanana.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 ActionSelector from './config/ActionSelector.vue';
import PromptInput from './config/PromptInput.vue';
import ImageUrlsInput from './config/ImageUrlsInput.vue';
import Consumption from '../common/Consumption.vue';
import { getConsumption } from '@/utils';
export default defineComponent({
name: 'ConfigPanel',
components: {
ElButton,
FontAwesomeIcon,
PromptInput,
Consumption,
ActionSelector,
ImageUrlsInput
},
emits: ['generate'],
computed: {
config() {
return this.$store.state.nanobanana?.config;
},
consumption() {
return getConsumption(this.config, this.service?.metadata?.price);
},
service() {
return this.$store.state.nanobanana?.service;
}
},
methods: {
onGenerate() {
this.$emit('generate');
}
}
});
</script>
+49
View File
@@ -0,0 +1,49 @@
<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 in tasks?.items" :key="task.id" :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 '../common/BotPlaceholder.vue';
import NoTasks from '@/components/common/NoTasks.vue';
export default defineComponent({
name: 'RecentPanel',
components: {
TaskPreview,
BotPlaceholder,
NoTasks
},
emits: ['reach-top'],
data() {
return {
job: 0
};
},
computed: {
tasks() {
return {
...this.$store.state.nanobanana?.tasks,
items: this.$store.state.nanobanana?.tasks?.items?.slice()
};
}
},
methods: {
onHandleScroll() {
const el = this.$refs.panel as HTMLElement;
if (el.scrollTop === 0) {
this.$emit('reach-top');
}
}
}
});
</script>
@@ -0,0 +1,80 @@
<template>
<div class="field">
<h2 class="title font-bold">{{ $t('nanobanana.name.task') }}</h2>
<el-select v-model="value" class="value" :placeholder="$t('nanobanana.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 { NANOBANANA_DEFAULT_ACTION } from '@/constants';
export default defineComponent({
name: 'ActionSelector',
components: {
ElSelect,
ElOption
},
props: {
modelValue: {
type: String,
default: undefined
}
},
emits: ['update:modelValue'],
data() {
return {
options: [
{
value: 'generate',
label: this.$t('nanobanana.name.generate')
},
{
value: 'edit',
label: this.$t('nanobanana.name.edits')
}
]
};
},
computed: {
value: {
get() {
return this.$store.state.nanobanana?.config?.action;
},
set(val: string) {
this.$store.commit('nanobanana/setConfig', {
...this.$store.state.nanobanana.config,
action: val
});
}
}
},
mounted() {
if (!this.value) {
this.value = NANOBANANA_DEFAULT_ACTION;
}
}
});
</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: 160px;
}
}
</style>
@@ -0,0 +1,153 @@
<template>
<div class="field">
<h2 class="title font-bold">{{ $t('nanobanana.name.imageUrls') }}</h2>
<div class="upload-wrapper">
<div class="controls">
<el-upload
v-model:file-list="fileList"
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
name="file"
class="value"
:limit="5"
:multiple="true"
:show-file-list="false"
:action="uploadUrl"
:on-exceed="onExceed"
:on-error="onError"
:on-success="onSuccess"
:headers="headers"
>
<el-button size="small" type="primary" round>
<font-awesome-icon icon="fa-solid fa-upload" class="mr-1" />
{{ $t('nanobanana.button.uploadImageUrls') }}
</el-button>
</el-upload>
<info-icon :content="$t('nanobanana.description.imageUrls')" class="ml-2" />
</div>
</div>
</div>
<div class="file-list">
<image-preview
v-for="(file, idx) in fileList"
:key="idx"
:url="(file as any).url || (file as any)?.response?.file_url"
:name="(file as any).name"
:percentage="(file as any).percentage"
@remove="fileList.splice(idx, 1)"
/>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElButton, ElUpload, ElMessage, UploadFiles, UploadFile } 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: 'ImageUrlsInput',
components: {
ElUpload,
ElButton,
InfoIcon,
ImagePreview,
FontAwesomeIcon
},
data(): IData {
return {
fileList: [],
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
};
},
computed: {
headers() {
return {
Authorization: `Bearer ${this.$store.state.token.access}`
};
},
urls(): string[] {
// @ts-ignore
return this.fileList.map((file: UploadFile) => {
return file?.response?.file_url;
});
},
value: {
get() {
return this.$store.state.nanobanana?.config?.image_urls;
},
set() {
const urls = this.urls;
this.$store.commit('nanobanana/setConfig', {
...this.$store.state.nanobanana?.config,
image_urls: urls
});
}
}
},
mounted() {
if (!this.value) {
this.value = undefined;
}
this.onSetImageUrls();
},
methods: {
onExceed() {
ElMessage.warning(this.$t('nanobanana.message.uploadImageExceed'));
},
onError() {
ElMessage.error(this.$t('nanobanana.message.uploadImageError'));
},
onSetImageUrls() {
const urls = this.urls;
this.$store.commit('nanobanana/setConfig', {
...this.$store.state.nanobanana?.config,
image_urls: urls
});
},
async onSuccess() {
this.onSetImageUrls();
}
}
});
</script>
<style lang="scss" scoped>
.field {
display: flex;
align-items: flex-start;
flex-direction: row;
align-items: center;
justify-content: space-between;
.title {
font-size: 14px;
margin: 0 0 10px 0;
}
.upload-wrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
.info {
margin-left: auto;
}
}
.controls {
display: flex;
align-items: center;
}
.file-list {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
</style>
@@ -0,0 +1,74 @@
<template>
<div class="field">
<div class="box">
<h2 class="title font-bold">{{ $t('nanobanana.name.prompt') }}</h2>
<info-icon :content="$t('nanobanana.description.prompt')" class="info" />
</div>
<el-input
v-model="prompt"
:rows="3"
type="textarea"
class="prompt"
:placeholder="$t('nanobanana.placeholder.prompt')"
:maxlength="300"
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.nanobanana?.config?.prompt;
},
set(val: string) {
console.debug('set prompt', val);
this.$store.commit('nanobanana/setConfig', {
...this.$store.state.nanobanana?.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;
position: relative;
.title {
font-size: 14px;
margin-bottom: 10px;
}
}
.info {
margin-left: auto;
}
.prompt {
resize: none;
}
}
</style>
+183
View File
@@ -0,0 +1,183 @@
<template>
<div class="preview">
<div class="left">
<el-image src="https://cdn.acedata.cloud/859plc.jpg" class="avatar" />
</div>
<div class="main">
<div class="bot">
{{ $t('nanobanana.name.nanobananaBot') }}
<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('nanobanana.status.pending') }}) </span>
</p>
</div>
<div v-if="modelValue?.response?.success === true" :class="{ content: true, failed: true }">
<div class="flex justify-start items-center gap-4 w-full overflow-x-auto">
<image-wrapper
v-for="(image, imageIndex) in images"
:key="imageIndex"
:src="image?.image_url!"
:raw-src="image?.image_url!"
/>
</div>
<el-alert :closable="false" class="mt-2 success">
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('nanobanana.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy inline-block" />
</p>
</el-alert>
</div>
<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('nanobanana.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('nanobanana.name.taskId') }}:
{{ modelValue?.id }}
<copy-to-clipboard :content="modelValue?.id!" class="btn-copy" />
</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('nanobanana.name.failureReason') }}:
{{ modelValue?.response?.error?.message }}
<copy-to-clipboard :content="modelValue?.response?.error?.message!" class="btn-copy" />
</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('nanobanana.name.traceId') }}:
{{ modelValue?.response?.trace_id }}
<copy-to-clipboard :content="modelValue?.response?.trace_id" class="btn-copy" />
</p>
</el-alert>
</div>
<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('nanobanana.name.failure') }}
</template>
<p class="text-[var(--el-text-color-regular)] text-xs mb-0">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ $t('nanobanana.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 } from 'element-plus';
import { INanobananaTask, INanobananaImage } from '@/models';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ImageWrapper from '@/components/common/ImageWrapper.vue';
export default defineComponent({
name: 'TaskPreview',
components: {
ElImage,
CopyToClipboard,
FontAwesomeIcon,
ElAlert,
ImageWrapper
},
props: {
modelValue: {
type: Object as () => INanobananaTask | undefined,
required: true
}
},
computed: {
images(): INanobananaImage[] {
const result: INanobananaImage[] = [];
// @ts-ignore
if (Array.isArray(this.modelValue?.response?.data)) {
this.modelValue?.response?.data?.forEach((item: any) => {
result.push(item as INanobananaImage);
});
}
return result;
}
}
});
</script>
<style lang="scss" scoped>
$left-width: 70px;
.preview {
width: 100%;
height: fit-content;
text-align: left;
display: flex;
flex-direction: row;
margin-bottom: 10px;
.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: 15px;
}
}
.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);
}
}
}
}
}
</style>
+23 -5
View File
@@ -6,10 +6,10 @@
v-model:file-list="fileList"
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
name="file"
class="value"
:show-file-list="true"
class="value upload-wrapper"
:limit="3"
:multiple="true"
list-type="picture"
:action="uploadUrl"
:on-exceed="onExceed"
:on-error="onError"
@@ -17,7 +17,18 @@
:on-success="onSuccess"
:headers="headers"
>
<el-button size="small" type="primary" round>{{ $t('pika.button.uploadImageUrl') }}</el-button>
<template #file="{ file }">
<image-preview
:url="file.url || (file.response as any)?.file_url"
:name="file.name"
:percentage="file.percentage"
@remove="fileList.splice(fileList.indexOf(file), 1)"
/>
</template>
<el-button size="small" type="primary" round>
<font-awesome-icon icon="fa-solid fa-upload" class="mr-1" />
{{ $t('pika.button.uploadImageUrl') }}
</el-button>
</el-upload>
</div>
<info-icon :content="$t('pika.description.imageUrl')" class="info" />
@@ -27,8 +38,10 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElButton, ElUpload, ElMessage, UploadFiles } 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';
export const DEFAULT_CONTENT = '';
interface IData {
@@ -41,7 +54,9 @@ export default defineComponent({
components: {
ElUpload,
ElButton,
InfoIcon
InfoIcon,
ImagePreview,
FontAwesomeIcon
},
data(): IData {
return {
@@ -117,7 +132,10 @@ export default defineComponent({
margin-left: 60px; // Adjust this value as needed
}
.upload-wrapper {
transform: translate(-26px, 5px); // Move left and down
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
.info {
margin-left: auto; // Pushes the info icon to the right
+25 -4
View File
@@ -20,17 +20,28 @@
v-model:file-list="fileList"
accept=".png,.jpg,.jpeg,.gif,.bmp,.webp"
name="file"
class="upload"
:show-file-list="true"
class="upload upload-wrapper"
:limit="1"
:multiple="false"
list-type="picture"
:action="uploadUrl"
:on-exceed="onExceed"
:on-error="onError"
:on-success="onSuccess"
:headers="headers"
>
<el-button size="small" type="primary" round>{{ $t('qrart.button.uploadQr') }}</el-button>
<template #file="{ file }">
<image-preview
:url="file.url || (file.response as any)?.file_url"
:name="file.name"
:percentage="file.percentage"
@remove="fileList.splice(fileList.indexOf(file), 1)"
/>
</template>
<el-button size="small" type="primary" round>
<font-awesome-icon icon="fa-solid fa-upload" class="mr-1" />
{{ $t('qrart.button.uploadQr') }}
</el-button>
</el-upload>
<p v-if="inputWay == 'upload'" class="description">
{{ $t('qrart.message.uploadQr') }}
@@ -41,6 +52,8 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElInput, ElRadioGroup, ElRadioButton, ElButton, ElUpload, ElMessage, UploadFiles } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import ImagePreview from '@/components/common/ImagePreview.vue';
import { getBaseUrlPlatform } from '@/utils';
export const DEFAULT_CONTENT = '';
@@ -58,7 +71,9 @@ export default defineComponent({
ElUpload,
ElRadioGroup,
ElButton,
ElRadioButton
ElRadioButton,
ImagePreview,
FontAwesomeIcon
},
data(): IData {
return {
@@ -134,4 +149,10 @@ export default defineComponent({
color: var(--el-text-color-secondary);
}
}
.upload-wrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
</style>
+2 -1
View File
@@ -15,7 +15,8 @@
'pixverse',
'flux',
'hailuo',
'headshots'
'headshots',
'nanobanana'
]"
:key="featureIndex"
:label="$t('site.field.features' + feature.charAt(0).toUpperCase() + feature.slice(1))"