生成 API
改进 登录
This commit is contained in:
parent
4bcc4850dc
commit
c6483d45d6
24
.gitignore
vendored
24
.gitignore
vendored
@ -1,22 +1,4 @@
|
|||||||
.DS_Store
|
wwwroot/*.js
|
||||||
node_modules
|
node_modules
|
||||||
/dist
|
typings
|
||||||
|
dist
|
||||||
# local env files
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Log files
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
|
|
||||||
# Editor directories and files
|
|
||||||
.idea
|
|
||||||
.vscode
|
|
||||||
*.suo
|
|
||||||
*.ntvs*
|
|
||||||
*.njsproj
|
|
||||||
*.sln
|
|
||||||
*.sw?
|
|
||||||
|
749
api/swagger.yaml
Normal file
749
api/swagger.yaml
Normal file
@ -0,0 +1,749 @@
|
|||||||
|
definitions:
|
||||||
|
rag-new_internal_entity.Assistant:
|
||||||
|
properties:
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
prompt:
|
||||||
|
type: string
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
rag-new_internal_entity.AssistantTool:
|
||||||
|
properties:
|
||||||
|
assistant_id:
|
||||||
|
type: integer
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
tool_id:
|
||||||
|
type: integer
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
rag-new_internal_entity.Chat:
|
||||||
|
properties:
|
||||||
|
assistant_id:
|
||||||
|
type: integer
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
rag-new_internal_entity.ChatMessage:
|
||||||
|
properties:
|
||||||
|
assistant_id:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
type: string
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
input_tokens:
|
||||||
|
type: integer
|
||||||
|
output_tokens:
|
||||||
|
type: integer
|
||||||
|
role:
|
||||||
|
type: string
|
||||||
|
total_tokens:
|
||||||
|
type: integer
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
rag-new_internal_entity.Tool:
|
||||||
|
properties:
|
||||||
|
api_key:
|
||||||
|
type: string
|
||||||
|
created_at:
|
||||||
|
type: string
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutput'
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
discovery_url:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
updated_at:
|
||||||
|
type: string
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.AssistantCreateRequest:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
prompt:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- description
|
||||||
|
- name
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ChatCreateRequest:
|
||||||
|
properties:
|
||||||
|
assistant_id:
|
||||||
|
type: integer
|
||||||
|
name:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- assistant_id
|
||||||
|
- name
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ChatMessageAddRequest:
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- message
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ChatMessageResponse:
|
||||||
|
properties:
|
||||||
|
stream_id:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.CurrentUserResponse:
|
||||||
|
properties:
|
||||||
|
ip:
|
||||||
|
type: string
|
||||||
|
userEmail:
|
||||||
|
type: string
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
valid:
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ResponseBody:
|
||||||
|
properties:
|
||||||
|
data: {}
|
||||||
|
error:
|
||||||
|
type: string
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
success:
|
||||||
|
type: boolean
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ToolCreateRequest:
|
||||||
|
properties:
|
||||||
|
api_key:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
url:
|
||||||
|
maxLength: 255
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- description
|
||||||
|
- name
|
||||||
|
- url
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ToolDiscoveryOutput:
|
||||||
|
properties:
|
||||||
|
callback_url:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
function:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctions'
|
||||||
|
type: array
|
||||||
|
homepage_url:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ToolDiscoveryOutputFunction:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
parameters: {}
|
||||||
|
required:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
rag-new_internal_schema.ToolDiscoveryOutputFunctions:
|
||||||
|
properties:
|
||||||
|
function:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction'
|
||||||
|
type: array
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
info:
|
||||||
|
contact: {}
|
||||||
|
title: Leaflow Amber
|
||||||
|
version: "1.0"
|
||||||
|
paths:
|
||||||
|
/api/v1/assistants:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.Assistant'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 获取 Assistant 列表
|
||||||
|
tags:
|
||||||
|
- assistant
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Assistant
|
||||||
|
in: body
|
||||||
|
name: assistant
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.AssistantCreateRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.Assistant'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 创建 Assistant
|
||||||
|
tags:
|
||||||
|
- assistant
|
||||||
|
/api/v1/assistants/{id}/tools:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Assistant ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.AssistantTool'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 获取 Assistant 所绑定的 Tool
|
||||||
|
tags:
|
||||||
|
- assistant
|
||||||
|
/api/v1/assistants/{id}/tools/{tool_id}:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Assistant ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: Tool ID
|
||||||
|
in: path
|
||||||
|
name: tool_id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.AssistantTool'
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 解绑 Tool
|
||||||
|
tags:
|
||||||
|
- assistant
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Assistant ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: Tool ID
|
||||||
|
in: path
|
||||||
|
name: tool_id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.AssistantTool'
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 绑定 Tool
|
||||||
|
tags:
|
||||||
|
- assistant
|
||||||
|
/api/v1/chats:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.Chat'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 获取所有 Chat
|
||||||
|
tags:
|
||||||
|
- chat
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Chat
|
||||||
|
in: body
|
||||||
|
name: chat
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ChatCreateRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.Chat'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: Create Chat
|
||||||
|
tags:
|
||||||
|
- chat
|
||||||
|
/api/v1/chats/{id}:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Chat ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: Delete Chat
|
||||||
|
tags:
|
||||||
|
- chat
|
||||||
|
/api/v1/chats/{id}/messages:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Chat ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.ChatMessage'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 查看聊天记录
|
||||||
|
tags:
|
||||||
|
- chat_message
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Chat ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: Message
|
||||||
|
in: body
|
||||||
|
name: message
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ChatMessageAddRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"409":
|
||||||
|
description: Conflict
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: 添加聊天记录
|
||||||
|
tags:
|
||||||
|
- chat_message
|
||||||
|
/api/v1/ping:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.CurrentUserResponse'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: Greet
|
||||||
|
tags:
|
||||||
|
- ping
|
||||||
|
/api/v1/stream/{stream_id}:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: get string by ID
|
||||||
|
parameters:
|
||||||
|
- description: Chat ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: Chat stream id
|
||||||
|
in: path
|
||||||
|
name: stream_id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"409":
|
||||||
|
description: Conflict
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
security:
|
||||||
|
- none: []
|
||||||
|
summary: 流式传输聊天内容
|
||||||
|
tags:
|
||||||
|
- chat_message
|
||||||
|
/api/v1/tools:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: List tools
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.CurrentUserResponse'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: List Tool
|
||||||
|
tags:
|
||||||
|
- tool
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Create tool
|
||||||
|
parameters:
|
||||||
|
- description: Tool
|
||||||
|
in: body
|
||||||
|
name: tool
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ToolCreateRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.Tool'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: Create Tool
|
||||||
|
tags:
|
||||||
|
- tool
|
||||||
|
/api/v1/tools/{id}:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: DeleteTool
|
||||||
|
parameters:
|
||||||
|
- description: Tool ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: DeleteTool
|
||||||
|
tags:
|
||||||
|
- tool
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Get tool
|
||||||
|
parameters:
|
||||||
|
- description: Tool ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/rag-new_internal_entity.Tool'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/rag-new_internal_schema.ResponseBody'
|
||||||
|
summary: Get Tool
|
||||||
|
tags:
|
||||||
|
- tool
|
||||||
|
securityDefinitions:
|
||||||
|
ApiKeyAuth:
|
||||||
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
type: apiKey
|
||||||
|
swagger: "2.0"
|
7
openapitools.json
Normal file
7
openapitools.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
||||||
|
"spaces": 2,
|
||||||
|
"generator-cli": {
|
||||||
|
"version": "7.7.0"
|
||||||
|
}
|
||||||
|
}
|
@ -5,13 +5,15 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"lint": "eslint . --fix --ignore-path .gitignore"
|
"lint": "eslint . --fix --ignore-path .gitignore",
|
||||||
|
"gen": "openapi-generator-cli generate -i ./api/swagger.yaml -g typescript-axios -o ./src/api"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "7.4.47",
|
"@mdi/font": "7.4.47",
|
||||||
"axios": "^1.7.2",
|
"axios": "^1.7.2",
|
||||||
"core-js": "^3.37.1",
|
"core-js": "^3.37.1",
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
|
"pinia-plugin-persistedstate": "^3.2.1",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
"vue": "^3.4.31",
|
"vue": "^3.4.31",
|
||||||
"vuetify": "^3.6.11"
|
"vuetify": "^3.6.11"
|
||||||
|
4
src/api/.gitignore
vendored
Normal file
4
src/api/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
wwwroot/*.js
|
||||||
|
node_modules
|
||||||
|
typings
|
||||||
|
dist
|
1
src/api/.npmignore
Normal file
1
src/api/.npmignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
23
src/api/.openapi-generator-ignore
Normal file
23
src/api/.openapi-generator-ignore
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
8
src/api/.openapi-generator/FILES
Normal file
8
src/api/.openapi-generator/FILES
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.gitignore
|
||||||
|
.npmignore
|
||||||
|
api.ts
|
||||||
|
base.ts
|
||||||
|
common.ts
|
||||||
|
configuration.ts
|
||||||
|
git_push.sh
|
||||||
|
index.ts
|
1
src/api/.openapi-generator/VERSION
Normal file
1
src/api/.openapi-generator/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
7.7.0
|
2175
src/api/api.ts
Normal file
2175
src/api/api.ts
Normal file
File diff suppressed because it is too large
Load Diff
86
src/api/base.ts
Normal file
86
src/api/base.ts
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Leaflow Amber
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import type { Configuration } from './configuration';
|
||||||
|
// Some imports not used depending on template conditions
|
||||||
|
// @ts-ignore
|
||||||
|
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
||||||
|
import globalAxios from 'axios';
|
||||||
|
|
||||||
|
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
csv: ",",
|
||||||
|
ssv: " ",
|
||||||
|
tsv: "\t",
|
||||||
|
pipes: "|",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface RequestArgs
|
||||||
|
*/
|
||||||
|
export interface RequestArgs {
|
||||||
|
url: string;
|
||||||
|
options: RawAxiosRequestConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class BaseAPI
|
||||||
|
*/
|
||||||
|
export class BaseAPI {
|
||||||
|
protected configuration: Configuration | undefined;
|
||||||
|
|
||||||
|
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
||||||
|
if (configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.basePath = configuration.basePath ?? basePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class RequiredError
|
||||||
|
* @extends {Error}
|
||||||
|
*/
|
||||||
|
export class RequiredError extends Error {
|
||||||
|
constructor(public field: string, msg?: string) {
|
||||||
|
super(msg);
|
||||||
|
this.name = "RequiredError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ServerMap {
|
||||||
|
[key: string]: {
|
||||||
|
url: string,
|
||||||
|
description: string,
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const operationServerMap: ServerMap = {
|
||||||
|
}
|
150
src/api/common.ts
Normal file
150
src/api/common.ts
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Leaflow Amber
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import type { Configuration } from "./configuration";
|
||||||
|
import type { RequestArgs } from "./base";
|
||||||
|
import type { AxiosInstance, AxiosResponse } from 'axios';
|
||||||
|
import { RequiredError } from "./base";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const DUMMY_BASE_URL = 'https://example.com'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
||||||
|
if (paramValue === null || paramValue === undefined) {
|
||||||
|
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
||||||
|
if (configuration && configuration.apiKey) {
|
||||||
|
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||||
|
? await configuration.apiKey(keyParamName)
|
||||||
|
: await configuration.apiKey;
|
||||||
|
object[keyParamName] = localVarApiKeyValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
|
||||||
|
if (configuration && (configuration.username || configuration.password)) {
|
||||||
|
object["auth"] = { username: configuration.username, password: configuration.password };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const accessToken = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken()
|
||||||
|
: await configuration.accessToken;
|
||||||
|
object["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken(name, scopes)
|
||||||
|
: await configuration.accessToken;
|
||||||
|
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
||||||
|
if (parameter == null) return;
|
||||||
|
if (typeof parameter === "object") {
|
||||||
|
if (Array.isArray(parameter)) {
|
||||||
|
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Object.keys(parameter).forEach(currentKey =>
|
||||||
|
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (urlSearchParams.has(key)) {
|
||||||
|
urlSearchParams.append(key, parameter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
urlSearchParams.set(key, parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
||||||
|
const searchParams = new URLSearchParams(url.search);
|
||||||
|
setFlattenedQueryParams(searchParams, objects);
|
||||||
|
url.search = searchParams.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
||||||
|
const nonString = typeof value !== 'string';
|
||||||
|
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
||||||
|
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
||||||
|
: nonString;
|
||||||
|
return needsSerialization
|
||||||
|
? JSON.stringify(value !== undefined ? value : {})
|
||||||
|
: (value || "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const toPathString = function (url: URL) {
|
||||||
|
return url.pathname + url.search + url.hash
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
||||||
|
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
|
||||||
|
return axios.request<T, R>(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
}
|
110
src/api/configuration.ts
Normal file
110
src/api/configuration.ts
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Leaflow Amber
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export interface ConfigurationParameters {
|
||||||
|
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||||
|
username?: string;
|
||||||
|
password?: string;
|
||||||
|
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
||||||
|
basePath?: string;
|
||||||
|
serverIndex?: number;
|
||||||
|
baseOptions?: any;
|
||||||
|
formDataCtor?: new () => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Configuration {
|
||||||
|
/**
|
||||||
|
* parameter for apiKey security
|
||||||
|
* @param name security name
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||||
|
/**
|
||||||
|
* parameter for basic security
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
username?: string;
|
||||||
|
/**
|
||||||
|
* parameter for basic security
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
password?: string;
|
||||||
|
/**
|
||||||
|
* parameter for oauth2 security
|
||||||
|
* @param name security name
|
||||||
|
* @param scopes oauth2 scope
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
||||||
|
/**
|
||||||
|
* override base path
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
basePath?: string;
|
||||||
|
/**
|
||||||
|
* override server index
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
serverIndex?: number;
|
||||||
|
/**
|
||||||
|
* base options for axios calls
|
||||||
|
*
|
||||||
|
* @type {any}
|
||||||
|
* @memberof Configuration
|
||||||
|
*/
|
||||||
|
baseOptions?: any;
|
||||||
|
/**
|
||||||
|
* The FormData constructor that will be used to create multipart form data
|
||||||
|
* requests. You can inject this here so that execution environments that
|
||||||
|
* do not support the FormData class can still run the generated client.
|
||||||
|
*
|
||||||
|
* @type {new () => FormData}
|
||||||
|
*/
|
||||||
|
formDataCtor?: new () => any;
|
||||||
|
|
||||||
|
constructor(param: ConfigurationParameters = {}) {
|
||||||
|
this.apiKey = param.apiKey;
|
||||||
|
this.username = param.username;
|
||||||
|
this.password = param.password;
|
||||||
|
this.accessToken = param.accessToken;
|
||||||
|
this.basePath = param.basePath;
|
||||||
|
this.serverIndex = param.serverIndex;
|
||||||
|
this.baseOptions = param.baseOptions;
|
||||||
|
this.formDataCtor = param.formDataCtor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given MIME is a JSON MIME.
|
||||||
|
* JSON MIME examples:
|
||||||
|
* application/json
|
||||||
|
* application/json; charset=UTF8
|
||||||
|
* APPLICATION/JSON
|
||||||
|
* application/vnd.company+json
|
||||||
|
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||||
|
* @return True if the given MIME is JSON, false otherwise.
|
||||||
|
*/
|
||||||
|
public isJsonMime(mime: string): boolean {
|
||||||
|
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||||
|
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||||
|
}
|
||||||
|
}
|
57
src/api/git_push.sh
Normal file
57
src/api/git_push.sh
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
git_host=$4
|
||||||
|
|
||||||
|
if [ "$git_host" = "" ]; then
|
||||||
|
git_host="github.com"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=$(git remote)
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
|
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
18
src/api/index.ts
Normal file
18
src/api/index.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Leaflow Amber
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export * from "./api";
|
||||||
|
export * from "./configuration";
|
||||||
|
|
3
src/components.d.ts
vendored
3
src/components.d.ts
vendored
@ -7,9 +7,12 @@ export {}
|
|||||||
/* prettier-ignore */
|
/* prettier-ignore */
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
AppBar: typeof import('./components/AppBar.vue')['default']
|
||||||
AppFooter: typeof import('./components/AppFooter.vue')['default']
|
AppFooter: typeof import('./components/AppFooter.vue')['default']
|
||||||
|
copy: typeof import('./components/default copy.vue')['default']
|
||||||
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
|
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
|
View: typeof import('./components/View.vue')['default']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,31 +5,23 @@
|
|||||||
<v-btn-group rounded="lg">
|
<v-btn-group rounded="lg">
|
||||||
<v-btn density="default" icon="mdi-close" @click="drawer = !drawer" />
|
<v-btn density="default" icon="mdi-close" @click="drawer = !drawer" />
|
||||||
|
|
||||||
<v-btn density="default" icon="mdi-plus" title="创建资料库" @click="to('libraries.create')" />
|
<v-btn
|
||||||
|
density="default"
|
||||||
|
icon="mdi-plus"
|
||||||
|
title="创建资料库"
|
||||||
|
/>
|
||||||
</v-btn-group>
|
</v-btn-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <v-divider></v-divider> -->
|
<!-- <v-divider></v-divider> -->
|
||||||
|
|
||||||
<v-list density="compact" nav>
|
<v-list density="compact" nav>
|
||||||
<!-- <template v-for="item in items">
|
|
||||||
<v-list-item
|
|
||||||
rounded="lg"
|
|
||||||
:prepend-icon="item.icon"
|
|
||||||
:title="item.text"
|
|
||||||
:value="item.text"
|
|
||||||
:to="item.to"
|
|
||||||
:on-click="item?.click"
|
|
||||||
></v-list-item>
|
|
||||||
</template> -->
|
|
||||||
|
|
||||||
<v-list-item
|
<v-list-item
|
||||||
prepend-icon="mdi-home"
|
prepend-icon="mdi-home"
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
title="首页"
|
title="首页"
|
||||||
:to="{
|
to="/"
|
||||||
name: 'home',
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@ -37,9 +29,7 @@
|
|||||||
prepend-icon="mdi-account"
|
prepend-icon="mdi-account"
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
title="登录"
|
title="登录"
|
||||||
:to="{
|
to="/auth/login"
|
||||||
name: 'login',
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <v-list-item
|
<!-- <v-list-item
|
||||||
@ -67,7 +57,16 @@
|
|||||||
<v-app-bar>
|
<v-app-bar>
|
||||||
<v-app-bar-nav-icon @click="drawer = !drawer" />
|
<v-app-bar-nav-icon @click="drawer = !drawer" />
|
||||||
|
|
||||||
<v-app-bar-title>{{ configStore.appName }}</v-app-bar-title>
|
<v-app-bar-title>{{ configStore.app_name }}</v-app-bar-title>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
<!-- </v-app> -->
|
<!-- </v-app> -->
|
||||||
</template>
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { useConfigStore } from "@/stores/config";
|
||||||
|
|
||||||
|
const configStore = useConfigStore();
|
||||||
|
|
||||||
|
const drawer = ref(false);
|
||||||
|
const logined = ref(false);
|
||||||
|
</script>
|
@ -1,79 +0,0 @@
|
|||||||
<template>
|
|
||||||
<v-footer app height="40">
|
|
||||||
<a
|
|
||||||
v-for="item in items"
|
|
||||||
:key="item.title"
|
|
||||||
class="d-inline-block mx-2 social-link"
|
|
||||||
:href="item.href"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
target="_blank"
|
|
||||||
:title="item.title"
|
|
||||||
>
|
|
||||||
<v-icon
|
|
||||||
:icon="item.icon"
|
|
||||||
:size="item.icon === '$vuetify' ? 24 : 16"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="text-caption text-disabled"
|
|
||||||
style="position: absolute; right: 16px;"
|
|
||||||
>
|
|
||||||
© 2016-{{ (new Date()).getFullYear() }} <span class="d-none d-sm-inline-block">Vuetify, LLC</span>
|
|
||||||
—
|
|
||||||
<a
|
|
||||||
class="text-decoration-none on-surface"
|
|
||||||
href="https://vuetifyjs.com/about/licensing/"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
MIT License
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</v-footer>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
const items = [
|
|
||||||
{
|
|
||||||
title: 'Vuetify Documentation',
|
|
||||||
icon: `$vuetify`,
|
|
||||||
href: 'https://vuetifyjs.com/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Vuetify Support',
|
|
||||||
icon: 'mdi-shield-star-outline',
|
|
||||||
href: 'https://support.vuetifyjs.com/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Vuetify X',
|
|
||||||
icon: ['M2.04875 3.00002L9.77052 13.3248L1.99998 21.7192H3.74882L10.5519 14.3697L16.0486 21.7192H22L13.8437 10.8137L21.0765 3.00002H19.3277L13.0624 9.76874L8.0001 3.00002H2.04875ZM4.62054 4.28821H7.35461L19.4278 20.4308H16.6937L4.62054 4.28821Z'],
|
|
||||||
href: 'https://x.com/vuetifyjs',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Vuetify GitHub',
|
|
||||||
icon: `mdi-github`,
|
|
||||||
href: 'https://github.com/vuetifyjs/vuetify',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Vuetify Discord',
|
|
||||||
icon: ['M22,24L16.75,19L17.38,21H4.5A2.5,2.5 0 0,1 2,18.5V3.5A2.5,2.5 0 0,1 4.5,1H19.5A2.5,2.5 0 0,1 22,3.5V24M12,6.8C9.32,6.8 7.44,7.95 7.44,7.95C8.47,7.03 10.27,6.5 10.27,6.5L10.1,6.33C8.41,6.36 6.88,7.53 6.88,7.53C5.16,11.12 5.27,14.22 5.27,14.22C6.67,16.03 8.75,15.9 8.75,15.9L9.46,15C8.21,14.73 7.42,13.62 7.42,13.62C7.42,13.62 9.3,14.9 12,14.9C14.7,14.9 16.58,13.62 16.58,13.62C16.58,13.62 15.79,14.73 14.54,15L15.25,15.9C15.25,15.9 17.33,16.03 18.73,14.22C18.73,14.22 18.84,11.12 17.12,7.53C17.12,7.53 15.59,6.36 13.9,6.33L13.73,6.5C13.73,6.5 15.53,7.03 16.56,7.95C16.56,7.95 14.68,6.8 12,6.8M9.93,10.59C10.58,10.59 11.11,11.16 11.1,11.86C11.1,12.55 10.58,13.13 9.93,13.13C9.29,13.13 8.77,12.55 8.77,11.86C8.77,11.16 9.28,10.59 9.93,10.59M14.1,10.59C14.75,10.59 15.27,11.16 15.27,11.86C15.27,12.55 14.75,13.13 14.1,13.13C13.46,13.13 12.94,12.55 12.94,11.86C12.94,11.16 13.45,10.59 14.1,10.59Z'],
|
|
||||||
href: 'https://community.vuetifyjs.com/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Vuetify Reddit',
|
|
||||||
icon: `mdi-reddit`,
|
|
||||||
href: 'https://reddit.com/r/vuetifyjs',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="sass">
|
|
||||||
.social-link :deep(.v-icon)
|
|
||||||
color: rgba(var(--v-theme-on-background), var(--v-disabled-opacity))
|
|
||||||
text-decoration: none
|
|
||||||
transition: .2s ease-in-out
|
|
||||||
|
|
||||||
&:hover
|
|
||||||
color: rgba(25, 118, 210, 1)
|
|
||||||
</style>
|
|
@ -1,157 +0,0 @@
|
|||||||
<template>
|
|
||||||
<v-container class="fill-height">
|
|
||||||
<v-responsive
|
|
||||||
class="align-centerfill-height mx-auto"
|
|
||||||
max-width="900"
|
|
||||||
>
|
|
||||||
<v-img
|
|
||||||
class="mb-4"
|
|
||||||
height="150"
|
|
||||||
src="@/assets/logo.png"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="text-center">
|
|
||||||
<div class="text-body-2 font-weight-light mb-n1">Welcome to</div>
|
|
||||||
|
|
||||||
<h1 class="text-h2 font-weight-bold">Vuetify</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="py-4" />
|
|
||||||
|
|
||||||
<v-row>
|
|
||||||
<v-col cols="12">
|
|
||||||
<v-card
|
|
||||||
class="py-4"
|
|
||||||
color="surface-variant"
|
|
||||||
image="https://cdn.vuetifyjs.com/docs/images/one/create/feature.png"
|
|
||||||
prepend-icon="mdi-rocket-launch-outline"
|
|
||||||
rounded="lg"
|
|
||||||
variant="outlined"
|
|
||||||
>
|
|
||||||
<template #image>
|
|
||||||
<v-img position="top right" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #title>
|
|
||||||
<h2 class="text-h5 font-weight-bold">Get started</h2>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #subtitle>
|
|
||||||
<div class="text-subtitle-1">
|
|
||||||
Replace this page by removing <v-kbd>{{ `<HelloWorld />` }}</v-kbd> in <v-kbd>pages/index.vue</v-kbd>.
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<v-overlay
|
|
||||||
contained
|
|
||||||
model-value
|
|
||||||
opacity=".12"
|
|
||||||
persistent
|
|
||||||
scrim="primary"
|
|
||||||
/>
|
|
||||||
</v-card>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="6">
|
|
||||||
<v-card
|
|
||||||
append-icon="mdi-open-in-new"
|
|
||||||
class="py-4"
|
|
||||||
color="surface-variant"
|
|
||||||
href="https://vuetifyjs.com/"
|
|
||||||
prepend-icon="mdi-text-box-outline"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
rounded="lg"
|
|
||||||
subtitle="Learn about all things Vuetify in our documentation."
|
|
||||||
target="_blank"
|
|
||||||
title="Documentation"
|
|
||||||
variant="text"
|
|
||||||
>
|
|
||||||
<v-overlay
|
|
||||||
contained
|
|
||||||
model-value
|
|
||||||
opacity=".06"
|
|
||||||
persistent
|
|
||||||
scrim="primary"
|
|
||||||
/>
|
|
||||||
</v-card>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="6">
|
|
||||||
<v-card
|
|
||||||
append-icon="mdi-open-in-new"
|
|
||||||
class="py-4"
|
|
||||||
color="surface-variant"
|
|
||||||
href="https://vuetifyjs.com/introduction/why-vuetify/#feature-guides"
|
|
||||||
prepend-icon="mdi-star-circle-outline"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
rounded="lg"
|
|
||||||
subtitle="Explore available framework Features."
|
|
||||||
target="_blank"
|
|
||||||
title="Features"
|
|
||||||
variant="text"
|
|
||||||
>
|
|
||||||
<v-overlay
|
|
||||||
contained
|
|
||||||
model-value
|
|
||||||
opacity=".06"
|
|
||||||
persistent
|
|
||||||
scrim="primary"
|
|
||||||
/>
|
|
||||||
</v-card>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="6">
|
|
||||||
<v-card
|
|
||||||
append-icon="mdi-open-in-new"
|
|
||||||
class="py-4"
|
|
||||||
color="surface-variant"
|
|
||||||
href="https://vuetifyjs.com/components/all"
|
|
||||||
prepend-icon="mdi-widgets-outline"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
rounded="lg"
|
|
||||||
subtitle="Discover components in the API Explorer."
|
|
||||||
target="_blank"
|
|
||||||
title="Components"
|
|
||||||
variant="text"
|
|
||||||
>
|
|
||||||
<v-overlay
|
|
||||||
contained
|
|
||||||
model-value
|
|
||||||
opacity=".06"
|
|
||||||
persistent
|
|
||||||
scrim="primary"
|
|
||||||
/>
|
|
||||||
</v-card>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="6">
|
|
||||||
<v-card
|
|
||||||
append-icon="mdi-open-in-new"
|
|
||||||
class="py-4"
|
|
||||||
color="surface-variant"
|
|
||||||
href="https://discord.vuetifyjs.com"
|
|
||||||
prepend-icon="mdi-account-group-outline"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
rounded="lg"
|
|
||||||
subtitle="Connect with Vuetify developers."
|
|
||||||
target="_blank"
|
|
||||||
title="Community"
|
|
||||||
variant="text"
|
|
||||||
>
|
|
||||||
<v-overlay
|
|
||||||
contained
|
|
||||||
model-value
|
|
||||||
opacity=".06"
|
|
||||||
persistent
|
|
||||||
scrim="primary"
|
|
||||||
/>
|
|
||||||
</v-card>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-responsive>
|
|
||||||
</v-container>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
//
|
|
||||||
</script>
|
|
12
src/components/View.vue
Normal file
12
src/components/View.vue
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<v-main>
|
||||||
|
<v-container>
|
||||||
|
<router-view />
|
||||||
|
</v-container>
|
||||||
|
</v-main>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
# Layouts
|
|
||||||
|
|
||||||
Layouts are reusable components that wrap around pages. They are used to provide a consistent look and feel across multiple pages.
|
|
||||||
|
|
||||||
Full documentation for this feature can be found in the Official [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) repository.
|
|
@ -1,13 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-app>
|
<AppBar />
|
||||||
<v-main>
|
<View />
|
||||||
<router-view />
|
|
||||||
</v-main>
|
|
||||||
|
|
||||||
<AppFooter />
|
|
||||||
</v-app>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
//
|
// import { ref } from "vue";
|
||||||
|
// import { useConfigStore } from "@/stores/config";
|
||||||
|
import AppBar from "@/components/AppBar.vue";
|
||||||
|
import View from "@/components/View.vue";
|
||||||
|
|
||||||
|
// const configStore = useConfigStore();
|
||||||
|
|
||||||
|
// const drawer = ref(false);
|
||||||
|
// const logined = ref(false);
|
||||||
</script>
|
</script>
|
||||||
|
@ -6,28 +6,45 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { useConfigStore } from "@/stores/config";
|
||||||
|
import { useUserStore } from "@/stores/user";
|
||||||
|
import router from "@/router";
|
||||||
|
const configStore = useConfigStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const discovery_url =
|
let discovery = await axios.get(configStore.oauth_discovery_url);
|
||||||
"https://auth.leaflow.cn/.well-known/openid-configuration";
|
|
||||||
|
|
||||||
let discovery = await axios.get(discovery_url);
|
let local_code_verifier = localStorage.getItem(configStore.oauth_storage_key)
|
||||||
|
|
||||||
let local_code_verifier = localStorage.getItem("code_verifier")
|
|
||||||
|
|
||||||
// 从当前页面请求中获取 code
|
// 从当前页面请求中获取 code
|
||||||
let code = new URLSearchParams(window.location.search).get("code");
|
let code = new URLSearchParams(window.location.search).get("code");
|
||||||
|
|
||||||
|
|
||||||
let q = new URLSearchParams({
|
let q = new URLSearchParams({
|
||||||
client_id: '14',
|
client_id: configStore.oauth_client_id,
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
redirect_uri: 'http://localhost:3000/auth/callback',
|
redirect_uri: configStore.oauth_callback_url,
|
||||||
code_verifier: local_code_verifier || '',
|
code_verifier: local_code_verifier || '',
|
||||||
code: code || '',
|
code: code || '',
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenEndpoint = discovery.data.token_endpoint
|
const tokenEndpoint = discovery.data.token_endpoint
|
||||||
const r = await axios.post(tokenEndpoint, q)
|
const r = await axios.post(tokenEndpoint, q)
|
||||||
console.log(r.data)
|
|
||||||
|
|
||||||
|
userStore.access_token = r.data.access_token
|
||||||
|
userStore.refresh_token = r.data.refresh_token
|
||||||
|
|
||||||
|
userStore.login(
|
||||||
|
r.data.id_token,
|
||||||
|
r.data.access_token,
|
||||||
|
r.data.refresh_token,
|
||||||
|
r.data.expires_in,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
// 跳转到 /
|
||||||
|
router.push('/')
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -6,17 +6,17 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { useConfigStore } from "@/stores/config";
|
||||||
|
const configStore = useConfigStore();
|
||||||
|
|
||||||
const discovery_url =
|
|
||||||
"https://auth.leaflow.cn/.well-known/openid-configuration";
|
|
||||||
|
|
||||||
let discovery = await axios.get(discovery_url);
|
let discovery = await axios.get(configStore.oauth_discovery_url);
|
||||||
|
|
||||||
function generateRandomString(length: number) {
|
function generateRandomString(length: number) {
|
||||||
var text = "";
|
let text = "";
|
||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
for (var i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ function generateRandomString(length: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function generateCodeChallenge(codeVerifier: string) {
|
async function generateCodeChallenge(codeVerifier: string) {
|
||||||
var digest = await crypto.subtle.digest("SHA-256",
|
let digest = await crypto.subtle.digest("SHA-256",
|
||||||
new TextEncoder().encode(codeVerifier));
|
new TextEncoder().encode(codeVerifier));
|
||||||
|
|
||||||
return btoa(String.fromCharCode(...new Uint8Array(digest)))
|
return btoa(String.fromCharCode(...new Uint8Array(digest)))
|
||||||
@ -35,20 +35,18 @@ const codeVerifier = generateRandomString(128);
|
|||||||
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
||||||
|
|
||||||
// save code_verifier to localStorage
|
// save code_verifier to localStorage
|
||||||
localStorage.setItem("code_verifier", codeVerifier);
|
localStorage.setItem(configStore.oauth_storage_key, codeVerifier);
|
||||||
|
|
||||||
const query = new URLSearchParams({
|
const query = new URLSearchParams({
|
||||||
client_id: "14",
|
client_id: configStore.oauth_client_id,
|
||||||
redirect_uri: "http://localhost:3000/auth/callback",
|
redirect_uri: configStore.oauth_callback_url,
|
||||||
response_type: "code",
|
response_type: "code",
|
||||||
scope: "openid profile",
|
scope: configStore.oauth_scope,
|
||||||
code_challenge: codeChallenge,
|
code_challenge: codeChallenge,
|
||||||
code_challenge_method: "S256",
|
code_challenge_method: "S256",
|
||||||
// 'prompt': '', // "none", "consent", or "login"
|
|
||||||
}).toString();
|
}).toString();
|
||||||
|
|
||||||
console.log(discovery.data.authorization_endpoint + "?" + query);
|
|
||||||
|
|
||||||
// window.location.href = discovery.data.authorization_endpoint + "?" + query;
|
window.location.href = discovery.data.authorization_endpoint + "?" + query;
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,7 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<HelloWorld />
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
<div>index</div>
|
||||||
|
|
||||||
|
<button @click="refresh">refresh</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
//
|
|
||||||
|
|
||||||
|
console.log("this is index")
|
||||||
|
|
||||||
|
import { useUserStore } from '@/stores/user';
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
userStore.refresh()
|
||||||
|
console.log('refresh')
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
26
src/plugins/api.ts
Normal file
26
src/plugins/api.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import {Configuration, ChatApi, AssistantApi, PingApi, ToolApi, ChatMessageApi,} from "@/api";
|
||||||
|
import { useConfigStore } from "@/stores/config";
|
||||||
|
import { useUserStore } from "@/stores/user";
|
||||||
|
|
||||||
|
const configStore = useConfigStore()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
const conf = new Configuration
|
||||||
|
|
||||||
|
conf.basePath = configStore.backend
|
||||||
|
conf.apiKey = "Bearer " + userStore.id_token
|
||||||
|
|
||||||
|
|
||||||
|
const api = {
|
||||||
|
Chat: new ChatApi(conf),
|
||||||
|
Assistant: new AssistantApi(conf),
|
||||||
|
Ping: new PingApi(conf),
|
||||||
|
Tool: new ToolApi(conf),
|
||||||
|
ChatMessage: new ChatMessageApi(conf),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
api, conf
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
# Store
|
|
||||||
|
|
||||||
Pinia stores are used to store reactive state and expose actions to mutate it.
|
|
||||||
|
|
||||||
Full documentation for this feature can be found in the Official [Pinia](https://pinia.esm.dev/) repository.
|
|
14
src/stores/config.ts
Normal file
14
src/stores/config.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Utilities
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useConfigStore = defineStore('config', {
|
||||||
|
state: () => ({
|
||||||
|
app_name: "Amber",
|
||||||
|
oauth_discovery_url: "https://auth.leaflow.cn/.well-known/openid-configuration",
|
||||||
|
oauth_client_id: "14",
|
||||||
|
oauth_callback_url: "http://localhost:3000/auth/callback",
|
||||||
|
oauth_storage_key: "code_verifier",
|
||||||
|
oauth_scope: "openid profile",
|
||||||
|
backend: "http://localhost:8080"
|
||||||
|
}),
|
||||||
|
})
|
@ -1,4 +1,10 @@
|
|||||||
// Utilities
|
// Utilities
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
export default createPinia()
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||||
|
|
||||||
|
const pinia = createPinia()
|
||||||
|
|
||||||
|
pinia.use(piniaPluginPersistedstate)
|
||||||
|
|
||||||
|
export default pinia
|
||||||
|
96
src/stores/user.ts
Normal file
96
src/stores/user.ts
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { useConfigStore } from "@/stores/config";
|
||||||
|
import axios from "axios";
|
||||||
|
export const useUserStore = defineStore("user", {
|
||||||
|
persist: true,
|
||||||
|
state: () => ({
|
||||||
|
logined: false,
|
||||||
|
id_token: "",
|
||||||
|
refresh_token: "",
|
||||||
|
access_token: "",
|
||||||
|
expired_at: 0,
|
||||||
|
user: {
|
||||||
|
id: 0,
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
},
|
||||||
|
timer: 0,
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
login(
|
||||||
|
id_token: string,
|
||||||
|
access_token: string,
|
||||||
|
refresh_token: string,
|
||||||
|
expired_at: number
|
||||||
|
) {
|
||||||
|
let id_token_parts = id_token.split(".");
|
||||||
|
let id_token_payload = JSON.parse(atob(id_token_parts[1]));
|
||||||
|
|
||||||
|
expired_at = Date.now() + expired_at * 1000;
|
||||||
|
this.expired_at = expired_at;
|
||||||
|
|
||||||
|
this.refresh_token = refresh_token;
|
||||||
|
this.access_token = access_token;
|
||||||
|
|
||||||
|
this.id_token = id_token;
|
||||||
|
this.user.email = id_token_payload.email;
|
||||||
|
this.user.name = id_token_payload.name;
|
||||||
|
this.user.id = id_token_payload.sub;
|
||||||
|
this.logined = true;
|
||||||
|
},
|
||||||
|
setupTimer() {
|
||||||
|
// 如果有 timer
|
||||||
|
if (this.timer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.timer = setInterval(() => {
|
||||||
|
if (this.logined) {
|
||||||
|
if (this.expired_at - Date.now() < 60000) {
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
// else {
|
||||||
|
// // 显示还有多长时间过期
|
||||||
|
// // console.log("Token will expire in " + (this.expired_at - Date.now()) / 1000 + " seconds");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}, 10 * 1000);
|
||||||
|
},
|
||||||
|
async refresh() {
|
||||||
|
const configStore = useConfigStore();
|
||||||
|
|
||||||
|
let discovery = await axios.get(configStore.oauth_discovery_url);
|
||||||
|
|
||||||
|
// post /oauth/token to refresh
|
||||||
|
// 构建 form 参数
|
||||||
|
let data = new URLSearchParams();
|
||||||
|
data.set("grant_type", "refresh_token");
|
||||||
|
data.set("refresh_token", this.refresh_token);
|
||||||
|
data.set("client_id", configStore.oauth_client_id);
|
||||||
|
data.set("scope", configStore.oauth_scope);
|
||||||
|
|
||||||
|
// axios
|
||||||
|
let refresh = await axios.post(discovery.data.token_endpoint, data);
|
||||||
|
|
||||||
|
this.login(
|
||||||
|
refresh.data.id_token,
|
||||||
|
refresh.data.access_token,
|
||||||
|
refresh.data.refresh_token,
|
||||||
|
refresh.data.expires_in
|
||||||
|
);
|
||||||
|
},
|
||||||
|
logout() {
|
||||||
|
this.user = {
|
||||||
|
id: 0,
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
this.id_token = "";
|
||||||
|
this.logined = false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
userStore.setupTimer();
|
@ -2345,6 +2345,11 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1:
|
|||||||
resolved "https://mirrors.cloud.tencent.com/npm/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
|
resolved "https://mirrors.cloud.tencent.com/npm/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
|
||||||
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
|
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
|
||||||
|
|
||||||
|
pinia-plugin-persistedstate@^3.2.1:
|
||||||
|
version "3.2.1"
|
||||||
|
resolved "https://mirrors.cloud.tencent.com/npm/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz#66780602aecd6c7b152dd7e3ddc249a1f7a13fe5"
|
||||||
|
integrity sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ==
|
||||||
|
|
||||||
pinia@^2.1.7:
|
pinia@^2.1.7:
|
||||||
version "2.1.7"
|
version "2.1.7"
|
||||||
resolved "https://mirrors.cloud.tencent.com/npm/pinia/-/pinia-2.1.7.tgz#4cf5420d9324ca00b7b4984d3fbf693222115bbc"
|
resolved "https://mirrors.cloud.tencent.com/npm/pinia/-/pinia-2.1.7.tgz#4cf5420d9324ca00b7b4984d3fbf693222115bbc"
|
||||||
|
Loading…
Reference in New Issue
Block a user