改进
This commit is contained in:
parent
84cf40b3ac
commit
fc130065d9
@ -468,20 +468,20 @@
|
||||
"type": "string",
|
||||
"description": "标题",
|
||||
"name": "Title",
|
||||
"in": "query",
|
||||
"in": "formData",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "描述",
|
||||
"name": "Description",
|
||||
"in": "query"
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "文档内容",
|
||||
"name": "Content",
|
||||
"in": "query"
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
|
@ -42,6 +42,31 @@ export interface GormDeletedAt {
|
||||
*/
|
||||
'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
|
||||
@ -394,17 +419,15 @@ export const DocumentsApiAxiosParamCreator = function (configuration?: Configura
|
||||
*
|
||||
* @summary 新建文档
|
||||
* @param {string} libraryId 标题
|
||||
* @param {string} title 标题
|
||||
* @param {string} [description] 描述
|
||||
* @param {string} [content] 文档内容
|
||||
* @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @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
|
||||
assertParamExists('libraryLibraryIdDocumentsPost', 'libraryId', libraryId)
|
||||
// verify required parameter 'title' is not null or undefined
|
||||
assertParamExists('libraryLibraryIdDocumentsPost', 'title', title)
|
||||
// verify required parameter 'libraryLibraryIdDocumentsPostRequest' is not null or undefined
|
||||
assertParamExists('libraryLibraryIdDocumentsPost', 'libraryLibraryIdDocumentsPostRequest', libraryLibraryIdDocumentsPostRequest)
|
||||
const localVarPath = `/library/{LibraryId}/documents`
|
||||
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
|
||||
// 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
|
||||
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);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(libraryLibraryIdDocumentsPostRequest, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
@ -560,14 +574,12 @@ export const DocumentsApiFp = function(configuration?: Configuration) {
|
||||
*
|
||||
* @summary 新建文档
|
||||
* @param {string} libraryId 标题
|
||||
* @param {string} title 标题
|
||||
* @param {string} [description] 描述
|
||||
* @param {string} [content] 文档内容
|
||||
* @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async libraryLibraryIdDocumentsPost(libraryId: string, title: string, description?: string, content?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelDocument>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentsPost(libraryId, title, description, content, options);
|
||||
async libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ModelDocument>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options);
|
||||
const index = configuration?.serverIndex ?? 0;
|
||||
const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentsPost']?.[index]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
|
||||
@ -646,14 +658,12 @@ export const DocumentsApiFactory = function (configuration?: Configuration, base
|
||||
*
|
||||
* @summary 新建文档
|
||||
* @param {string} libraryId 标题
|
||||
* @param {string} title 标题
|
||||
* @param {string} [description] 描述
|
||||
* @param {string} [content] 文档内容
|
||||
* @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
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));
|
||||
libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: any): AxiosPromise<ModelDocument> {
|
||||
return localVarFp.libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
@ -734,15 +744,13 @@ export class DocumentsApi extends BaseAPI {
|
||||
*
|
||||
* @summary 新建文档
|
||||
* @param {string} libraryId 标题
|
||||
* @param {string} title 标题
|
||||
* @param {string} [description] 描述
|
||||
* @param {string} [content] 文档内容
|
||||
* @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof DocumentsApi
|
||||
*/
|
||||
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));
|
||||
public libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: AxiosRequestConfig) {
|
||||
return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +68,8 @@ import getTheme from "@/plugins/getTheme";
|
||||
import { watch } from "vue";
|
||||
import { getDocument } from "pdfjs-dist";
|
||||
import "pdfjs-dist/build/pdf.worker.mjs";
|
||||
import {convertToHtml} from "mammoth/mammoth.browser";
|
||||
import html2markdown from '@notable/html2markdown';
|
||||
import { convertToHtml } from "mammoth/mammoth.browser";
|
||||
import html2markdown from "@notable/html2markdown";
|
||||
|
||||
// 错误提示
|
||||
const errorMsg = ref("");
|
||||
@ -95,16 +95,23 @@ function createDocument() {
|
||||
document
|
||||
.libraryLibraryIdDocumentsPost(
|
||||
libraryIdInt,
|
||||
createData.value.Title,
|
||||
null,
|
||||
createData.value.Content
|
||||
{
|
||||
Title: createData.value.Title,
|
||||
Content: createData.value.Content,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((r) => {
|
||||
console.log(r);
|
||||
|
||||
created.value = true;
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
show_created_failed.value = true;
|
||||
});
|
||||
}
|
||||
@ -154,7 +161,9 @@ watch(file, (newVal) => {
|
||||
newVal[0].type ==
|
||||
"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 messages = resultObject.messages; // Any messages, such as warnings during conversion
|
||||
|
||||
@ -163,10 +172,10 @@ watch(file, (newVal) => {
|
||||
if (createData.value.Title == "") {
|
||||
// get first line of Content
|
||||
|
||||
const firstLine = createData.value.Content.split("\n")[0] ?? ""
|
||||
const firstLine = createData.value.Content.split("\n")[0] ?? "";
|
||||
|
||||
if (firstLine) {
|
||||
createData.value.Title = firstLine
|
||||
createData.value.Title = firstLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user