Open Craft editors in standalone tabs and improve addon settings
This commit is contained in:
1 parent
5cb1b463ea
commit
bc9709e500
16 files changed
+277
-162
No files matched your search
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
Для HTML, JS и WASM создаются gzip-копии; корректные MIME, CSP для WASM и same-origin iframe задаются только страницам аддонов. Основная CSP File Browser не ослабляется. Старые версии остаются на диске: открытые редакторы продолжают загружать свои файлы. Удалять старые версии и оставшиеся после аварийной остановки `.install-*` можно вручную при остановленном сервере. Каталог `addons` закрыт от чтения/изменения через обычный файловый API, включая псевдонимы через ссылки и операции над родительскими папками.
|
||||
|
||||
В ПКМ и панели предпросмотра появляется «Открыть в GridCraft/PdfCraft». В «Создать» — XLSX/PDF, если соответствующий аддон установлен и включён; сервер генерирует корректные пустые документы. Предпросмотр PDF остаётся прежним быстрым просмотрщиком.
|
||||
В ПКМ и панели предпросмотра появляется «Открыть в GridCraft/PdfCraft». В «Создать» — XLSX/PDF, если соответствующий аддон установлен и включён; сервер генерирует корректные пустые документы. Двойной клик по PDF/XLSX сразу открывает включённый установленный редактор в отдельной вкладке без панелей File Browser. Команда «Открыть в…» и создание документов также открывают отдельную вкладку. Для остальных файлов сохраняется обычное открытие.
|
||||
|
||||
Обмен идёт через официальный `?host=parent`/`postMessage`: проверяются origin и конкретное окно iframe. Данные передаются без токенов SSO. Файлы загружаются и сохраняются через собственный API File Browser, с проверкой области доступа, правил и текущих разрешений. Размер документа ограничен 64 МиБ; XLSX дополнительно ограничен 4096 записями и суммарно 256 МиБ заявленного распакованного содержимого. Одновременно обрабатываются не более двух запросов документов.
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
v-if="tool"
|
||||
icon="edit_note"
|
||||
:label="t('addons.openWith', { name: tool.name })"
|
||||
@action="router.push({ path: file!.url, query: { craft: tool!.id } })"
|
||||
@action="openCraftTab(router, tool!.id, file!.url)"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { openCraftTab } from "@/utils/craft";
|
||||
import { computed, onMounted } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -21,7 +22,10 @@ const store = useAddonsStore(),
|
||||
router = useRouter(),
|
||||
{ t } = useI18n();
|
||||
const tool = computed(() =>
|
||||
!props.file?.isDir && auth.user?.perm.download && auth.user?.perm.modify
|
||||
props.file &&
|
||||
!props.file.isDir &&
|
||||
auth.user?.perm.download &&
|
||||
auth.user?.perm.modify
|
||||
? store.items.find(
|
||||
(item) =>
|
||||
item.enabled &&
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useAddonsStore } from "@/stores/addons";
|
||||
import { openCraftTab } from "@/utils/craft";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useFileStore } from "@/stores/file";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
@@ -87,6 +89,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const addons = useAddonsStore();
|
||||
const fileStore = useFileStore();
|
||||
const layoutStore = useLayoutStore();
|
||||
|
||||
@@ -327,9 +330,12 @@ const click = (event: Event | KeyboardEvent) => {
|
||||
touches.value = 0;
|
||||
}, 300);
|
||||
|
||||
touches.value++;
|
||||
if (touches.value > 1) {
|
||||
open();
|
||||
if (!(event instanceof MouseEvent) || event.button === 0) {
|
||||
touches.value++;
|
||||
if (touches.value > 1) {
|
||||
touches.value = 0;
|
||||
open();
|
||||
}
|
||||
}
|
||||
|
||||
if (fileStore.selected.indexOf(props.index) !== -1) {
|
||||
@@ -377,6 +383,22 @@ const click = (event: Event | KeyboardEvent) => {
|
||||
};
|
||||
|
||||
const open = () => {
|
||||
const tool =
|
||||
!props.readOnly &&
|
||||
!props.isDir &&
|
||||
authStore.user?.perm.modify &&
|
||||
authStore.user?.perm.download
|
||||
? addons.items.find(
|
||||
(item) =>
|
||||
item.enabled &&
|
||||
item.build &&
|
||||
props.name.toLowerCase().endsWith(item.extension)
|
||||
)
|
||||
: undefined;
|
||||
if (tool) {
|
||||
openCraftTab(router, tool.id, props.url);
|
||||
return;
|
||||
}
|
||||
router.push({ path: props.url });
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { craftLocation } from "@/utils/craft";
|
||||
import { computed, inject, ref, watch } from "vue";
|
||||
import { fileTemplate, templateFileName } from "@/utils/file-templates";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -88,8 +89,12 @@ const submit = async (event: Event) => {
|
||||
uri += encodeURIComponent(fullName.value);
|
||||
uri = uri.replace("//", "/");
|
||||
|
||||
let editorTab: Window | null = null;
|
||||
try {
|
||||
if (template.value.craft) {
|
||||
editorTab = window.open("about:blank", "_blank");
|
||||
if (!editorTab) throw new Error(t("addons.popupBlocked"));
|
||||
editorTab.opener = null;
|
||||
await fetchURL(
|
||||
"/api/craft/" +
|
||||
template.value.craft +
|
||||
@@ -102,16 +107,19 @@ const submit = async (event: Event) => {
|
||||
uri,
|
||||
new Blob([template.value.content], { type: "text/plain;charset=utf-8" })
|
||||
);
|
||||
await router.push({
|
||||
path: uri,
|
||||
query: template.value.craft
|
||||
? { craft: template.value.craft }
|
||||
: template.value.id === "other"
|
||||
? {}
|
||||
: { edit: "true" },
|
||||
});
|
||||
if (template.value.craft && editorTab) {
|
||||
editorTab.location.replace(
|
||||
router.resolve(craftLocation(template.value.craft, uri)).href
|
||||
);
|
||||
fileStore.reload = true;
|
||||
} else
|
||||
await router.push({
|
||||
path: uri,
|
||||
query: template.value.id === "other" ? {} : { edit: "true" },
|
||||
});
|
||||
layoutStore.closeHovers();
|
||||
} catch (e) {
|
||||
editorTab?.close();
|
||||
if (e instanceof Error) {
|
||||
$showError(e);
|
||||
}
|
||||
|
||||
@@ -3,40 +3,51 @@
|
||||
<h2><AppIcon name="package" />{{ t("addons.title") }}</h2>
|
||||
<p class="field-hint">{{ t("addons.description") }}</p>
|
||||
<p v-if="error" class="document-error" role="alert">{{ error }}</p>
|
||||
<div v-for="addon in store.items" :key="addon.id" class="addon-row">
|
||||
<div>
|
||||
<strong>{{ addon.name }}</strong
|
||||
><small
|
||||
>{{ addon.version || t("addons.notInstalled") }} ·
|
||||
{{ addon.extension }}</small
|
||||
><small v-if="busy(addon)"
|
||||
>{{ t("addons.states." + addon.state)
|
||||
}}<template v-if="addon.total">
|
||||
·
|
||||
{{ Math.round((addon.downloaded / addon.total) * 100) }}%</template
|
||||
></small
|
||||
><small v-if="addon.error" role="alert" class="document-error">{{
|
||||
addon.error
|
||||
}}</small>
|
||||
</div>
|
||||
<label v-if="addon.build" class="addon-enabled"
|
||||
><input
|
||||
type="checkbox"
|
||||
:checked="addon.enabled"
|
||||
:disabled="changing === addon.id"
|
||||
@change="toggle(addon, ($event.target as HTMLInputElement).checked)"
|
||||
/>{{ t("addons.enabled") }}</label
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="button"
|
||||
:disabled="busy(addon) || changing === addon.id"
|
||||
@click="install(addon)"
|
||||
>
|
||||
<AppIcon :name="addon.build ? 'refresh' : 'download'" />{{
|
||||
addon.build ? t("addons.update") : t("addons.install")
|
||||
}}
|
||||
</button>
|
||||
<div class="addon-grid">
|
||||
<article v-for="addon in store.items" :key="addon.id" class="addon-card">
|
||||
<div class="addon-details">
|
||||
<AppIcon :name="addon.id === 'gridcraft' ? 'table' : 'description'" />
|
||||
<div>
|
||||
<strong>{{ addon.name }}</strong
|
||||
><small
|
||||
>{{ addon.version || t("addons.notInstalled") }} ·
|
||||
{{ addon.extension }}</small
|
||||
><small v-if="busy(addon)"
|
||||
>{{ t("addons.states." + addon.state)
|
||||
}}<template v-if="addon.total">
|
||||
·
|
||||
{{
|
||||
Math.round((addon.downloaded / addon.total) * 100)
|
||||
}}%</template
|
||||
></small
|
||||
><small v-if="addon.error" role="alert" class="document-error">{{
|
||||
addon.error
|
||||
}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="addon-controls">
|
||||
<label v-if="addon.build" class="settings-toggle"
|
||||
><span>{{ t("addons.enabled") }}</span
|
||||
><input
|
||||
type="checkbox"
|
||||
:checked="addon.enabled"
|
||||
:disabled="changing === addon.id"
|
||||
@change="
|
||||
toggle(addon, ($event.target as HTMLInputElement).checked)
|
||||
"
|
||||
/></label>
|
||||
<button
|
||||
type="button"
|
||||
class="button"
|
||||
:disabled="busy(addon) || changing === addon.id"
|
||||
@click="install(addon)"
|
||||
>
|
||||
<AppIcon :name="addon.build ? 'refresh' : 'download'" />{{
|
||||
addon.build ? t("addons.update") : t("addons.install")
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<p class="field-hint">{{ t("addons.directory") }} <code>./addons</code></p>
|
||||
</section>
|
||||
|
||||
@@ -389,38 +389,62 @@
|
||||
padding: 14px;
|
||||
}
|
||||
}
|
||||
.addon-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.addons-settings .addon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
|
||||
gap: 16px;
|
||||
padding: 16px 0;
|
||||
border-top: 1px solid var(--borderPrimary);
|
||||
margin: 20px 0;
|
||||
}
|
||||
.addon-row > div {
|
||||
flex: 1;
|
||||
.addons-settings .addon-card {
|
||||
min-width: 0;
|
||||
padding: 20px;
|
||||
border: 1px solid var(--borderPrimary);
|
||||
border-radius: 14px;
|
||||
background: var(--surfaceSecondary);
|
||||
}
|
||||
.addon-row strong,
|
||||
.addon-row small {
|
||||
.addon-details {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: start;
|
||||
}
|
||||
.addon-details > .app-icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
flex-shrink: 0;
|
||||
color: var(--blue);
|
||||
}
|
||||
.addon-details > div {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.addon-details strong,
|
||||
.addon-details small {
|
||||
display: block;
|
||||
}
|
||||
.addon-row small {
|
||||
margin-top: 5px;
|
||||
font-size: 12px;
|
||||
color: var(--textSecondary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.addon-enabled {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
.addon-details small {
|
||||
margin-top: 6px;
|
||||
color: var(--textSecondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.addon-row .button {
|
||||
.addons-settings .addon-controls {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.addons-settings .addon-controls .settings-toggle {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.addon-controls .button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
margin: 0;
|
||||
}
|
||||
.craft-editor {
|
||||
position: fixed;
|
||||
@@ -428,7 +452,7 @@
|
||||
z-index: 9000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 64px;
|
||||
padding: 0;
|
||||
background: var(--background);
|
||||
}
|
||||
.craft-frame {
|
||||
@@ -476,17 +500,32 @@
|
||||
width: 100%;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.craft-feedback {
|
||||
position: absolute;
|
||||
bottom: 16px;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
z-index: 2;
|
||||
max-height: 60vh;
|
||||
overflow: auto;
|
||||
background: var(--surfacePrimary);
|
||||
border: 1px solid var(--borderPrimary);
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 8px 32px #0003;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.addon-row {
|
||||
flex-wrap: wrap;
|
||||
.addons-settings .addon-card {
|
||||
padding: 16px;
|
||||
}
|
||||
.addon-row > div {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.addon-row .button {
|
||||
margin-inline-start: auto;
|
||||
.addon-controls .button {
|
||||
flex: 1;
|
||||
}
|
||||
.craft-status {
|
||||
gap: 8px;
|
||||
}
|
||||
.craft-feedback {
|
||||
bottom: 8px;
|
||||
left: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
}
|
||||
@@ -415,6 +415,7 @@
|
||||
"pdf": "PDF document"
|
||||
},
|
||||
"addons": {
|
||||
"popupBlocked": "Allow new tabs in your browser.",
|
||||
"title": "Addons",
|
||||
"description": "Editors run in your browser. Install official Artcraft releases with SHA-256 verification.",
|
||||
"notInstalled": "Not installed",
|
||||
|
||||
@@ -412,6 +412,7 @@
|
||||
"pdf": "Документ PDF"
|
||||
},
|
||||
"addons": {
|
||||
"popupBlocked": "Разрешите открытие новых вкладок в браузере.",
|
||||
"title": "Аддоны",
|
||||
"description": "Редакторы работают в браузере. Установка и обновление — из официальных релизов Artcraft с проверкой SHA-256.",
|
||||
"notInstalled": "Не установлен",
|
||||
|
||||
@@ -16,6 +16,7 @@ import i18n from "@/i18n";
|
||||
import { validateLogin } from "@/utils/auth";
|
||||
|
||||
const titles = {
|
||||
CraftEditor: "addons.title",
|
||||
Login: "sidebar.login",
|
||||
Share: "buttons.share",
|
||||
Files: "files.files",
|
||||
@@ -31,6 +32,12 @@ const titles = {
|
||||
};
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/editor/:addon(gridcraft|pdfcraft)",
|
||||
name: "CraftEditor",
|
||||
component: () => import("@/views/files/CraftEditor.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
name: "Login",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { craftMessage, safeCraftName } from "../craft";
|
||||
import { craftLocation, craftMessage, safeCraftName } from "../craft";
|
||||
it("accepts messages only from the specific same-origin editor frame", () => {
|
||||
const frame = {} as Window,
|
||||
origin = "https://files.test";
|
||||
@@ -56,3 +56,13 @@ it("validates save-as filenames without allowing paths or another file type", ()
|
||||
])
|
||||
expect(safeCraftName(name, ".xlsx")).toBeNull();
|
||||
});
|
||||
|
||||
it("preserves encoded names in standalone editor links", () => {
|
||||
const location = craftLocation(
|
||||
"gridcraft",
|
||||
"/files/folder%20name/report%20%231%25.xlsx"
|
||||
);
|
||||
expect(location.name).toBe("CraftEditor");
|
||||
expect(location.query.path).toBe("/folder name/report #1%.xlsx");
|
||||
expect(location.params.addon).toBe("gridcraft");
|
||||
});
|
||||
@@ -1,3 +1,20 @@
|
||||
import type { Router } from "vue-router";
|
||||
|
||||
export function craftLocation(id: string, fileURL: string) {
|
||||
return {
|
||||
name: "CraftEditor",
|
||||
params: { addon: id },
|
||||
query: { path: decodeURIComponent(fileURL.replace(/^\/files/, "")) },
|
||||
};
|
||||
}
|
||||
export function openCraftTab(router: Router, id: string, fileURL: string) {
|
||||
window.open(
|
||||
router.resolve(craftLocation(id, fileURL)).href,
|
||||
"_blank",
|
||||
"noopener,noreferrer"
|
||||
);
|
||||
}
|
||||
|
||||
export function safeCraftName(name: unknown, extension: string): string | null {
|
||||
if (
|
||||
typeof name !== "string" ||
|
||||
|
||||
@@ -1,72 +1,68 @@
|
||||
<template>
|
||||
<div class="craft-editor">
|
||||
<header-bar
|
||||
><Action
|
||||
icon="close"
|
||||
:label="t('buttons.close')"
|
||||
@action="close"
|
||||
/><title>{{ currentName }}</title></header-bar
|
||||
>
|
||||
<div class="craft-status" role="status">
|
||||
<strong>{{ title }}</strong
|
||||
><span>{{
|
||||
saving
|
||||
? t("addons.saving")
|
||||
: pending
|
||||
? t("addons.unsaved")
|
||||
: frameDirty
|
||||
<div v-if="pending || error || saving || saveAs" class="craft-feedback">
|
||||
<div class="craft-status" role="status">
|
||||
<strong>{{ title }}</strong
|
||||
><span>{{
|
||||
saving
|
||||
? t("addons.saving")
|
||||
: pending
|
||||
? t("addons.unsaved")
|
||||
: status
|
||||
}}</span
|
||||
><button
|
||||
v-if="pending && !saveAs && !saving"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="persist"
|
||||
>
|
||||
{{ t("addons.retrySave") }}</button
|
||||
><button
|
||||
v-if="pending && !saveAs && !saving"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="
|
||||
newName = pending.name;
|
||||
saveAs = true;
|
||||
"
|
||||
>
|
||||
{{ t("addons.saveAs") }}</button
|
||||
><button
|
||||
v-if="pending"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="downloadCopy"
|
||||
>
|
||||
{{ t("addons.downloadCopy") }}
|
||||
</button>
|
||||
: frameDirty
|
||||
? t("addons.unsaved")
|
||||
: status
|
||||
}}</span
|
||||
><button
|
||||
v-if="pending && !saveAs && !saving"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="persist"
|
||||
>
|
||||
{{ t("addons.retrySave") }}</button
|
||||
><button
|
||||
v-if="pending && !saveAs && !saving"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="
|
||||
newName = pending.name;
|
||||
saveAs = true;
|
||||
"
|
||||
>
|
||||
{{ t("addons.saveAs") }}</button
|
||||
><button
|
||||
v-if="pending"
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="downloadCopy"
|
||||
>
|
||||
{{ t("addons.downloadCopy") }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="error" class="craft-error" role="alert">
|
||||
{{ error }}
|
||||
<a
|
||||
v-if="authExpired"
|
||||
:href="baseURL + '/auth/login'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ t("sidebar.login") }}</a
|
||||
>
|
||||
</p>
|
||||
<form v-if="saveAs" class="craft-save-as" @submit.prevent="confirmSaveAs">
|
||||
<label
|
||||
>{{ t("addons.saveAs")
|
||||
}}<input class="input" v-model.trim="newName" required /></label
|
||||
><button class="button" :disabled="saving">
|
||||
{{ t("buttons.save") }}</button
|
||||
><button
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="saveAs = false"
|
||||
>
|
||||
{{ t("buttons.cancel") }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<p v-if="error" class="craft-error" role="alert">
|
||||
{{ error }}
|
||||
<a
|
||||
v-if="authExpired"
|
||||
:href="baseURL + '/auth/login'"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ t("sidebar.login") }}</a
|
||||
>
|
||||
</p>
|
||||
<form v-if="saveAs" class="craft-save-as" @submit.prevent="confirmSaveAs">
|
||||
<label
|
||||
>{{ t("addons.saveAs")
|
||||
}}<input class="input" v-model.trim="newName" required /></label
|
||||
><button class="button" :disabled="saving">{{ t("buttons.save") }}</button
|
||||
><button
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="saveAs = false"
|
||||
>
|
||||
{{ t("buttons.cancel") }}
|
||||
</button>
|
||||
</form>
|
||||
<iframe
|
||||
v-if="frameURL"
|
||||
ref="frame"
|
||||
@@ -82,15 +78,8 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import {
|
||||
useRoute,
|
||||
useRouter,
|
||||
onBeforeRouteLeave,
|
||||
onBeforeRouteUpdate,
|
||||
} from "vue-router";
|
||||
import { useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import HeaderBar from "@/components/header/HeaderBar.vue";
|
||||
import Action from "@/components/header/Action.vue";
|
||||
import { useFileStore } from "@/stores/file";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useAddonsStore } from "@/stores/addons";
|
||||
@@ -98,17 +87,18 @@ import { baseURL } from "@/utils/constants";
|
||||
import { fetchURL, StatusError } from "@/api/utils";
|
||||
import { craftMessage, safeCraftName } from "@/utils/craft";
|
||||
const route = useRoute(),
|
||||
router = useRouter(),
|
||||
store = useAddonsStore(),
|
||||
files = useFileStore(),
|
||||
auth = useAuthStore(),
|
||||
{ t } = useI18n();
|
||||
// Bind the editor to the file opened at mount; later store navigation must not redirect a save.
|
||||
const file = files.req,
|
||||
id = String(route.query.craft || ""),
|
||||
sourcePath = file?.path || "";
|
||||
id = String(route.params.addon || route.query.craft || ""),
|
||||
sourcePath = route.params.addon
|
||||
? String(route.query.path || "")
|
||||
: file?.path || "";
|
||||
const currentPath = ref(sourcePath),
|
||||
currentName = ref(file?.name || "");
|
||||
currentName = ref(sourcePath.split("/").pop() || "");
|
||||
const title = computed(
|
||||
() => store.items.find((item) => item.id === id)?.name || id
|
||||
);
|
||||
@@ -193,11 +183,6 @@ onBeforeRouteUpdate(mayLeave);
|
||||
function beforeUnload(event: BeforeUnloadEvent) {
|
||||
if (unsaved.value) event.preventDefault();
|
||||
}
|
||||
function close() {
|
||||
router.push({
|
||||
path: file?.url.slice(0, file.url.lastIndexOf("/") + 1) || "/files/",
|
||||
});
|
||||
}
|
||||
async function persist() {
|
||||
const payload = pending.value;
|
||||
if (!payload || saving.value) return;
|
||||
@@ -292,7 +277,7 @@ function receive(event: MessageEvent) {
|
||||
opened = true;
|
||||
clearTimeout(startup);
|
||||
frame.value!.contentWindow!.postMessage(
|
||||
{ type: id + ":open", name: file!.name, bytes: original },
|
||||
{ type: id + ":open", name: currentName.value, bytes: original },
|
||||
window.location.origin,
|
||||
[original]
|
||||
);
|
||||
@@ -340,6 +325,7 @@ onMounted(async () => {
|
||||
window.addEventListener("message", receive);
|
||||
window.addEventListener("beforeunload", beforeUnload);
|
||||
try {
|
||||
document.title = currentName.value;
|
||||
await store.refresh();
|
||||
const addon = store.items.find(
|
||||
(item) => item.id === id && item.enabled && item.build
|
||||
|
||||
@@ -271,6 +271,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useAddonsStore } from "@/stores/addons";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useClipboardStore } from "@/stores/clipboard";
|
||||
import { useFileStore } from "@/stores/file";
|
||||
@@ -318,6 +319,7 @@ const $showError = inject<IToastError>("$showError")!;
|
||||
|
||||
const clipboardStore = useClipboardStore();
|
||||
const authStore = useAuthStore();
|
||||
const addons = useAddonsStore();
|
||||
const fileStore = useFileStore();
|
||||
const layoutStore = useLayoutStore();
|
||||
|
||||
@@ -442,6 +444,7 @@ watch(req, () => {
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (authStore.isLoggedIn) addons.refresh().catch(() => {});
|
||||
// Check the columns size for the first time.
|
||||
columnsResize();
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ const harness = vi.hoisted(() => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("@/stores/addons", () => ({
|
||||
useAddonsStore: () => ({
|
||||
items: [],
|
||||
refresh: vi.fn().mockResolvedValue(undefined),
|
||||
}),
|
||||
}));
|
||||
vi.mock("@/stores/auth", () => ({
|
||||
useAuthStore: () => ({ user: null }),
|
||||
}));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
param([string]$Version = '3.0.0-sso.20')
|
||||
param([string]$Version = '3.0.0-sso.21')
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||
Push-Location $repo
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
VERSION="${VERSION:-3.0.0-sso.20}"
|
||||
VERSION="${VERSION:-3.0.0-sso.21}"
|
||||
COMMIT=$(git rev-parse --short HEAD)
|
||||
(cd frontend && pnpm install --frozen-lockfile && pnpm run build)
|
||||
mkdir -p build/release/linux-amd64
|
||||
|
||||
Reference in new issue
Block a user