TODO: 增加 资料库创建

This commit is contained in:
Twilight 2023-12-12 19:44:46 +08:00
parent 127e44840d
commit 7ad7251b53
6 changed files with 47 additions and 24 deletions

View File

@ -72,5 +72,7 @@ See [Configuration Reference](https://vitejs.dev/config/).
### 根据 OpenAPI 生成代码
```bash
./node_modules/.bin/openapi-generator-cli generate -i api/swagger.json -g typescript-axios -o src/openapi
npm install -g @openapitools/openapi-generator-cli
openapi-generator-cli generate -i api/swagger.json -g typescript-axios -o src/openapi
```

View File

@ -1,14 +1,11 @@
{
"schemes": ["http","https"],
"swagger": "2.0",
"info": {
"description": "This is a sample server celler server.",
"title": "Leaf Document",
"title": "Swagger Example API",
"contact": {},
"version": "1.0"
},
"host": "",
"basePath": "/api",
"paths": {
"/libraries": {
"get": {
@ -81,7 +78,7 @@
"summary": "新建资料库",
"parameters": [
{
"type": "integer",
"type": "string",
"description": "资料库名称",
"name": "Name",
"in": "query",

View File

@ -11,6 +11,7 @@
"deploy": "npx wrangler pages deploy dist --project-name=document-web"
},
"dependencies": {
"@notable/html2markdown": "^2.0.3",
"axios": "^1.6.2",
"core-js": "^3.29.0",
"event-source-polyfill": "^1.0.31",
@ -20,7 +21,6 @@
"pinia": "^2.0.0",
"pinia-plugin-persistedstate": "^3.2.0",
"roboto-fontface": "*",
"turndown": "^7.1.2",
"vue": "^3.2.0",
"vue-axios": "^3.5.2",
"vue-router": "^4.0.0",

View File

@ -69,8 +69,7 @@ import { watch } from "vue";
import { getDocument } from "pdfjs-dist";
import "pdfjs-dist/build/pdf.worker.mjs";
import {convertToHtml} from "mammoth/mammoth.browser";
import TurndownService from "turndown";
import html2markdown from '@notable/html2markdown';
//
const errorMsg = ref("");
@ -159,10 +158,20 @@ watch(file, (newVal) => {
let html = resultObject.value; // The generated HTML
let messages = resultObject.messages; // Any messages, such as warnings during conversion
// convert to markdown
createData.value.Content = TurndownService.turndown(html);
createData.value.Content = html2markdown(html);
if (createData.value.Title == "") {
// get first line of Content
const firstLine = createData.value.Content.split("\n")[0] ?? ""
if (firstLine) {
createData.value.Title = firstLine
}
}
// console.log(html);
// console.log(messages);
console.warn(messages);
});
} else {
errorMsg.value = "您只能选择 DPF 或者 DOCX 文件。";

View File

@ -194,4 +194,12 @@ function deleteSelected() {
}, 1000);
}
}
const creatingLibrary = ref(false)
// function newLibrary(name) {
// creatingLibrary.value = true
// library.librariesPost(name).then
// }
</script>

View File

@ -630,6 +630,13 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@notable/html2markdown@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@notable/html2markdown/-/html2markdown-2.0.3.tgz#7d4fd45fd64081090921233727a4af65eaa4730e"
integrity sha512-ah3y5vNXKURWRxURrnyCNMwdZCABp0hPwtSOfZBldldl5Qwre9OVV5aT2kTg2t0d0fQCRXxefA6o0w48A7nb2A==
dependencies:
mime2ext "^2.0.0"
"@rollup/plugin-virtual@^3.0.2":
version "3.0.2"
resolved "https://registry.npmmirror.com/@rollup/plugin-virtual/-/plugin-virtual-3.0.2.tgz#17e17eeecb4c9fa1c0a6e72c9e5f66382fddbb82"
@ -1337,11 +1344,6 @@ doctrine@^3.0.0:
dependencies:
esutils "^2.0.2"
domino@^2.1.6:
version "2.1.6"
resolved "https://registry.npmmirror.com/domino/-/domino-2.1.6.tgz#fe4ace4310526e5e7b9d12c7de01b7f485a57ffe"
integrity sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==
duck@^0.1.12:
version "0.1.12"
resolved "https://registry.npmmirror.com/duck/-/duck-0.1.12.tgz#de7adf758421230b6d7aee799ce42670586b9efa"
@ -2011,6 +2013,11 @@ mime-db@1.52.0:
resolved "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
mime-standard@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/mime-standard/-/mime-standard-1.0.2.tgz#de9472dacfe8dc8fa70d2b28074ffc6e007a1f67"
integrity sha512-xUmjXVgIU9bL370jglTuRunmIJyOx9CKPH5IgaQtfx7IwUmKfMKuJddFXCFALFks/9fZ/zk3/ko9NoTskVx51g==
mime-types@^2.1.12:
version "2.1.35"
resolved "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
@ -2018,6 +2025,13 @@ mime-types@^2.1.12:
dependencies:
mime-db "1.52.0"
mime2ext@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/mime2ext/-/mime2ext-2.0.0.tgz#4aa1896c08a3e294042e49f8c14465965ef9e4f2"
integrity sha512-v4f86Jsi/wtqbeXVJXcd7ZxMGAnTJ55LlMJS2tNYEQQoevDq6DdsxJxIAACjRUMPL43QJVzL6nF5x78BNf4R2Q==
dependencies:
mime-standard "^1.0.2"
mimic-response@^2.0.0:
version "2.1.0"
resolved "https://registry.npmmirror.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43"
@ -2562,13 +2576,6 @@ tsutils@^3.21.0:
dependencies:
tslib "^1.8.1"
turndown@^7.1.2:
version "7.1.2"
resolved "https://registry.npmmirror.com/turndown/-/turndown-7.1.2.tgz#7feb838c78f14241e79ed92a416e0d213e044a29"
integrity sha512-ntI9R7fcUKjqBP6QU8rBK2Ehyt8LAzt3UBT9JR9tgo6GtuKvyUzpayWmeMKJw1DPdXzktvtIT8m2mVXz+bL/Qg==
dependencies:
domino "^2.1.6"
type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
resolved "https://registry.npmmirror.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"