Skip to content

Commit

Permalink
[feature] keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
WindLX committed Dec 9, 2023
1 parent e2ebeb2 commit cd5bbda
Show file tree
Hide file tree
Showing 21 changed files with 169 additions and 313 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@ Pap 需要 Python 3.11.4 的运行环境. 所有脚本均可通过 `Get-Help scr
- [x] Note Tag
- [x] Rightbar
- [x] Private Lock
- [ ] Keymap
- [ ] Style
- [x] Keymap
- [x] Title List
- [x] Markdown Ref net
- [x] Resource
- [x] Pdf viewer
- [x] Music viewer
- [ ] Video viewer
- [x] Data Export
- [ ] Table
- [ ] Database
- [ ] OCR
- [ ] Table
Binary file modified libmd_net.so
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pap",
"private": true,
"version": "0.1.7",
"version": "0.1.8",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
10 changes: 1 addition & 9 deletions src-python/router/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from service.logger import logger
from service.config import path_config

from fastapi import status, APIRouter, HTTPException, UploadFile
from fastapi import status, APIRouter, HTTPException, UploadFile, WebSocket
from fastapi.responses import FileResponse, StreamingResponse

router = APIRouter(prefix="/resource")
Expand Down Expand Up @@ -100,11 +100,3 @@ async def remove_zip():
zip_path = "./data.zip"
if path.exists(zip_path):
remove(zip_path)


@router.get("/get_stream", status_code=status.HTTP_200_OK, include_in_schema=True)
async def get_stream(url: str):
if not path.exists(url):
raise HTTPException(status_code=404, detail="Video file not found")

return StreamingResponse(open(url, "rb"))
12 changes: 0 additions & 12 deletions src/api/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ export class ResourceApi extends BaseApi {
})
}

public static async getStreamUrl(url: string): Promise<string> {
return new Promise(function (resolve, reject) {
pFetch(`/resource/get_stream?url=${url}`)
.then(async res => {
const blob = await res.blob()
const objectURL = URL.createObjectURL(blob);
resolve(objectURL)
})
.catch(e => reject(e))
})
}

public static async getBlobUrl(url: string): Promise<string> {
return new Promise(function (resolve, reject) {
pFetch(`/${url}`)
Expand Down
16 changes: 5 additions & 11 deletions src/components/Content/Content.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<script setup lang="ts">
import { computed } from 'vue';
import { useStateStore, SidebarIndex } from '@/store/state'
import { useStateStore, ContentIndex } from '@/store/state'
import Notespace from './Notespace.vue';
import Resourcespace from './Resourcespace.vue';
import Databasespace from './Databasespace.vue';
import Settingspace from './Settingspace.vue';
import Netspace from './Netspace.vue';
// state
const store = useStateStore();
// content
const currentComponent = computed(() => {
switch (store.sidebarIndex) {
case SidebarIndex.Note:
switch (store.contentIndex) {
case ContentIndex.Note:
return Notespace
case SidebarIndex.Net:
case ContentIndex.Net:
return Netspace
case SidebarIndex.Resource:
case ContentIndex.Resource:
return Resourcespace
case SidebarIndex.Database:
return Databasespace
case SidebarIndex.Setting:
return Settingspace
default:
return Notespace
}
Expand Down
10 changes: 0 additions & 10 deletions src/components/Content/Settingspace.vue

This file was deleted.

32 changes: 29 additions & 3 deletions src/components/Markdown/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const props = defineProps<{
const emits = defineEmits<{
(e: 'update:mdData', value: string): void,
(e: 'onEdit'): void,
(e: 'tag'): void,
(e: 'lock'): void,
(e: 'export'): void,
(e: 'pdf'): void,
(e: 'outline'): void,
}>();
defineExpose({
Expand All @@ -31,10 +36,31 @@ const blocks = ref<Array<InstanceType<typeof MdBlock>>>([]);
let rawDataSet = ref<Array<string>>([""])
function handleKeyDown(event: KeyboardEvent) {
if (event.ctrlKey && event.key === 's') {
if (event.ctrlKey) {
event.preventDefault();
const newData = saveData();
emits('update:mdData', newData);
switch (event.key) {
case '1':
emits('tag')
break;
case '2':
emits('lock')
break;
case '3':
const newData = saveData();
emits('update:mdData', newData);
break;
case '4':
emits('export')
break;
case '5':
emits('pdf')
break;
case '6':
emits('outline')
break;
default:
break;
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/components/Markdown/Markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ function handleShowOutline() {
isTagListShow.value = false
}
function handleLock() {
lockState.value = !lockState.value;
emits('lock', lockState.value)
}
onMounted(async () => {
await loadContentAsync()
window.onbeforeprint = () => {
Expand All @@ -132,7 +137,7 @@ onMounted(async () => {
<font-awesome-icon :icon="['fas', 'tags']" class="icon" :class="isTagListShow ? 'active' : ''"
@mousedown="handleShowTagList()" />
<font-awesome-icon :icon="['fas', lockState ? 'lock' : 'lock-open']" class="icon"
:class="lockState ? 'active' : ''" @mousedown="lockState = !lockState; emits('lock', lockState)" />
:class="lockState ? 'active' : ''" @mousedown="handleLock()" />
<font-awesome-icon :icon="['fas', 'floppy-disk']" class="icon" style="font-size: 22px;"
@mousedown="editor?.saveData()" />
<font-awesome-icon :icon="['fas', 'file-export']" class="icon" @mousedown="downloadMdData()" />
Expand All @@ -147,7 +152,8 @@ onMounted(async () => {
<MdOutline :md-data="mdData" :name="name" v-show="isRightbarShow" :key="updateStatus" />
</Transition>
<Editor :md-data="mdData" :lock="lockState" @update:md-data="updateMdData" @on-edit="emits('save', false)"
ref="editor" />
@tag="handleShowTagList()" @lock="handleLock()" @export="downloadMdData()" @pdf="exportPdf()"
@outline="handleShowOutline()" ref="editor" />
</div>
<el-skeleton v-else :rows="10" class="md-block-skeleton" animated />
</template>
Expand Down
26 changes: 4 additions & 22 deletions src/components/Markdown/MdLinkExtend.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script setup lang="ts">
import { Link } from '@/md/mdexpr';
import { watch, ref, onMounted, onActivated, computed } from 'vue';
import { watch, ref, onMounted, onActivated } from 'vue';
import { ElEmpty } from 'element-plus';
import PDFViewer from '../MdExtend/PDFViewer.vue';
import VideoViewer from '../MdExtend/VideoViewer.vue';
import AudioViewer from '../MdExtend/AudioViewer.vue';
const props = defineProps<{
link: Link
Expand All @@ -12,16 +11,6 @@ const props = defineProps<{
const url = ref('')
const config = ref<string | null>(null)
const currentComponent = computed(() => {
if (isPDF(url.value)) {
return PDFViewer
} else if (isVideo(url.value)) {
return VideoViewer
} else if (isAudio(url.value)) {
return AudioViewer
}
});
function extractGroups(url: string): [string, string | null] {
const reg = /(.*) (\{.*\})/gm;
const match = reg.exec(url);
Expand All @@ -45,14 +34,6 @@ function isPDF(url: string): boolean {
return (url.endsWith('.pdf') || url.endsWith('.PDF'))
}
function isVideo(url: string): boolean {
return (url.endsWith('.mp4') || url.endsWith('.webm') || url.endsWith('.flv') || url.endsWith('.mkv'))
}
function isAudio(url: string): boolean {
return (url.endsWith('.mp3') || url.endsWith('.wav'))
}
watch(props, () => {
generateURL()
})
Expand All @@ -68,7 +49,8 @@ onActivated(() => {

<template>
<div class="link-extend">
<component :is="currentComponent" :name="props.link.content" :url="url.slice(6)" :config="config" />
<PDFViewer v-if="isPDF(url)" :name="props.link.content" :url="url.slice(6)" :config="config" />
<el-empty v-else description="无法加载的文件类型" />
</div>
</template>

Expand Down
57 changes: 0 additions & 57 deletions src/components/MdExtend/AudioViewer.vue

This file was deleted.

58 changes: 0 additions & 58 deletions src/components/MdExtend/VideoViewer.vue

This file was deleted.

10 changes: 0 additions & 10 deletions src/components/Middlebar/Database.vue

This file was deleted.

Loading

0 comments on commit cd5bbda

Please sign in to comment.