feat: 请求增加requestid
This commit is contained in:
@ -3,6 +3,7 @@ import axios from 'axios';
|
|||||||
import { glsWithCatch } from '@/utils/stroage';
|
import { glsWithCatch } from '@/utils/stroage';
|
||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
export const BASE_PYTHON_URL = 'https://agent.lvfunai.com';
|
export const BASE_PYTHON_URL = 'https://agent.lvfunai.com';
|
||||||
|
import { genRandomId } from '@/utils/tools';
|
||||||
|
|
||||||
// 历史记录-列表
|
// 历史记录-列表
|
||||||
export const getAgentHistory = (id: string) => {
|
export const getAgentHistory = (id: string) => {
|
||||||
@ -32,10 +33,11 @@ export const getConversationList = (params: {}) => {
|
|||||||
export const getHeaders = () => {
|
export const getHeaders = () => {
|
||||||
const store = useEnterpriseStore();
|
const store = useEnterpriseStore();
|
||||||
return {
|
return {
|
||||||
'Authorization': glsWithCatch('accessToken'),
|
Authorization: glsWithCatch('accessToken'),
|
||||||
'enterprise-id': store.enterpriseInfo?.id,
|
'enterprise-id': store.enterpriseInfo?.id,
|
||||||
'Accept': 'application/json',
|
Accept: 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
requestid: genRandomId(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -132,7 +132,7 @@ const useTypedEffect = (
|
|||||||
const isTyping = computed(
|
const isTyping = computed(
|
||||||
() =>
|
() =>
|
||||||
mergedTypingEnabled.value &&
|
mergedTypingEnabled.value &&
|
||||||
unref(typingIndex) < content.value.length && // 此时 content.value 已被 mergedTypingEnabled 限定为 string
|
unref(typingIndex) < (content.value as string).length && // 此时 content.value 已被 mergedTypingEnabled 限定为 string
|
||||||
!(abortRef && abortRef.value),
|
!(abortRef && abortRef.value),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import type { EventSourceMessage } from '@microsoft/fetch-event-source';
|
|||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
import { glsWithCatch } from '@/utils/stroage';
|
import { glsWithCatch } from '@/utils/stroage';
|
||||||
import { BASE_PYTHON_URL } from '@/api/all/chat';
|
import { BASE_PYTHON_URL } from '@/api/all/chat';
|
||||||
|
import { genRandomId } from '@/utils/tools';
|
||||||
|
|
||||||
const DEFAULT_SSE_URL = `${BASE_PYTHON_URL}/api/agent/runs`;
|
const DEFAULT_SSE_URL = `${BASE_PYTHON_URL}/api/agent/runs`;
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ const SSE_HEADERS = {
|
|||||||
'Cache-Control': 'no-cache',
|
'Cache-Control': 'no-cache',
|
||||||
Connection: 'keep-alive',
|
Connection: 'keep-alive',
|
||||||
Accept: 'text/event-stream',
|
Accept: 'text/event-stream',
|
||||||
|
requestid: genRandomId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
interface SSEConfig {
|
interface SSEConfig {
|
||||||
|
|||||||
@ -108,7 +108,7 @@ export function downloadByUrl(url: string, filename?: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function genRandomId() {
|
export function genRandomId() {
|
||||||
return `id_${Date.now()}_${Math.floor(Math.random() * 10000)}`;
|
return `id_${dayjs().unix()}_${Math.floor(Math.random() * 10000)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatFileSize(bytes: number): string {
|
export function formatFileSize(bytes: number): string {
|
||||||
@ -397,7 +397,7 @@ export function getImageMainColor(imageUrl: string): Promise<string> {
|
|||||||
const avgColor = {
|
const avgColor = {
|
||||||
r: Math.round(maxGroup.sumR / maxGroup.count),
|
r: Math.round(maxGroup.sumR / maxGroup.count),
|
||||||
g: Math.round(maxGroup.sumG / maxGroup.count),
|
g: Math.round(maxGroup.sumG / maxGroup.count),
|
||||||
b: Math.round(maxGroup.sumB / maxGroup.count)
|
b: Math.round(maxGroup.sumB / maxGroup.count),
|
||||||
};
|
};
|
||||||
|
|
||||||
resolve(`rgb(${avgColor.r},${avgColor.g},${avgColor.b})`);
|
resolve(`rgb(${avgColor.r},${avgColor.g},${avgColor.b})`);
|
||||||
@ -427,28 +427,38 @@ function medianCut(data: Uint8ClampedArray, levels: number): any[] {
|
|||||||
if (a < 128) continue;
|
if (a < 128) continue;
|
||||||
|
|
||||||
colors.push({
|
colors.push({
|
||||||
r, g, b,
|
r,
|
||||||
|
g,
|
||||||
|
b,
|
||||||
count: 1,
|
count: 1,
|
||||||
sumR: r, sumG: g, sumB: b
|
sumR: r,
|
||||||
|
sumG: g,
|
||||||
|
sumB: b,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有颜色数据,返回默认白色
|
// 如果没有颜色数据,返回默认白色
|
||||||
if (colors.length === 0) {
|
if (colors.length === 0) {
|
||||||
return [{
|
return [
|
||||||
count: 1,
|
{
|
||||||
sumR: 255, sumG: 255, sumB: 255
|
count: 1,
|
||||||
}];
|
sumR: 255,
|
||||||
|
sumG: 255,
|
||||||
|
sumB: 255,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开始中位数切分
|
// 开始中位数切分
|
||||||
let colorGroups = [{
|
let colorGroups = [
|
||||||
colors,
|
{
|
||||||
count: colors.length,
|
colors,
|
||||||
sumR: colors.reduce((sum, c) => sum + c.r, 0),
|
count: colors.length,
|
||||||
sumG: colors.reduce((sum, c) => sum + c.g, 0),
|
sumR: colors.reduce((sum, c) => sum + c.r, 0),
|
||||||
sumB: colors.reduce((sum, c) => sum + c.b, 0)
|
sumG: colors.reduce((sum, c) => sum + c.g, 0),
|
||||||
}];
|
sumB: colors.reduce((sum, c) => sum + c.b, 0),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
for (let i = 0; i < levels; i++) {
|
for (let i = 0; i < levels; i++) {
|
||||||
const newGroups = [];
|
const newGroups = [];
|
||||||
@ -460,12 +470,12 @@ function medianCut(data: Uint8ClampedArray, levels: number): any[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 找出颜色范围最大的通道
|
// 找出颜色范围最大的通道
|
||||||
const rMin = Math.min(...group.colors.map(c => c.r));
|
const rMin = Math.min(...group.colors.map((c) => c.r));
|
||||||
const rMax = Math.max(...group.colors.map(c => c.r));
|
const rMax = Math.max(...group.colors.map((c) => c.r));
|
||||||
const gMin = Math.min(...group.colors.map(c => c.g));
|
const gMin = Math.min(...group.colors.map((c) => c.g));
|
||||||
const gMax = Math.max(...group.colors.map(c => c.g));
|
const gMax = Math.max(...group.colors.map((c) => c.g));
|
||||||
const bMin = Math.min(...group.colors.map(c => c.b));
|
const bMin = Math.min(...group.colors.map((c) => c.b));
|
||||||
const bMax = Math.max(...group.colors.map(c => c.b));
|
const bMax = Math.max(...group.colors.map((c) => c.b));
|
||||||
|
|
||||||
const rRange = rMax - rMin;
|
const rRange = rMax - rMin;
|
||||||
const gRange = gMax - gMin;
|
const gRange = gMax - gMin;
|
||||||
@ -500,7 +510,7 @@ function medianCut(data: Uint8ClampedArray, levels: number): any[] {
|
|||||||
count: group1.length,
|
count: group1.length,
|
||||||
sumR: group1.reduce((sum, c) => sum + c.r, 0),
|
sumR: group1.reduce((sum, c) => sum + c.r, 0),
|
||||||
sumG: group1.reduce((sum, c) => sum + c.g, 0),
|
sumG: group1.reduce((sum, c) => sum + c.g, 0),
|
||||||
sumB: group1.reduce((sum, c) => sum + c.b, 0)
|
sumB: group1.reduce((sum, c) => sum + c.b, 0),
|
||||||
});
|
});
|
||||||
|
|
||||||
newGroups.push({
|
newGroups.push({
|
||||||
@ -508,7 +518,7 @@ function medianCut(data: Uint8ClampedArray, levels: number): any[] {
|
|||||||
count: group2.length,
|
count: group2.length,
|
||||||
sumR: group2.reduce((sum, c) => sum + c.r, 0),
|
sumR: group2.reduce((sum, c) => sum + c.r, 0),
|
||||||
sumG: group2.reduce((sum, c) => sum + c.g, 0),
|
sumG: group2.reduce((sum, c) => sum + c.g, 0),
|
||||||
sumB: group2.reduce((sum, c) => sum + c.b, 0)
|
sumB: group2.reduce((sum, c) => sum + c.b, 0),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user