Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f362ba25
authored
Jul 20, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: date and warning
parent
e0b68607
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
33 deletions
+24
-33
client/src/api/app.ts
+4
-4
client/src/pages/api/app/data/totalUsage.ts
+1
-18
client/src/pages/api/openapi/plugin/vector.ts
+6
-0
client/src/pages/app/detail/components/Charts/TotalUsage.tsx
+6
-2
client/src/pages/app/detail/components/InfoModal.tsx
+3
-3
client/src/pages/app/detail/components/Settings.tsx
+2
-4
client/src/pages/number/components/BillTable.tsx
+2
-2
No files found.
client/src/api/app.ts
View file @
f362ba25
...
@@ -46,8 +46,8 @@ export const triggerModelCollection = (appId: string) =>
...
@@ -46,8 +46,8 @@ export const triggerModelCollection = (appId: string) =>
// ====================== data
// ====================== data
export
const
getAppTotalUsage
=
(
data
:
{
appId
:
string
})
=>
export
const
getAppTotalUsage
=
(
data
:
{
appId
:
string
})
=>
POST
<
{
total
:
number
;
date
:
Date
}[]
>
(
`/app/data/totalUsage`
,
{
POST
<
{
date
:
Date
;
total
:
number
}[]
>
(
`/app/data/totalUsage`
,
{
...
data
,
...
data
,
start
:
addDays
(
new
Date
(),
-
13
)
.
setHours
(
0
,
0
,
0
,
0
)
,
start
:
addDays
(
new
Date
(),
-
13
),
end
:
addDays
(
new
Date
(),
1
)
.
setHours
(
0
,
0
,
0
,
0
)
end
:
addDays
(
new
Date
(),
1
)
});
})
.
then
((
res
)
=>
(
res
.
length
===
0
?
[{
date
:
new
Date
(),
total
:
0
}]
:
res
))
;
client/src/pages/api/app/data/totalUsage.ts
View file @
f362ba25
...
@@ -3,23 +3,6 @@ import { jsonRes } from '@/service/response';
...
@@ -3,23 +3,6 @@ import { jsonRes } from '@/service/response';
import
{
connectToDatabase
,
Bill
}
from
'@/service/mongo'
;
import
{
connectToDatabase
,
Bill
}
from
'@/service/mongo'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
Types
}
from
'mongoose'
;
import
{
Types
}
from
'mongoose'
;
import
dayjs
from
'dayjs'
;
import
{
addDays
,
isSameDay
}
from
'date-fns'
;
const
fillMissingDates
=
(
start
:
number
,
end
:
number
,
data
:
{
date
:
Date
;
total
:
number
}[])
=>
{
const
result
:
{
date
:
Date
;
total
:
number
}[]
=
[];
const
dayStart
=
dayjs
(
start
);
const
dayEnd
=
dayjs
(
end
);
const
diff
=
+
dayEnd
.
diff
(
dayStart
,
'day'
);
for
(
let
i
=
0
;
i
<
diff
;
i
++
)
{
const
date
=
addDays
(
start
,
i
);
const
dataItem
=
data
.
find
((
item
)
=>
isSameDay
(
date
,
item
.
date
));
result
[
i
]
=
{
date
,
total
:
dataItem
?.
total
||
0
};
}
return
result
;
};
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
try
{
try
{
...
@@ -57,7 +40,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -57,7 +40,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
]);
]);
jsonRes
(
res
,
{
jsonRes
(
res
,
{
data
:
fillMissingDates
(
start
,
end
,
result
)
data
:
result
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
jsonRes
(
res
,
{
jsonRes
(
res
,
{
...
...
client/src/pages/api/openapi/plugin/vector.ts
View file @
f362ba25
...
@@ -42,6 +42,12 @@ export async function getVector({
...
@@ -42,6 +42,12 @@ export async function getVector({
}:
{
userId
?:
string
}
&
Props
)
{
}:
{
userId
?:
string
}
&
Props
)
{
userId
&&
(
await
authBalanceByUid
(
userId
));
userId
&&
(
await
authBalanceByUid
(
userId
));
for
(
let
i
=
0
;
i
<
input
.
length
;
i
++
)
{
if
(
!
input
[
i
])
{
return
Promise
.
reject
(
'向量生成模块输入内容为空'
);
}
}
// 获取 chatAPI
// 获取 chatAPI
const
chatAPI
=
getOpenAIApi
();
const
chatAPI
=
getOpenAIApi
();
...
...
client/src/pages/app/detail/components/Charts/TotalUsage.tsx
View file @
f362ba25
...
@@ -120,7 +120,7 @@ const TokenUsage = ({ appId }: { appId: string }) => {
...
@@ -120,7 +120,7 @@ const TokenUsage = ({ appId }: { appId: string }) => {
show
:
false
,
show
:
false
,
left
:
5
,
left
:
5
,
right
:
5
,
right
:
5
,
top
:
5
,
top
:
0
,
bottom
:
5
bottom
:
5
},
},
tooltip
:
{
tooltip
:
{
...
@@ -173,6 +173,10 @@ const TokenUsage = ({ appId }: { appId: string }) => {
...
@@ -173,6 +173,10 @@ const TokenUsage = ({ appId }: { appId: string }) => {
if (!Dom.current || myChart?.current?.getOption()) return;
if (!Dom.current || myChart?.current?.getOption()) return;
myChart.current = echarts.init(Dom.current);
myChart.current = echarts.init(Dom.current);
myChart.current && myChart.current.setOption(option);
myChart.current && myChart.current.setOption(option);
setTimeout(() => {
myChart.current?.resize();
}, 500);
}, []);
}, []);
// data changed, update
// data changed, update
...
@@ -188,7 +192,7 @@ const TokenUsage = ({ appId }: { appId: string }) => {
...
@@ -188,7 +192,7 @@ const TokenUsage = ({ appId }: { appId: string }) => {
}, [screenWidth]);
}, [screenWidth]);
return (
return (
<Box ref={Dom} w={'100%'} h={'100%'} position={'relative'}>
<Box ref={Dom} w={'100%'}
flex={'1 0 0'}
h={'100%'} position={'relative'}>
<Loading fixed={false} />
<Loading fixed={false} />
</Box>
</Box>
);
);
...
...
client/src/pages/app/detail/components/InfoModal.tsx
View file @
f362ba25
...
@@ -146,12 +146,12 @@ const InfoModal = ({
...
@@ -146,12 +146,12 @@ const InfoModal = ({
></
Input
>
></
Input
>
</
FormControl
>
</
FormControl
>
</
Flex
>
</
Flex
>
<
Box
mt=
{
6
}
mb=
{
1
}
>
<
Box
mt=
{
7
}
mb=
{
1
}
>
应用介绍
应用介绍
</
Box
>
</
Box
>
<
Box
color=
{
'myGray.500'
}
mb=
{
2
}
fontSize=
{
'sm'
}
>
{
/*
<Box color={'myGray.500'} mb={2} fontSize={'sm'}>
该介绍主要用于记忆和在应用市场展示
该介绍主要用于记忆和在应用市场展示
</
Box
>
</Box>
*/
}
<
Textarea
<
Textarea
rows=
{
4
}
rows=
{
4
}
maxLength=
{
500
}
maxLength=
{
500
}
...
...
client/src/pages/app/detail/components/Settings.tsx
View file @
f362ba25
...
@@ -132,14 +132,12 @@ const Settings = ({ appId }: { appId: string }) => {
...
@@ -132,14 +132,12 @@ const Settings = ({ appId }: { appId: string }) => {
</
Flex
>
</
Flex
>
</
Box
>
</
Box
>
</
Box
>
</
Box
>
<
Box
>
<
Flex
flexDirection=
{
'column'
}
>
<
Box
mb=
{
2
}
fontSize=
{
[
'md'
,
'xl'
]
}
>
<
Box
mb=
{
2
}
fontSize=
{
[
'md'
,
'xl'
]
}
>
近 14 日消费
近 14 日消费
</
Box
>
</
Box
>
<
Box
h=
{
'150px'
}
w=
{
'100%'
}
>
<
TotalUsage
appId=
{
appId
}
/>
<
TotalUsage
appId=
{
appId
}
/>
</
Box
>
</
Flex
>
</
Box
>
</
Grid
>
</
Grid
>
</
Box
>
</
Box
>
<
Box
flex=
{
'1 0 0'
}
position=
{
'relative'
}
>
<
Box
flex=
{
'1 0 0'
}
position=
{
'relative'
}
>
...
...
client/src/pages/number/components/BillTable.tsx
View file @
f362ba25
...
@@ -42,8 +42,8 @@ const BillTable = () => {
...
@@ -42,8 +42,8 @@ const BillTable = () => {
api
:
getUserBills
,
api
:
getUserBills
,
pageSize
:
isPc
?
20
:
10
,
pageSize
:
isPc
?
20
:
10
,
params
:
{
params
:
{
dateStart
:
new
Date
(
dateRange
.
from
||
new
Date
()).
setHours
(
0
,
0
,
0
,
0
),
dateStart
:
dateRange
.
from
||
new
Date
(
),
dateEnd
:
new
Date
(
dateRange
.
to
||
new
Date
()).
setHours
(
23
,
59
,
59
,
999
)
dateEnd
:
addDays
(
dateRange
.
to
||
new
Date
(),
1
)
}
}
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment