Skip to content

Commit

Permalink
new: pptx support and rename to office-pack
Browse files Browse the repository at this point in the history
  • Loading branch information
imzlh committed Oct 5, 2024
1 parent 16a8244 commit 770a4ab
Show file tree
Hide file tree
Showing 12 changed files with 93,466 additions and 32 deletions.
11 changes: 11 additions & 0 deletions public/app/office.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions public/app/ppt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/module/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
if(import.meta.env.DEV) console.debug = console.info;
console.clear = () => {logs.splice(0, logs.length), objCache.splice(0, objCache.length)};
document.addEventListener('DOMContentLoaded', () => console.info(`%c${name} V${version}`, 'color: #2cae61; padding: .5rem 1rem; background-color: #d5f9ff;'));
window.addEventListener('error', (event) => logs.push({ type: 'error', message: event.message, time: new Date().toLocaleString(), trace: event.error.stack.split('\n').slice(1) }));
window.addEventListener('error', (event) => logs.push({ type: 'error', message: event.message, time: new Date().toLocaleString(), trace: event.error?.stack.split('\n').slice(1) }));
window.addEventListener('unhandledrejection', (event) => logs.push({ type: 'error', message: event.reason, time: new Date().toLocaleString(), trace: event.reason?.stack?.split('\n').slice(1) }));
</script>

Expand Down
45 changes: 17 additions & 28 deletions src/opener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import I_ASCIINEMA from '/app/asciinema.svg';
import I_NOTES from '/app/notes.webp';
import I_WORD from '/app/word.svg';
import I_EXCEL from '/app/excel.svg';
import I_PPT from '/app/ppt.svg';
import I_OFFICE from '/app/office.svg';

export const OPENER:Array<OpenerOption> = [
// Monaco-Editor(VsCode)
Expand Down Expand Up @@ -78,40 +80,27 @@ export const OPENER:Array<OpenerOption> = [
});
},
},
// docx-previewer
// @link https://github.com/kavya-5/docx-previewer
// office pack
// Copyright(C) 2024 izGroup
{
"name": "Docx Viewer",
"type": "text/docx",
"typeDesc": "在线读取和预览docx文档",
"icon": I_WORD,
"name": "Office Pack",
"type": "application/vnd.ms-office",
"typeDesc": "在线预览Word/Excel/PowerPoint文档",
"icon": I_OFFICE,
"format": [
"xlsx",
"pptx",
"docx"
],
async open(file) {
createWindow({
"content": (await import('@/opener/docx.vue')).default,
"icon": I_WORD,
"name": file.name + " - Docx Viewer",
"option": file
});
},
},
// x-spreadsheet
// @link https://github.com/myliang/x-spreadsheet
{
"name": "Light Excel",
"type": "text/sheet",
"typeDesc": "在线编辑、预览Excel表格",
"icon": I_EXCEL,
"format": [
"xlsx"
],
async open(file) {
createWindow({
"content": (await import('@/opener/xlsx.vue')).default,
"icon": I_EXCEL,
"name": file.name + " - Excel",
"content": (await import('@/opener/office.vue')).default,
"icon": ({
'docx': I_WORD,
'xlsx': I_EXCEL,
'pptx': I_PPT
})[splitPath(file).ext] || I_OFFICE,
"name": file.name + " - Office",
"option": file
});
}
Expand Down
18 changes: 18 additions & 0 deletions src/opener/office.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script lang="ts" setup>
import Xlsx from './office/xlsx.vue';
import Docx from './office/docx.vue';
import Pptx from './office/pptx.vue';
import type { vFile } from '@/env';
import { splitPath } from '@/utils';
const _prop = defineProps(['option']),
file = _prop.option as vFile,
ext = splitPath(file).ext;
</script>

<template>
<Xlsx v-if="ext === 'xlsx'" :option="file" />
<Docx v-else-if="ext === 'docx'" :option="file" />
<Pptx v-else-if="ext === 'pptx'" :option="file" />
<div v-else vs-icon="warning" inline>不支持该格式文件</div>
</template>
File renamed without changes.
Loading

0 comments on commit 770a4ab

Please sign in to comment.