test 数据持久化与验证登录

This commit is contained in:
ivamp 2023-12-04 22:26:11 +08:00
parent 5bd9b1a2e2
commit 659fa9d0ad
13 changed files with 1012 additions and 92 deletions

View File

@ -1,63 +1,22 @@
{
"schemes": ["http","https"],
"swagger": "2.0",
"info": {
"description": "This is a sample server celler server.",
"title": "Swagger Example API",
"title": "Leaf Document",
"contact": {},
"version": "1.0"
},
"host": "",
"basePath": "/api",
"paths": {
"/document/{Id}": {
"delete": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Documents"
],
"summary": "删除文档",
"parameters": [
{
"type": "string",
"description": "文档 ID",
"name": "Id",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "资料库 ID",
"name": "LibraryId",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Document"
}
}
}
}
},
"/library/:LibraryId/documents": {
"/libraries": {
"get": {
"security": [
{
"BearerToken": []
}
],
"description": "获取当前账号的文档列表",
"consumes": [
"application/json"
],
@ -65,9 +24,9 @@
"application/json"
],
"tags": [
"Documents"
"Libraries"
],
"summary": "获取文档列表",
"summary": "获取资料库列表",
"parameters": [
{
"type": "integer",
@ -75,7 +34,109 @@
"name": "Page",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/model.Library"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
}
}
},
"post": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Libraries"
],
"summary": "新建资料库",
"parameters": [
{
"type": "integer",
"description": "资料库名称",
"name": "Name",
"in": "query",
"required": true
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/model.Library"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
}
}
}
},
"/library/{LibraryId}": {
"get": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Libraries"
],
"summary": "显示资料库",
"parameters": [
{
"type": "integer",
"description": "资料库 ID",
@ -85,11 +146,8 @@
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/pkg.ResponsePaginated"
}
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
@ -97,6 +155,61 @@
"$ref": "#/definitions/pkg.ResponseError"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
}
}
},
"post": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Libraries"
],
"summary": "删除资料库",
"parameters": [
{
"type": "integer",
"description": "资料库 ID",
"name": "LibraryId",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
@ -165,9 +278,160 @@
}
}
}
},
"put": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Documents"
],
"summary": "更新文档",
"parameters": [
{
"type": "string",
"description": "资料库 ID",
"name": "LibraryId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "文档 ID",
"name": "DocumentId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Document"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
}
}
},
"delete": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Documents"
],
"summary": "删除文档",
"parameters": [
{
"type": "integer",
"description": "文档 ID",
"name": "DocumentId",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "资料库 ID",
"name": "LibraryId",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/library/{LibraryId}/documents": {
"get": {
"security": [
{
"BearerToken": []
}
],
"description": "获取当前账号的文档列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Documents"
],
"summary": "获取文档列表",
"parameters": [
{
"type": "integer",
"description": "页码",
"name": "Page",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "资料库 ID",
"name": "LibraryId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/pkg.ResponsePaginated"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
}
}
},
"post": {
"security": [
{
@ -233,6 +497,61 @@
}
}
}
},
"/library/{LibraryId}/query": {
"get": {
"security": [
{
"BearerToken": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Documents"
],
"summary": "Server Sent Events 查询文档",
"parameters": [
{
"type": "string",
"description": "资料库 ID",
"name": "LibraryId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "问题",
"name": "Question",
"in": "query",
"required": true
}
],
"responses": {
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/pkg.ResponseError"
}
}
}
}
}
},
"definitions": {
@ -283,6 +602,32 @@
}
}
},
"model.Library": {
"type": "object",
"properties": {
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"password": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
"userId": {
"type": "integer"
}
}
},
"pkg.ResponseError": {
"type": "object",
"properties": {

View File

@ -12,6 +12,7 @@
"axios": "^1.6.2",
"core-js": "^3.29.0",
"pinia": "^2.0.0",
"pinia-plugin-persistedstate": "^3.2.0",
"roboto-fontface": "*",
"vue": "^3.2.0",
"vue-axios": "^3.5.2",

View File

@ -1,12 +1,32 @@
<template>
<v-container class="fill-height">
<v-responsive class="align-center text-center fill-height">
<v-btn>Hi</v-btn>
<v-btn @click="testrequest">Hi</v-btn>
<v-text-field label="Label" v-model="token"></v-text-field>
<v-btn @click="settoken">设置</v-btn>
</v-responsive>
</v-container>
</template>
<script lang="ts" setup>
import library from '@/plugins/library'
import {library} from '@/plugins/library'
import { ref } from 'vue';
import { useUserStore } from '@/store/user';
const userStore = useUserStore()
const token = ref("")
const settoken = () => {
userStore.login("0", token.value)
console.log(userStore.jwt_token)
}
const testrequest = () => {
library.librariesGet(1).then(r => console.log(r))
}
// library.libraryLibraryIdDocumentsGet(1,2)
</script>

View File

@ -1,6 +1,5 @@
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
base.ts
common.ts

View File

@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */
/**
* Swagger Example API
* Leaf Document
* This is a sample server celler server.
*
* The version of the OpenAPI document: 1.0
@ -109,6 +109,55 @@ export interface ModelDocument {
*/
'userId'?: number;
}
/**
*
* @export
* @interface ModelLibrary
*/
export interface ModelLibrary {
/**
*
* @type {string}
* @memberof ModelLibrary
*/
'createdAt'?: string;
/**
*
* @type {GormDeletedAt}
* @memberof ModelLibrary
*/
'deletedAt'?: GormDeletedAt;
/**
*
* @type {number}
* @memberof ModelLibrary
*/
'id'?: number;
/**
*
* @type {string}
* @memberof ModelLibrary
*/
'name'?: string;
/**
*
* @type {string}
* @memberof ModelLibrary
*/
'password'?: string;
/**
*
* @type {string}
* @memberof ModelLibrary
*/
'updatedAt'?: string;
/**
*
* @type {number}
* @memberof ModelLibrary
*/
'userId'?: number;
}
/**
*
* @export
@ -163,18 +212,19 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
/**
*
* @summary
* @param {string} id ID
* @param {number} documentId ID
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
documentIdDelete: async (id: string, libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
assertParamExists('documentIdDelete', 'id', id)
libraryLibraryIdDocumentDocumentIdDelete: async (documentId: number, libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'documentId' is not null or undefined
assertParamExists('libraryLibraryIdDocumentDocumentIdDelete', 'documentId', documentId)
// verify required parameter 'libraryId' is not null or undefined
assertParamExists('documentIdDelete', 'libraryId', libraryId)
const localVarPath = `/document/{Id}`
.replace(`{${"Id"}}`, encodeURIComponent(String(id)));
assertParamExists('libraryLibraryIdDocumentDocumentIdDelete', 'libraryId', libraryId)
const localVarPath = `/library/{LibraryId}/document/{DocumentId}`
.replace(`{${"DocumentId"}}`, encodeURIComponent(String(documentId)))
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
@ -189,10 +239,6 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
if (libraryId !== undefined) {
localVarQueryParameter['LibraryId'] = libraryId;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
@ -236,6 +282,47 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {string} libraryId ID
* @param {string} documentId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdDocumentDocumentIdPut: async (libraryId: string, documentId: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'libraryId' is not null or undefined
assertParamExists('libraryLibraryIdDocumentDocumentIdPut', 'libraryId', libraryId)
// verify required parameter 'documentId' is not null or undefined
assertParamExists('libraryLibraryIdDocumentDocumentIdPut', 'documentId', documentId)
const localVarPath = `/library/{LibraryId}/document/{DocumentId}`
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)))
.replace(`{${"DocumentId"}}`, encodeURIComponent(String(documentId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@ -258,7 +345,7 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
assertParamExists('libraryLibraryIdDocumentsGet', 'page', page)
// verify required parameter 'libraryId' is not null or undefined
assertParamExists('libraryLibraryIdDocumentsGet', 'libraryId', libraryId)
const localVarPath = `/library/:LibraryId/documents`
const localVarPath = `/library/{LibraryId}/documents`
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@ -334,6 +421,50 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Server Sent Events
* @param {string} libraryId ID
* @param {string} question
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdQueryGet: async (libraryId: string, question: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'libraryId' is not null or undefined
assertParamExists('libraryLibraryIdQueryGet', 'libraryId', libraryId)
// verify required parameter 'question' is not null or undefined
assertParamExists('libraryLibraryIdQueryGet', 'question', question)
const localVarPath = `/library/{LibraryId}/query`
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
if (question !== undefined) {
localVarQueryParameter['Question'] = question;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@ -356,15 +487,15 @@ export const DocumentsApiFp = function(configuration?: Configuration) {
/**
*
* @summary
* @param {string} id ID
* @param {number} documentId ID
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async documentIdDelete(id: string, libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelDocument>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.documentIdDelete(id, libraryId, options);
async libraryLibraryIdDocumentDocumentIdDelete(documentId: number, libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentDocumentIdDelete(documentId, libraryId, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['DocumentsApi.documentIdDelete']?.[index]?.url;
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdDelete']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
@ -381,6 +512,20 @@ export const DocumentsApiFp = function(configuration?: Configuration) {
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdGet']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
*
* @summary
* @param {string} libraryId ID
* @param {string} documentId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async libraryLibraryIdDocumentDocumentIdPut(libraryId: string, documentId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelDocument>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentDocumentIdPut(libraryId, documentId, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdPut']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
*
* @summary
@ -411,6 +556,20 @@ export const DocumentsApiFp = function(configuration?: Configuration) {
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentsPost']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
*
* @summary Server Sent Events
* @param {string} libraryId ID
* @param {string} question
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async libraryLibraryIdQueryGet(libraryId: string, question: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdQueryGet(libraryId, question, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdQueryGet']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
}
};
@ -424,13 +583,13 @@ export const DocumentsApiFactory = function (configuration?: Configuration, base
/**
*
* @summary
* @param {string} id ID
* @param {number} documentId ID
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
documentIdDelete(id: string, libraryId: number, options?: any): AxiosPromise<ModelDocument> {
return localVarFp.documentIdDelete(id, libraryId, options).then((request) => request(axios, basePath));
libraryLibraryIdDocumentDocumentIdDelete(documentId: number, libraryId: number, options?: any): AxiosPromise<void> {
return localVarFp.libraryLibraryIdDocumentDocumentIdDelete(documentId, libraryId, options).then((request) => request(axios, basePath));
},
/**
*
@ -443,6 +602,17 @@ export const DocumentsApiFactory = function (configuration?: Configuration, base
libraryLibraryIdDocumentDocumentIdGet(libraryId: string, documentId: string, options?: any): AxiosPromise<ModelDocument> {
return localVarFp.libraryLibraryIdDocumentDocumentIdGet(libraryId, documentId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {string} libraryId ID
* @param {string} documentId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdDocumentDocumentIdPut(libraryId: string, documentId: string, options?: any): AxiosPromise<ModelDocument> {
return localVarFp.libraryLibraryIdDocumentDocumentIdPut(libraryId, documentId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
@ -467,6 +637,17 @@ export const DocumentsApiFactory = function (configuration?: Configuration, base
libraryLibraryIdDocumentsPost(libraryId: string, title: string, description?: string, content?: string, options?: any): AxiosPromise<ModelDocument> {
return localVarFp.libraryLibraryIdDocumentsPost(libraryId, title, description, content, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Server Sent Events
* @param {string} libraryId ID
* @param {string} question
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdQueryGet(libraryId: string, question: string, options?: any): AxiosPromise<void> {
return localVarFp.libraryLibraryIdQueryGet(libraryId, question, options).then((request) => request(axios, basePath));
},
};
};
@ -480,14 +661,14 @@ export class DocumentsApi extends BaseAPI {
/**
*
* @summary
* @param {string} id ID
* @param {number} documentId ID
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DocumentsApi
*/
public documentIdDelete(id: string, libraryId: number, options?: AxiosRequestConfig) {
return DocumentsApiFp(this.configuration).documentIdDelete(id, libraryId, options).then((request) => request(this.axios, this.basePath));
public libraryLibraryIdDocumentDocumentIdDelete(documentId: number, libraryId: number, options?: AxiosRequestConfig) {
return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdDelete(documentId, libraryId, options).then((request) => request(this.axios, this.basePath));
}
/**
@ -503,6 +684,19 @@ export class DocumentsApi extends BaseAPI {
return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdGet(libraryId, documentId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {string} libraryId ID
* @param {string} documentId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DocumentsApi
*/
public libraryLibraryIdDocumentDocumentIdPut(libraryId: string, documentId: string, options?: AxiosRequestConfig) {
return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdPut(libraryId, documentId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
@ -530,6 +724,352 @@ export class DocumentsApi extends BaseAPI {
public libraryLibraryIdDocumentsPost(libraryId: string, title: string, description?: string, content?: string, options?: AxiosRequestConfig) {
return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentsPost(libraryId, title, description, content, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Server Sent Events
* @param {string} libraryId ID
* @param {string} question
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DocumentsApi
*/
public libraryLibraryIdQueryGet(libraryId: string, question: string, options?: AxiosRequestConfig) {
return DocumentsApiFp(this.configuration).libraryLibraryIdQueryGet(libraryId, question, options).then((request) => request(this.axios, this.basePath));
}
}
/**
* LibrariesApi - axios parameter creator
* @export
*/
export const LibrariesApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @summary
* @param {number} page
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
librariesGet: async (page: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'page' is not null or undefined
assertParamExists('librariesGet', 'page', page)
const localVarPath = `/libraries`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
if (page !== undefined) {
localVarQueryParameter['Page'] = page;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {number} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
librariesPost: async (name: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('librariesPost', 'name', name)
const localVarPath = `/libraries`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
if (name !== undefined) {
localVarQueryParameter['Name'] = name;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdGet: async (libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'libraryId' is not null or undefined
assertParamExists('libraryLibraryIdGet', 'libraryId', libraryId)
const localVarPath = `/library/{LibraryId}`
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdPost: async (libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'libraryId' is not null or undefined
assertParamExists('libraryLibraryIdPost', 'libraryId', libraryId)
const localVarPath = `/library/{LibraryId}`
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* LibrariesApi - functional programming interface
* @export
*/
export const LibrariesApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = LibrariesApiAxiosParamCreator(configuration)
return {
/**
*
* @summary
* @param {number} page
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async librariesGet(page: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<ModelLibrary>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.librariesGet(page, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['LibrariesApi.librariesGet']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
*
* @summary
* @param {number} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async librariesPost(name: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelLibrary>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.librariesPost(name, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['LibrariesApi.librariesPost']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async libraryLibraryIdGet(libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdGet(libraryId, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdGet']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async libraryLibraryIdPost(libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdPost(libraryId, options);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdPost']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
}
};
/**
* LibrariesApi - factory interface
* @export
*/
export const LibrariesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = LibrariesApiFp(configuration)
return {
/**
*
* @summary
* @param {number} page
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
librariesGet(page: number, options?: any): AxiosPromise<Array<ModelLibrary>> {
return localVarFp.librariesGet(page, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {number} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
librariesPost(name: number, options?: any): AxiosPromise<ModelLibrary> {
return localVarFp.librariesPost(name, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdGet(libraryId: number, options?: any): AxiosPromise<void> {
return localVarFp.libraryLibraryIdGet(libraryId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
libraryLibraryIdPost(libraryId: number, options?: any): AxiosPromise<void> {
return localVarFp.libraryLibraryIdPost(libraryId, options).then((request) => request(axios, basePath));
},
};
};
/**
* LibrariesApi - object-oriented interface
* @export
* @class LibrariesApi
* @extends {BaseAPI}
*/
export class LibrariesApi extends BaseAPI {
/**
*
* @summary
* @param {number} page
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof LibrariesApi
*/
public librariesGet(page: number, options?: AxiosRequestConfig) {
return LibrariesApiFp(this.configuration).librariesGet(page, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {number} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof LibrariesApi
*/
public librariesPost(name: number, options?: AxiosRequestConfig) {
return LibrariesApiFp(this.configuration).librariesPost(name, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof LibrariesApi
*/
public libraryLibraryIdGet(libraryId: number, options?: AxiosRequestConfig) {
return LibrariesApiFp(this.configuration).libraryLibraryIdGet(libraryId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {number} libraryId ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof LibrariesApi
*/
public libraryLibraryIdPost(libraryId: number, options?: AxiosRequestConfig) {
return LibrariesApiFp(this.configuration).libraryLibraryIdPost(libraryId, options).then((request) => request(this.axios, this.basePath));
}
}

View File

@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */
/**
* Swagger Example API
* Leaf Document
* This is a sample server celler server.
*
* The version of the OpenAPI document: 1.0
@ -19,7 +19,7 @@ import type { Configuration } from './configuration';
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
export const BASE_PATH = "/api".replace(/\/+$/, "");
/**
*

View File

@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */
/**
* Swagger Example API
* Leaf Document
* This is a sample server celler server.
*
* The version of the OpenAPI document: 1.0

View File

@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */
/**
* Swagger Example API
* Leaf Document
* This is a sample server celler server.
*
* The version of the OpenAPI document: 1.0

View File

@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */
/**
* Swagger Example API
* Leaf Document
* This is a sample server celler server.
*
* The version of the OpenAPI document: 1.0

View File

@ -1,8 +1,8 @@
import { DocumentsApi, Configuration } from "../openapi";
import { DocumentsApi, Configuration, LibrariesApi } from "../openapi";
import axios from "axios";
import router from "@/router";
// import {useUserStore} from "@/stores/user";
// import axios from "axios";
// import router from "@/router";
import {useUserStore} from "@/store/user";
// // const config = useConfigStore()
// import config from "@/plugins/config"
@ -44,10 +44,15 @@ import router from "@/router";
// export default instance;
const userStore = useUserStore()
const conf = new Configuration
conf.basePath = "https://document.awa.im/api"
conf.apiKey = "a"
const a = new DocumentsApi(conf);
conf.apiKey = "Bearer " + userStore.jwt_token
const document = new DocumentsApi(conf);
const library = new LibrariesApi(conf);
export default a
export {
document, library
}

View File

@ -1,4 +1,6 @@
// Utilities
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
export default createPinia()
export default createPinia().use(piniaPluginPersistedstate)

View File

@ -34,6 +34,9 @@ export const useUserStore = defineStore('user', {
console.error(e)
this.logout()
})
},
get_token() {
return this.jwt_token
}
}
})

View File

@ -1352,6 +1352,11 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1:
resolved "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
pinia-plugin-persistedstate@^3.2.0:
version "3.2.0"
resolved "https://registry.npmmirror.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz#9932ca2ae88aa6c0d6763bebc6447d7bd1f097d0"
integrity sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==
pinia@^2.0.0:
version "2.1.7"
resolved "https://registry.npmmirror.com/pinia/-/pinia-2.1.7.tgz#4cf5420d9324ca00b7b4984d3fbf693222115bbc"