Skip to content

Commit 4b03c56

Browse files
authored
Merge pull request #190 from APIParkLab/feature/1.5-cx
feat:Feature/1.5
2 parents 567cac9 + eaecc5c commit 4b03c56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3272
-1144
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
echo "Build frontend..."
2626
cd ./frontend && pnpm run build
2727
- name: upload frontend release
28-
uses: actions/upload-artifact@v3
28+
uses: actions/upload-artifact@v4
2929
with:
3030
name: frontend-package
3131
path: frontend/dist
@@ -41,7 +41,7 @@ jobs:
4141
- name: Checkout #Checkout代码
4242
uses: actions/checkout@v3
4343
- name: download frontend release
44-
uses: actions/download-artifact@v3
44+
uses: actions/download-artifact@v4
4545
with:
4646
name: frontend-package
4747
path: frontend/dist
@@ -71,7 +71,7 @@ jobs:
7171
- uses: actions/checkout@v3
7272

7373
- name: download frontend release
74-
uses: actions/download-artifact@v3
74+
uses: actions/download-artifact@v4
7575
with:
7676
name: frontend-package
7777
path: frontend/dist

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ APIPark uses the Apache 2.0 License. For more details, please refer to the LICEN
210210
For enterprise-level features and professional technical support, contact our pre-sales experts for personalized demos, customized solutions, and pricing.
211211

212212
- Website: https://apipark.com
213-
- Email: dev@apipark.com
213+
- Email: contact@apipark.com
214214

215215
<br>
216216

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 14 additions & 0 deletions
Loading

frontend/packages/common/src/components/aoplatform/BasicLayout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ function BasicLayout({ project = 'core' }: { project: string }) {
116116
getGlobalAccessData()
117117
}, [])
118118

119+
useEffect(() => {
120+
setPathname(location.pathname)
121+
}, [location.pathname])
122+
119123
const logOut = () => {
120124
fetchData<BasicResponse<null>>('account/logout', { method: 'GET' }).then((response) => {
121125
const { code, msg } = response
@@ -182,7 +186,7 @@ function BasicLayout({ project = 'core' }: { project: string }) {
182186
</Button>,
183187
...((pluginSlotHub.getSlot('basicLayoutAfterBtns') as unknown[]) || [])
184188
]
185-
}, [pluginSlotHub.getSlot('basicLayoutAfterBtns')])
189+
}, [state.language, pluginSlotHub.getSlot('basicLayoutAfterBtns')])
186190

