This commit is contained in:
ivamp 2023-12-12 20:20:54 +08:00
parent 84cf40b3ac
commit fc130065d9
3 changed files with 62 additions and 45 deletions

View File

@ -468,20 +468,20 @@
"type": "string", "type": "string",
"description": "标题", "description": "标题",
"name": "Title", "name": "Title",
"in": "query", "in": "formData",
"required": true "required": true
}, },
{ {
"type": "string", "type": "string",
"description": "描述", "description": "描述",
"name": "Description", "name": "Description",
"in": "query" "in": "formData"
}, },
{ {
"type": "string", "type": "string",
"description": "文档内容", "description": "文档内容",
"name": "Content", "name": "Content",
"in": "query" "in": "formData"
} }
], ],
"responses": { "responses": {

View File

@ -42,6 +42,31 @@ export interface GormDeletedAt {
*/ */
'valid'?: boolean; 'valid'?: boolean;
} }
/**
*
* @export
* @interface LibraryLibraryIdDocumentsPostRequest
*/
export interface LibraryLibraryIdDocumentsPostRequest {
/**
*
* @type {string}
* @memberof LibraryLibraryIdDocumentsPostRequest
*/
'Title': string;
/**
*
* @type {string}
* @memberof LibraryLibraryIdDocumentsPostRequest
*/
'Description'?: string;
/**
*
* @type {string}
* @memberof LibraryLibraryIdDocumentsPostRequest
*/
'Content'?: string;
}
/** /**
* *
* @export * @export
@ -394,17 +419,15 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
* *
* @summary * @summary
* @param {string} libraryId * @param {string} libraryId
* @param {string} title * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
* @param {string} [description]
* @param {string} [content]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
libraryLibraryIdDocumentsPost: async (libraryId: string, title: string, description?: string, content?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => { libraryLibraryIdDocumentsPost: async (libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'libraryId' is not null or undefined // verify required parameter 'libraryId' is not null or undefined
assertParamExists('libraryLibraryIdDocumentsPost', 'libraryId', libraryId) assertParamExists('libraryLibraryIdDocumentsPost', 'libraryId', libraryId)
// verify required parameter 'title' is not null or undefined // verify required parameter 'libraryLibraryIdDocumentsPostRequest' is not null or undefined
assertParamExists('libraryLibraryIdDocumentsPost', 'title', title) assertParamExists('libraryLibraryIdDocumentsPost', 'libraryLibraryIdDocumentsPostRequest', libraryLibraryIdDocumentsPostRequest)
const localVarPath = `/library/{LibraryId}/documents` const localVarPath = `/library/{LibraryId}/documents`
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs. // use dummy base URL string because the URL constructor only accepts absolute URLs.
@ -421,23 +444,14 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
// authentication BearerToken required // authentication BearerToken required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)
if (title !== undefined) {
localVarQueryParameter['Title'] = title;
}
if (description !== undefined) {
localVarQueryParameter['Description'] = description;
}
if (content !== undefined) {
localVarQueryParameter['Content'] = content;
}
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(libraryLibraryIdDocumentsPostRequest, localVarRequestOptions, configuration)
return { return {
url: toPathString(localVarUrlObj), url: toPathString(localVarUrlObj),
@ -560,14 +574,12 @@ export const DocumentsApiFp = function(configuration?: Configuration) {
* *
* @summary * @summary
* @param {string} libraryId * @param {string} libraryId
* @param {string} title * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
* @param {string} [description]
* @param {string} [content]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async libraryLibraryIdDocumentsPost(libraryId: string, title: string, description?: string, content?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelDocument>> { async libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelDocument>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentsPost(libraryId, title, description, content, options); const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options);
const index = configuration?.serverIndex ?? 0; const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentsPost']?.[index]?.url; const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentsPost']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
@ -646,14 +658,12 @@ export const DocumentsApiFactory = function (configuration?: Configuration, base
* *
* @summary * @summary
* @param {string} libraryId * @param {string} libraryId
* @param {string} title * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
* @param {string} [description]
* @param {string} [content]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
*/ */
libraryLibraryIdDocumentsPost(libraryId: string, title: string, description?: string, content?: string, options?: any): AxiosPromise<ModelDocument> { libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: any): AxiosPromise<ModelDocument> {
return localVarFp.libraryLibraryIdDocumentsPost(libraryId, title, description, content, options).then((request) => request(axios, basePath)); return localVarFp.libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options).then((request) => request(axios, basePath));
}, },
/** /**
* *
@ -734,15 +744,13 @@ export class DocumentsApi extends BaseAPI {
* *
* @summary * @summary
* @param {string} libraryId * @param {string} libraryId
* @param {string} title * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
* @param {string} [description]
* @param {string} [content]
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
* @memberof DocumentsApi * @memberof DocumentsApi
*/ */
public libraryLibraryIdDocumentsPost(libraryId: string, title: string, description?: string, content?: string, options?: AxiosRequestConfig) { public libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: AxiosRequestConfig) {
return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentsPost(libraryId, title, description, content, options).then((request) => request(this.axios, this.basePath)); return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options).then((request) => request(this.axios, this.basePath));
} }
/** /**

View File

@ -68,8 +68,8 @@ import getTheme from "@/plugins/getTheme";
import { watch } from "vue"; import { watch } from "vue";
import { getDocument } from "pdfjs-dist"; import { getDocument } from "pdfjs-dist";
import "pdfjs-dist/build/pdf.worker.mjs"; import "pdfjs-dist/build/pdf.worker.mjs";
import {convertToHtml} from "mammoth/mammoth.browser"; import { convertToHtml } from "mammoth/mammoth.browser";
import html2markdown from '@notable/html2markdown'; import html2markdown from "@notable/html2markdown";
// //
const errorMsg = ref(""); const errorMsg = ref("");
@ -95,16 +95,23 @@ function createDocument() {
document document
.libraryLibraryIdDocumentsPost( .libraryLibraryIdDocumentsPost(
libraryIdInt, libraryIdInt,
createData.value.Title, {
null, Title: createData.value.Title,
createData.value.Content Content: createData.value.Content,
},
{
headers: {
"Content-Type": "application/json",
},
}
) )
.then((r) => { .then((r) => {
console.log(r); console.log(r);
created.value = true; created.value = true;
}) })
.catch(() => { .catch((e) => {
console.error(e);
show_created_failed.value = true; show_created_failed.value = true;
}); });
} }
@ -154,7 +161,9 @@ watch(file, (newVal) => {
newVal[0].type == newVal[0].type ==
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
) { ) {
convertToHtml({arrayBuffer: reader.result}).then(function (resultObject) { convertToHtml({ arrayBuffer: reader.result }).then(function (
resultObject
) {
let html = resultObject.value; // The generated HTML let html = resultObject.value; // The generated HTML
let messages = resultObject.messages; // Any messages, such as warnings during conversion let messages = resultObject.messages; // Any messages, such as warnings during conversion
@ -163,10 +172,10 @@ watch(file, (newVal) => {
if (createData.value.Title == "") { if (createData.value.Title == "") {
// get first line of Content // get first line of Content
const firstLine = createData.value.Content.split("\n")[0] ?? "" const firstLine = createData.value.Content.split("\n")[0] ?? "";
if (firstLine) { if (firstLine) {
createData.value.Title = firstLine createData.value.Title = firstLine;
} }
} }