Files
Docwell/Web-App/frontend/src/app.ts
T
tajniak81andClaude Opus 5.5 c98b127f1e
CI / go (Media) (push) Successful in 13m40s
CI / go (Server) (push) Failing after 23m20s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 10m35s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Failing after 3h4m42s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / mobile (push) Failing after 9m19s
CI / docker (push) Successful in 2h2m57s
Add columns, suggesting mode, verified pages, scanned PDF search and server translations
- Columns: /columns puts 2 to 4 columns side by side, with widths dragged
  between them; they stack on phones. HTML export and import keep them
  (also Notion column lists and Confluence page layouts).
- Suggesting mode: edits become suggested insertions and deletions that
  editors accept or reject one by one or all at once. Text only.
- Verified pages: editors verify a page for a while or without end; the
  verifier is notified when it runs out (migration 1764700000).
- Scanned PDFs attached to pages are read by AI for search where a
  workspace turns it on.
- The server writes error messages, emails, digests and phone
  notifications in English, Polish, German, French and Spanish; the apps
  send their language with each request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 08:38:08 +01:00

55 lines
1.9 KiB
TypeScript

// SPDX-License-Identifier: AGPL-3.0-or-later
import { createClient, createTokenStore } from "@docwell/api-client";
import { createPinia } from "pinia";
import { createApp } from "vue";
import App from "./App.vue";
import { apiKey, tokenKey } from "./api";
import { sendCommand } from "./lib/commands";
import { createDocwellI18n } from "./i18n";
import { configKey, platformKey, type Platform } from "./platform";
import { createDocwellRouter } from "./router";
import { useAuthStore } from "./stores/auth";
/** Builds and mounts the Docwell app for the given host platform. */
export async function createDocwellApp(platform: Platform, el: string | Element = "#app") {
const config = await platform.loadConfig();
const app = createApp(App);
const pinia = createPinia();
app.use(pinia);
const tokens = platform.tokenStore ? await platform.tokenStore() : createTokenStore();
const router = createDocwellRouter(platform);
const auth = useAuthStore(pinia);
const i18n = createDocwellI18n();
const api = createClient({
baseUrl: config.apiUrl,
token: tokens.get,
locale: () => i18n.global.locale.value,
onUnauthorized: () => {
auth.clear();
// During start-up the router guard decides where to go; public pages
// (sign-up, password reset) stay put when an old token is rejected.
const current = router.currentRoute.value;
if (auth.ready && !current.meta.public) {
router.push({ name: "login", query: { redirect: current.fullPath } });
}
},
});
auth.attach(api, tokens);
app.provide(platformKey, platform);
app.provide(configKey, config);
app.provide(apiKey, api);
app.provide(tokenKey, tokens.get);
app.use(i18n);
app.use(router);
app.mount(el);
platform.onOpenRoute?.((route) => void router.push(route));
platform.onCommand?.(sendCommand);
return app;
}
export type { AppCommand, Platform, RuntimeConfig, ServerEntry, ServerHost, TokenStore } from "./platform";