@mapomodule/uikit 2.0.0-beta.6 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/MapoListTable.vue +1 -1
- package/dist/runtime/stores/media.d.ts.map +1 -1
- package/dist/runtime/stores/media.js +7 -1
- package/package.json +1 -1
- package/src/runtime/components/MapoListTable.vue +1 -1
- package/src/runtime/stores/media.ts +22 -2
package/dist/module.json
CHANGED
|
@@ -615,7 +615,7 @@ const sortingOptions = computed(() => ({
|
|
|
615
615
|
<UPagination
|
|
616
616
|
:model-value="pagination.pageIndex + 1"
|
|
617
617
|
:total="total"
|
|
618
|
-
:page
|
|
618
|
+
:items-per-page="pagination.pageSize"
|
|
619
619
|
size="sm"
|
|
620
620
|
@update:model-value="
|
|
621
621
|
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/runtime/stores/media.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/runtime/stores/media.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EAEX,kBAAkB,EAClB,kBAAkB,EAGlB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBAKxB,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;eAmEN,OAAO;uBACC,OAAO;iBACb,OAAO;;uBAkD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IAAI,CAAC;uBAalC,IAAI;oBAIL,MAAM,GAAG,SAAS,KAAG,IAAI;yBAId,SAAS,KAAG,OAAO,CAAC,SAAS,CAAC;2BAcrD,MAAM,QACT,IAAI,4BAET,OAAO,CAAC,SAAS,CAAC;mCAgBX,OAAO,CAAC,WAAW,CAAC,KAC3B,OAAO,CAAC,IAAI,CAAC;2BAYoB,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;yBAY7B,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC;oBAapC,SAAS,KAAG,IAAI;6BAkBP,UAAU,KAAG,IAAI;0BAKpB,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,KAAG,IAAI;qBAI1C,MAAM,GAAG,MAAM,EAAE,KAAG,IAAI;yBAUtB,IAAI;0BAWG,OAAO,CAAC,IAAI,CAAC;2BAiBnC,kBAAkB,eACd,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,KACrC,OAAO,CAAC,SAAS,CAAC;wBAsCM,MAAM,GAAG,IAAI,KAAG,IAAI;yBAKnB,MAAM,GAAG,IAAI,KAAG,IAAI;iBAK9B,IAAI;wUA0DtB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
|
|
|
2
2
|
import { ref, computed, shallowRef } from "vue";
|
|
3
3
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
4
4
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
5
|
+
import { normalizeEndpoint } from "@mapomodule/utils";
|
|
5
6
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
6
7
|
import { applyMultipartPolicy } from "@mapomodule/core/runtime/api/multipart";
|
|
7
8
|
import { useNuxtApp, useRuntimeConfig } from "#app";
|
|
@@ -13,6 +14,11 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
13
14
|
media: mediaConfig.endpoints?.media ?? "/api/media",
|
|
14
15
|
folders: mediaConfig.endpoints?.folders ?? "/api/media-folders"
|
|
15
16
|
};
|
|
17
|
+
function uploadUrl() {
|
|
18
|
+
const app = runtimeConfig.app;
|
|
19
|
+
const base = (app?.baseURL ?? "/").replace(/\/+$/, "");
|
|
20
|
+
return `${base}${normalizeEndpoint(endpoints.media)}`;
|
|
21
|
+
}
|
|
16
22
|
function adapter() {
|
|
17
23
|
const nuxt = useNuxtApp();
|
|
18
24
|
return nuxt.$mapoMediaAdapter ?? defaultMediaAdapter;
|
|
@@ -235,7 +241,7 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
235
241
|
const formData = applyMultipartPolicy(body, "force");
|
|
236
242
|
return await new Promise((resolve, reject) => {
|
|
237
243
|
const xhr = new XMLHttpRequest();
|
|
238
|
-
xhr.open("POST",
|
|
244
|
+
xhr.open("POST", uploadUrl());
|
|
239
245
|
xhr.responseType = "json";
|
|
240
246
|
if (onProgress) {
|
|
241
247
|
xhr.upload.addEventListener("progress", (event) => {
|
package/package.json
CHANGED
|
@@ -871,7 +871,7 @@ const sortingOptions = computed(() => ({
|
|
|
871
871
|
<UPagination
|
|
872
872
|
:model-value="pagination.pageIndex + 1"
|
|
873
873
|
:total="total"
|
|
874
|
-
:page
|
|
874
|
+
:items-per-page="pagination.pageSize"
|
|
875
875
|
size="sm"
|
|
876
876
|
@update:model-value="
|
|
877
877
|
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
|
|
|
2
2
|
import { ref, computed, shallowRef } from "vue";
|
|
3
3
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
4
4
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
5
|
+
import { normalizeEndpoint } from "@mapomodule/utils";
|
|
5
6
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
6
7
|
import { applyMultipartPolicy } from "@mapomodule/core/runtime/api/multipart";
|
|
7
8
|
import { useNuxtApp, useRuntimeConfig } from "#app";
|
|
@@ -28,6 +29,24 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
28
29
|
folders: mediaConfig.endpoints?.folders ?? "/api/media-folders",
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Absolute-from-origin URL for the upload POST.
|
|
34
|
+
*
|
|
35
|
+
* Every other media request goes through `useCrud` → `$mapoFetch`, which
|
|
36
|
+
* inherits `baseURL: app.baseURL` from Nuxt's global `$fetch`. The upload has
|
|
37
|
+
* to use XHR (ofetch exposes no upload-progress hook), so it must reproduce
|
|
38
|
+
* that resolution itself: `normalizeEndpoint` for the path (same call
|
|
39
|
+
* `useCrud` makes) plus the app base. Skipping the base made the upload the
|
|
40
|
+
* only request to miss it, so on a sub-path deployment it bypassed server
|
|
41
|
+
* middleware mounted under that base — including the proxy that attaches
|
|
42
|
+
* `X-CSRFToken`, hence 403s on session-authenticated backends.
|
|
43
|
+
*/
|
|
44
|
+
function uploadUrl(): string {
|
|
45
|
+
const app = runtimeConfig.app as { baseURL?: string } | undefined;
|
|
46
|
+
const base = (app?.baseURL ?? "/").replace(/\/+$/, "");
|
|
47
|
+
return `${base}${normalizeEndpoint(endpoints.media)}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
31
50
|
// Adapter: backend-specific request/response transforms. Provided by a plugin
|
|
32
51
|
// ($mapoMediaAdapter); falls back to plain REST when none is registered.
|
|
33
52
|
function adapter(): MediaAdapter {
|
|
@@ -343,10 +362,11 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
343
362
|
const formData = applyMultipartPolicy(body, "force") as FormData;
|
|
344
363
|
|
|
345
364
|
// ofetch has no upload-progress hook, so uploads go through XHR.
|
|
346
|
-
// Same-origin request: the session cookie is attached automatically
|
|
365
|
+
// Same-origin request: the session cookie is attached automatically, and
|
|
366
|
+
// `uploadUrl()` keeps the target identical to the one `useCrud` would hit.
|
|
347
367
|
return await new Promise<MediaItem>((resolve, reject) => {
|
|
348
368
|
const xhr = new XMLHttpRequest();
|
|
349
|
-
xhr.open("POST",
|
|
369
|
+
xhr.open("POST", uploadUrl());
|
|
350
370
|
xhr.responseType = "json";
|
|
351
371
|
if (onProgress) {
|
|
352
372
|
xhr.upload.addEventListener("progress", (event) => {
|