这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/api/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ export const getHistoryMessage= async (dataSources:Chat.Chat[],loadingCnt=1 ,sta
let fileBase64= JSON.parse(str) as string[];
let arr = fileBase64.filter( (ff:string)=>ff.indexOf('http')>-1);
if(arr.length>0) content = arr.join(' ')+' '+ content ;

mlog(t('mjchat.attr') ,o.opt.images[0] , content );
}catch(ee){
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/mj/aiGpt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ watch(()=>homeStore.myData.act, async (n)=>{
if( !canVisionModel(model) ) model= canBase64Model(model)//model='gpt-4-vision-preview';

try{
let images= await localSaveAny( JSON.stringify( dd.fileBase64) ) ;
let images= await localSaveAny( JSON.stringify({fileName: dd.fileName, fileBase64: dd.fileBase64 }) ) ;
mlog('key', images );
promptMsg.opt= {images:[images]}
}catch(e){
Expand Down
9 changes: 7 additions & 2 deletions src/views/mj/aiGptInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const chatStore = useChatStore()
const emit = defineEmits(['update:modelValue'])
const props = defineProps<{ modelValue:string,disabled?:boolean,searchOptions?:AutoCompleteOptions,renderOption?: RenderLabel }>();
const fsRef = ref()
const st = ref<{fileBase64:string[],isLoad:number,isShow:boolean,showMic:boolean,micStart:boolean}>({fileBase64:[],isLoad:0
const st = ref<{fileBase64:string[],fileName:string[],isLoad:number,isShow:boolean,showMic:boolean,micStart:boolean}>({fileBase64:[],fileName:[],isLoad:0
,isShow:false,showMic:false , micStart:false})
const { isMobile } = useBasicLayout()
const placeholder = computed(() => {
Expand All @@ -50,11 +50,13 @@ const handleSubmit = ( ) => {
}
let obj={
prompt: mvalue.value,
fileBase64:st.value.fileBase64
fileBase64:st.value.fileBase64,
fileName:st.value.fileName
}
homeStore.setMyData({act:'gpt.submit', actData:obj });
mvalue.value='';
st.value.fileBase64=[];
st.value.fileName=[];
return false;
}
const ms= useMessage();
Expand Down Expand Up @@ -102,6 +104,7 @@ funt();
return ;
}
st.value.fileBase64.push(d)
st.value.fileName.push(file.name)
} ).catch(e=>ms.error(e));
}
}else{
Expand All @@ -117,8 +120,10 @@ funt();
ms.info(t('mj.uploadSuccess'));
if(r.url.indexOf('http')>-1) {
st.value.fileBase64.push(r.url)
st.value.fileName.push(file.name)
}else{
st.value.fileBase64.push(location.origin +r.url)
st.value.fileName.push(file.name)
}
}else if(r.error) ms.error(r.error);
}).catch(e=>{
Expand Down
92 changes: 65 additions & 27 deletions src/views/mj/mjTextAttr.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,71 @@
<script lang="ts" setup>
import { localGet } from '@/api';
import { ref } from 'vue'
import {NImage} from 'naive-ui'
import { SvgIcon } from '@/components/common';
import { localGet } from "@/api";
import { ref } from "vue";
import { NImage } from "naive-ui";
import { SvgIcon } from "@/components/common";

const pp = defineProps<{ image: string }>();
const images = ref<{ fileName: string; fileBase64: string }[]>([]);
const files = ref<{ fileName: string; fileBase64: string }[]>([]);

const pp = defineProps<{image:string}>();
const images =ref([]);
const load= ()=>{
localGet(pp.image).then((r:any)=>{
//images.value= JSON.parse(r);
if(r){
// mlog('load', r);
images.value= JSON.parse(r);
}
}).catch(e=>{})
}
load();
const isImage = (url) => {
const extensions = [".jpeg", ".jpg", ".png", ".gif", ".webp"];
url = url.toLowerCase();
return extensions.some((ext) => url.endsWith(ext));
};

const loadImages = async () => {
try {
const response = await localGet(pp.image);
if (response) {
const parsedData = JSON.parse(response);
if (
Array.isArray(parsedData.fileName) &&
Array.isArray(parsedData.fileBase64)
) {
const combinedData = parsedData.fileName.map(
(name: string, index: number) => ({
fileName: name,
fileBase64: parsedData.fileBase64[index],
})
);

images.value = combinedData.filter((file) => isImage(file.fileName));
files.value = combinedData.filter((file) => !isImage(file.fileName));
}
}
} catch (error) {
console.error("Failed to load images:", error);
}
};

loadImages();
</script>

<template>
<div v-if="images.length" class="flex flex-wrap justify-start items-baseline">
<div v-for="(img,k ) of images" :key="k" class="p-1" >
<NImage :src="img" preview class=" rounded" :class="[images.length<=1?'w-[330px]':'w-[130px]']" >
<template #placeholder>
<a class="w-full h-full flex items-center justify-center text-neutral-500" :href="img" target="_blank" >
<SvgIcon icon="mdi:download" />{{$t('mjchat.attr')}} {{ k+1 }}
</a>
</template>
</NImage>
</div>
</div>
<div v-if="images.length" class="flex flex-wrap justify-start items-baseline p-1">
<div v-for="(img, k) of images" :key="k">
<NImage :src="img.fileBase64" preview class="rounded" :class="[images.length <= 1 ? 'w-[250px]' : 'w-[130px]']">
<template #placeholder>
<a class="w-full h-full flex items-center justify-center text-neutral-500" :href="img.fileBase64"
target="_blank">
<SvgIcon icon="mdi:download" />{{ img.fileName }}
</a>
</template>
</NImage>
</div>
</div>
<div v-if="files.length" class="block justify-start items-baseline p-1">
<div v-for="(file, k) of files" :key="k" :class="[
'w-full h-full block items-center text-xs text-neutral-500',
{ 'mb-1': k !== files.length - 1 },
]">
<a :href="file.fileBase64" target="_blank" class="flex items-center">
<SvgIcon icon="mdi:download" class="mr-2" />
<n-ellipsis style="max-width: 280px">
{{ file.fileName }}
</n-ellipsis>
</a>
</div>
</div>
</template>