This commit is contained in:
2025-09-27 22:57:59 +08:00
parent 8a458ff0a4
commit ed26244cdb
12585 changed files with 1914308 additions and 3474 deletions

View File

@@ -1,6 +1,8 @@
"use strict";
const common_vendor = require("../common/vendor.js");
const common_http = require("../common/http.js");
const common_config = require("../common/config.js");
const common_assets = require("../common/assets.js");
const ITEM_SIZE = 210;
const GAP = 18;
const COLS = 3;
@@ -25,6 +27,14 @@ const _sfc_main = {
areaHeight() {
const rows = Math.ceil((this.innerList.length + 1) / COLS) || 1;
return rows * ITEM_SIZE + (rows - 1) * GAP;
},
adderStyle() {
const index = this.innerList.length;
const row = Math.floor(index / COLS);
const col = index % COLS;
const x = px(col * (ITEM_SIZE + GAP));
const y = px(row * (ITEM_SIZE + GAP));
return { left: x + "rpx", top: y + "rpx" };
}
},
watch: {
@@ -33,7 +43,7 @@ const _sfc_main = {
handler(list) {
const mapped = (list || []).map((u, i) => ({
uid: String(i) + "_" + (u.id || u.url || Math.random().toString(36).slice(2)),
url: typeof u === "string" ? u : u.url || "",
url: this.ensureAbsoluteUrl(typeof u === "string" ? u : u.url || ""),
x: this.posOf(i).x,
y: this.posOf(i).y
}));
@@ -42,6 +52,14 @@ const _sfc_main = {
}
},
methods: {
ensureAbsoluteUrl(u) {
if (!u)
return "";
const s = String(u);
if (s.startsWith("http://") || s.startsWith("https://"))
return s;
return common_config.API_BASE_URL + (s.startsWith("/") ? s : "/" + s);
},
posOf(index) {
const row = Math.floor(index / COLS);
const col = index % COLS;
@@ -75,7 +93,7 @@ const _sfc_main = {
var _a;
try {
const resp = await common_http.upload(this.uploadPath, filePath, this.formData, this.uploadFieldName);
const url = (resp == null ? void 0 : resp.url) || ((_a = resp == null ? void 0 : resp.data) == null ? void 0 : _a.url) || (resp == null ? void 0 : resp.path) || "";
const url = this.ensureAbsoluteUrl((resp == null ? void 0 : resp.url) || ((_a = resp == null ? void 0 : resp.data) == null ? void 0 : _a.url) || (resp == null ? void 0 : resp.path) || "");
if (!url)
throw new Error("上传响应无 url");
this.innerList.push({ uid: Math.random().toString(36).slice(2), url, ...this.posOf(this.innerList.length) });
@@ -131,12 +149,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
i: common_vendor.o(($event) => $options.onMoveEnd(index), img.uid)
};
}),
b: $data.innerList.length < $props.max
b: common_assets._imports_0$4,
c: $data.innerList.length < $props.max
}, $data.innerList.length < $props.max ? {
c: common_vendor.o((...args) => $options.choose && $options.choose(...args))
d: common_vendor.s($options.adderStyle),
e: common_vendor.o((...args) => $options.choose && $options.choose(...args))
} : {}, {
d: $options.areaHeight + "rpx",
e: $options.areaHeight + "rpx"
f: $options.areaHeight + "rpx",
g: $options.areaHeight + "rpx"
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);