187191
return (
188192
<div

frontend/packages/common/src/components/postcat/api/Codebox/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ interface CodeboxProps {
2626
language?: codeBoxLanguagesType
2727
extraContent?: React.ReactNode
2828
sx?: Record<string, unknown>
29-
editorTheme?: 'vs' | 'vs-dark' | 'hc-black'
29+
editorTheme?: 'vs' | 'vs-dark' | 'hc-black',
30+
autoScrollToEnd?: boolean
3031
}
3132

3233
export const Codebox = memo((props: CodeboxProps) => {
@@ -41,7 +42,8 @@ export const Codebox = memo((props: CodeboxProps) => {
4142
readOnly = false,
4243
language = 'plaintext',
4344
extraContent,
44-
editorTheme = 'vs'
45+
editorTheme = 'vs',
46+
autoScrollToEnd = false
4547
} = props
4648

4749
const [code, setCode] = useState<string>(``)
@@ -120,6 +122,11 @@ export const Codebox = memo((props: CodeboxProps) => {
120122

121123
const editorDidMount = (editor: MonacoEditor.IStandaloneCodeEditor): void => {
122124
editorRef.current = editor
125+
autoScrollToEnd && editor.onDidChangeModelContent(() => {
126+
const model = editor.getModel()
127+
const lineCount = model.getLineCount()
128+
editor.revealLine(lineCount)
129+
})
123130
}
124131

125132
const formatCode = async (): Promise<void> => {

frontend/packages/common/src/const/permissions.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,21 @@ export const PERMISSION_DEFINITION = [
239239
anyOf: [{ backend: ['system.settings.log_configuration.manager'] }]
240240
}
241241
},
242+
'system.settings.ai_balance.view': {
243+
granted: {
244+
anyOf: [{ backend: ['system.settings.ai_balance.view'] }]
245+
}
246+
},
247+
'system.settings.ai_balance.delete': {
248+
granted: {
249+
anyOf: [{ backend: ['system.settings.ai_balance.manager'] }]
250+
}
251+
},
252+
'system.settings.ai_balance.add': {
253+
granted: {
254+
anyOf: [{ backend: ['system.settings.ai_balance.manager'] }]
255+
}
256+
},
242257
'system.devops.policy.view': {
243258
granted: {
244259
anyOf: [{ backend: ['system.settings.strategy.view'] }]

frontend/packages/common/src/const/type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export type SimpleTeamItem = {
6363
description: string
6464
appNum: number
6565
}
66+
export type LocalModelItem = {
67+
id: string
68+
isPopular: boolean
69+
name: string
70+
size: string
71+
}
6672

6773
export type MatchItem = {
6874
position: typeof MatchPositionEnum

frontend/packages/common/src/contexts/GlobalStateContext.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ const mockData = [
160160
path: '/aiApis',
161161
icon: 'ic:baseline-api',
162162
access: 'system.settings.ai_api.view'
163+
},
164+
{
165+
name: '负载均衡',
166+
key: 'loadBalancing',
167+
path: '/loadBalancing',
168+
icon: 'ph:network-x',
169+
access: 'system.settings.ai_balance.view'
163170
}
164171
]
165172
},

frontend/packages/common/src/hooks/http.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ type EoRequest = RequestInit & {
134134
eoTransformKeys?: string[]
135135
eoApiPrefix?: string
136136
eoBody?: { [k: string]: unknown } | Array<unknown> | string
137+
isStream?: boolean
138+
handleStream?: (line: any) => void
137139
}
138140

139141
type EoHeaders = Headers | { [k: string]: string }
@@ -186,14 +188,36 @@ export function useFetch() {
186188
throw new Error(`HTTP error! status: ${response.status}`)
187189
}
188190

189-
// 如果响应体为JSON且指定了转换键,则转换响应数据
190-
if (options?.eoApiPrefix||isJsonHttp(response.headers)) {
191-
const data = await response.json()
192-
const newData = (await pluginEventHub.emit('httpResponse', { data, continue: true })) as Response
193-
return shouldTransformKeys ? (keysToCamel(newData, options.eoTransformKeys as string[]) as T) : data
191+
if (options?.isStream) {
192+
const reader = response.body?.getReader()
193+
const decoder = new TextDecoder('utf-8')
194+
let buffer = ''
195+
if (reader) {
196+
while (true) {
197+
const { done, value } = await reader.read()
198+
if (done) break
199+
buffer += decoder.decode(value, { stream: true })
200+
const lines = buffer.split('\n')
201+
buffer = lines.pop() || ''
202+
for (const line of lines) {
203+
options?.handleStream?.(line)
204+
}
205+
}
206+
207+
if (buffer) {
208+
options?.handleStream?.(buffer)
209+
}
210+
}
211+
} else {
212+
// 如果响应体为JSON且指定了转换键,则转换响应数据
213+
if (options?.eoApiPrefix || isJsonHttp(response.headers)) {
214+
const data = await response.json()
215+
const newData = (await pluginEventHub.emit('httpResponse', { data, continue: true })) as Response
216+
return shouldTransformKeys ? (keysToCamel(newData, options.eoTransformKeys as string[]) as T) : data
217+
}
218+
219+
return response
194220
}
195-
196-
return response
197221
})
198222
.catch((error) => {
199223
// 全局错误处理

frontend/packages/common/src/hooks/pluginLoader.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ const mockData = {
219219
type: 'normal'
220220
}
221221
]
222+
},
223+
{
224+
driver: 'apipark.builtIn.component',
225+
name: 'loadBalancing',
226+
router: [
227+
{
228+
path: 'loadBalancing',
229+
type: 'normal'
230+
}
231+
]
222232
}
223233
// {
224234
// "driver": "apipark.remote.normal",

0 commit comments

Comments
 (0)