Migrate to Euro-Office and refresh the editor home experience.
Swap Document Server to Euro-Office, add blank-document creation, and restyle the app with an Office-like light/dark theme and compact editor toolbar. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5ac6281304
commit
0800fc8571
27 files changed
+735
-394
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { isHwp, isOffice } from '@/config/app';
|
||||
import {
|
||||
createBlankDocument,
|
||||
createSession,
|
||||
fetchDocumentContent,
|
||||
uploadDocument,
|
||||
type BlankDocumentType,
|
||||
} from '@/api/client';
|
||||
import {
|
||||
storeHwpBuffer,
|
||||
storeHwpFile,
|
||||
} from '@/composables/useSessionLifecycle';
|
||||
|
||||
export function useOpenDocument() {
|
||||
const router = useRouter();
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
async function openDocument(file: File | undefined): Promise<boolean> {
|
||||
if (!file || busy.value) return false;
|
||||
error.value = '';
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
if (isHwp(file.name)) {
|
||||
await storeHwpFile(file);
|
||||
await createSession().catch(() => undefined);
|
||||
await router.push({ name: 'rhwp-editor' });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isOffice(file.name)) {
|
||||
error.value =
|
||||
'지원하지 않는 형식입니다. docx, xlsx, pptx, pdf, hwp, hwpx 등을 올려 주세요.';
|
||||
return false;
|
||||
}
|
||||
|
||||
await createSession();
|
||||
const { docId } = await uploadDocument(file);
|
||||
await router.push({ name: 'onlyoffice-editor', params: { docId } });
|
||||
return true;
|
||||
} catch (err) {
|
||||
error.value =
|
||||
err instanceof Error ? err.message : '파일을 열 수 없습니다.';
|
||||
return false;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function createAndOpenBlank(type: BlankDocumentType): Promise<boolean> {
|
||||
if (busy.value) return false;
|
||||
error.value = '';
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
await createSession();
|
||||
const doc = await createBlankDocument(type);
|
||||
|
||||
if (type === 'hwpx') {
|
||||
const buffer = await fetchDocumentContent(doc.docId, doc.token);
|
||||
storeHwpBuffer(doc.filename, buffer);
|
||||
await router.push({ name: 'rhwp-editor' });
|
||||
return true;
|
||||
}
|
||||
|
||||
await router.push({
|
||||
name: 'onlyoffice-editor',
|
||||
params: { docId: doc.docId },
|
||||
});
|
||||
return true;
|
||||
} catch (err) {
|
||||
error.value =
|
||||
err instanceof Error ? err.message : '새 문서를 만들 수 없습니다.';
|
||||
return false;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
return { busy, error, openDocument, createAndOpenBlank };
|
||||
}
|
||||
Reference in new issue
Block a user