9.17/1
This commit is contained in:
@@ -2,18 +2,21 @@
|
||||
const common_vendor = require("./vendor.js");
|
||||
const envBaseUrl = typeof process !== "undefined" && process.env && (process.env.VITE_APP_API_BASE_URL || process.env.API_BASE_URL) || "";
|
||||
const storageBaseUrl = typeof common_vendor.index !== "undefined" ? common_vendor.index.getStorageSync("API_BASE_URL") || "" : "";
|
||||
const fallbackBaseUrl = "http://localhost:8080";
|
||||
const fallbackBaseUrl = "http://192.168.31.193:8080";
|
||||
const API_BASE_URL = (envBaseUrl || storageBaseUrl || fallbackBaseUrl).replace(/\/$/, "");
|
||||
const candidateBases = [envBaseUrl, storageBaseUrl, fallbackBaseUrl, "http://127.0.0.1:8080", "http://localhost:8080"];
|
||||
const API_BASE_URL_CANDIDATES = Array.from(new Set(candidateBases.filter(Boolean))).map((u) => String(u).replace(/\/$/, ""));
|
||||
const envShopId = typeof process !== "undefined" && process.env && (process.env.VITE_APP_SHOP_ID || process.env.SHOP_ID) || "";
|
||||
const storageShopId = typeof common_vendor.index !== "undefined" ? common_vendor.index.getStorageSync("SHOP_ID") || "" : "";
|
||||
const SHOP_ID = Number(envShopId || storageShopId || 1);
|
||||
const envEnableDefaultUser = typeof process !== "undefined" && process.env && (process.env.VITE_APP_ENABLE_DEFAULT_USER || process.env.ENABLE_DEFAULT_USER) || "";
|
||||
const storageEnableDefaultUser = typeof common_vendor.index !== "undefined" ? common_vendor.index.getStorageSync("ENABLE_DEFAULT_USER") || "" : "";
|
||||
const ENABLE_DEFAULT_USER = String(envEnableDefaultUser || storageEnableDefaultUser || "false").toLowerCase() === "true";
|
||||
const ENABLE_DEFAULT_USER = String(envEnableDefaultUser || storageEnableDefaultUser || "true").toLowerCase() === "true";
|
||||
const envDefaultUserId = typeof process !== "undefined" && process.env && (process.env.VITE_APP_DEFAULT_USER_ID || process.env.DEFAULT_USER_ID) || "";
|
||||
const storageDefaultUserId = typeof common_vendor.index !== "undefined" ? common_vendor.index.getStorageSync("DEFAULT_USER_ID") || "" : "";
|
||||
const DEFAULT_USER_ID = Number(envDefaultUserId || storageDefaultUserId || 2);
|
||||
exports.API_BASE_URL = API_BASE_URL;
|
||||
exports.API_BASE_URL_CANDIDATES = API_BASE_URL_CANDIDATES;
|
||||
exports.DEFAULT_USER_ID = DEFAULT_USER_ID;
|
||||
exports.ENABLE_DEFAULT_USER = ENABLE_DEFAULT_USER;
|
||||
exports.SHOP_ID = SHOP_ID;
|
||||
|
||||
103
frontend/unpackage/dist/dev/mp-weixin/common/http.js
vendored
103
frontend/unpackage/dist/dev/mp-weixin/common/http.js
vendored
@@ -8,24 +8,29 @@ function buildUrl(path) {
|
||||
return path;
|
||||
return common_config.API_BASE_URL + (path.startsWith("/") ? path : "/" + path);
|
||||
}
|
||||
function requestWithFallback(options, candidates, idx, resolve, reject) {
|
||||
const base = candidates[idx] || common_config.API_BASE_URL;
|
||||
const url = options.url.replace(/^https?:\/\/[^/]+/, base);
|
||||
common_vendor.index.request({ ...options, url, success: (res) => {
|
||||
const { statusCode, data } = res;
|
||||
if (statusCode >= 200 && statusCode < 300)
|
||||
return resolve(data);
|
||||
if (idx + 1 < candidates.length)
|
||||
return requestWithFallback(options, candidates, idx + 1, resolve, reject);
|
||||
reject(new Error("HTTP " + statusCode));
|
||||
}, fail: (err) => {
|
||||
if (idx + 1 < candidates.length)
|
||||
return requestWithFallback(options, candidates, idx + 1, resolve, reject);
|
||||
reject(err);
|
||||
} });
|
||||
}
|
||||
function get(path, params = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const headers = { "X-Shop-Id": common_config.SHOP_ID };
|
||||
if (common_config.ENABLE_DEFAULT_USER && common_config.DEFAULT_USER_ID)
|
||||
headers["X-User-Id"] = common_config.DEFAULT_USER_ID;
|
||||
common_vendor.index.request({
|
||||
url: buildUrl(path),
|
||||
method: "GET",
|
||||
data: params,
|
||||
header: headers,
|
||||
success: (res) => {
|
||||
const { statusCode, data } = res;
|
||||
if (statusCode >= 200 && statusCode < 300)
|
||||
return resolve(data);
|
||||
reject(new Error("HTTP " + statusCode));
|
||||
},
|
||||
fail: (err) => reject(err)
|
||||
});
|
||||
const options = { url: buildUrl(path), method: "GET", data: params, header: headers };
|
||||
requestWithFallback(options, common_config.API_BASE_URL_CANDIDATES, 0, resolve, reject);
|
||||
});
|
||||
}
|
||||
function post(path, body = {}) {
|
||||
@@ -33,21 +38,67 @@ function post(path, body = {}) {
|
||||
const headers = { "Content-Type": "application/json", "X-Shop-Id": common_config.SHOP_ID };
|
||||
if (common_config.ENABLE_DEFAULT_USER && common_config.DEFAULT_USER_ID)
|
||||
headers["X-User-Id"] = common_config.DEFAULT_USER_ID;
|
||||
common_vendor.index.request({
|
||||
url: buildUrl(path),
|
||||
method: "POST",
|
||||
data: body,
|
||||
header: headers,
|
||||
success: (res) => {
|
||||
const { statusCode, data } = res;
|
||||
if (statusCode >= 200 && statusCode < 300)
|
||||
return resolve(data);
|
||||
reject(new Error("HTTP " + statusCode));
|
||||
},
|
||||
fail: (err) => reject(err)
|
||||
});
|
||||
const options = { url: buildUrl(path), method: "POST", data: body, header: headers };
|
||||
requestWithFallback(options, common_config.API_BASE_URL_CANDIDATES, 0, resolve, reject);
|
||||
});
|
||||
}
|
||||
function put(path, body = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const headers = { "Content-Type": "application/json", "X-Shop-Id": common_config.SHOP_ID };
|
||||
if (common_config.ENABLE_DEFAULT_USER && common_config.DEFAULT_USER_ID)
|
||||
headers["X-User-Id"] = common_config.DEFAULT_USER_ID;
|
||||
const options = { url: buildUrl(path), method: "PUT", data: body, header: headers };
|
||||
requestWithFallback(options, common_config.API_BASE_URL_CANDIDATES, 0, resolve, reject);
|
||||
});
|
||||
}
|
||||
function del(path, body = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const headers = { "Content-Type": "application/json", "X-Shop-Id": common_config.SHOP_ID };
|
||||
if (common_config.ENABLE_DEFAULT_USER && common_config.DEFAULT_USER_ID)
|
||||
headers["X-User-Id"] = common_config.DEFAULT_USER_ID;
|
||||
const options = { url: buildUrl(path), method: "DELETE", data: body, header: headers };
|
||||
requestWithFallback(options, common_config.API_BASE_URL_CANDIDATES, 0, resolve, reject);
|
||||
});
|
||||
}
|
||||
function uploadWithFallback(options, candidates, idx, resolve, reject) {
|
||||
const base = candidates[idx] || common_config.API_BASE_URL;
|
||||
const url = options.url.replace(/^https?:\/\/[^/]+/, base);
|
||||
const uploadOptions = { ...options, url };
|
||||
common_vendor.index.uploadFile({
|
||||
...uploadOptions,
|
||||
success: (res) => {
|
||||
const statusCode = res.statusCode || 0;
|
||||
if (statusCode >= 200 && statusCode < 300) {
|
||||
try {
|
||||
const data = typeof res.data === "string" ? JSON.parse(res.data) : res.data;
|
||||
return resolve(data);
|
||||
} catch (e) {
|
||||
return resolve(res.data);
|
||||
}
|
||||
}
|
||||
if (idx + 1 < candidates.length)
|
||||
return uploadWithFallback(options, candidates, idx + 1, resolve, reject);
|
||||
reject(new Error("HTTP " + statusCode));
|
||||
},
|
||||
fail: (err) => {
|
||||
if (idx + 1 < candidates.length)
|
||||
return uploadWithFallback(options, candidates, idx + 1, resolve, reject);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
function upload(path, filePath, formData = {}, name = "file") {
|
||||
return new Promise((resolve, reject) => {
|
||||
const header = { "X-Shop-Id": common_config.SHOP_ID };
|
||||
if (common_config.ENABLE_DEFAULT_USER && common_config.DEFAULT_USER_ID)
|
||||
header["X-User-Id"] = common_config.DEFAULT_USER_ID;
|
||||
const options = { url: buildUrl(path), filePath, name, formData, header };
|
||||
uploadWithFallback(options, common_config.API_BASE_URL_CANDIDATES, 0, resolve, reject);
|
||||
});
|
||||
}
|
||||
exports.del = del;
|
||||
exports.get = get;
|
||||
exports.post = post;
|
||||
exports.put = put;
|
||||
exports.upload = upload;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/common/http.js.map
|
||||
|
||||
@@ -68,8 +68,8 @@ const capitalize = cacheStringFunction((str) => {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
});
|
||||
const toHandlerKey = cacheStringFunction((str) => {
|
||||
const s = str ? `on${capitalize(str)}` : ``;
|
||||
return s;
|
||||
const s2 = str ? `on${capitalize(str)}` : ``;
|
||||
return s2;
|
||||
});
|
||||
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
||||
const invokeArrayFns$1 = (fns, arg) => {
|
||||
@@ -92,6 +92,36 @@ const toNumber = (val) => {
|
||||
const n = isString(val) ? Number(val) : NaN;
|
||||
return isNaN(n) ? val : n;
|
||||
};
|
||||
function normalizeStyle(value) {
|
||||
if (isArray(value)) {
|
||||
const res = {};
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const item = value[i];
|
||||
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
||||
if (normalized) {
|
||||
for (const key in normalized) {
|
||||
res[key] = normalized[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
} else if (isString(value) || isObject(value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
const listDelimiterRE = /;(?![^(]*\))/g;
|
||||
const propertyDelimiterRE = /:([^]+)/;
|
||||
const styleCommentRE = /\/\*[^]*?\*\//g;
|
||||
function parseStringStyle(cssText) {
|
||||
const ret = {};
|
||||
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
||||
if (item) {
|
||||
const tmp = item.split(propertyDelimiterRE);
|
||||
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
const toDisplayString = (val) => {
|
||||
return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
|
||||
};
|
||||
@@ -1287,6 +1317,9 @@ function isReadonly(value) {
|
||||
function isShallow(value) {
|
||||
return !!(value && value["__v_isShallow"]);
|
||||
}
|
||||
function isProxy(value) {
|
||||
return isReactive(value) || isReadonly(value);
|
||||
}
|
||||
function toRaw(observed) {
|
||||
const raw = observed && observed["__v_raw"];
|
||||
return raw ? toRaw(raw) : observed;
|
||||
@@ -2078,6 +2111,47 @@ function setCurrentRenderingInstance(instance) {
|
||||
instance && instance.type.__scopeId || null;
|
||||
return prev;
|
||||
}
|
||||
const COMPONENTS = "components";
|
||||
function resolveComponent(name, maybeSelfReference) {
|
||||
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
||||
}
|
||||
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
||||
const instance = currentRenderingInstance || currentInstance;
|
||||
if (instance) {
|
||||
const Component2 = instance.type;
|
||||
if (type === COMPONENTS) {
|
||||
const selfName = getComponentName(
|
||||
Component2,
|
||||
false
|
||||
);
|
||||
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
||||
return Component2;
|
||||
}
|
||||
}
|
||||
const res = (
|
||||
// local registration
|
||||
// check instance[type] first which is resolved for options API
|
||||
resolve(instance[type] || Component2[type], name) || // global registration
|
||||
resolve(instance.appContext[type], name)
|
||||
);
|
||||
if (!res && maybeSelfReference) {
|
||||
return Component2;
|
||||
}
|
||||
if (warnMissing && !res) {
|
||||
const extra = type === COMPONENTS ? `
|
||||
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
||||
warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
warn$1(
|
||||
`resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
|
||||
);
|
||||
}
|
||||
}
|
||||
function resolve(registry, name) {
|
||||
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
||||
}
|
||||
const INITIAL_WATCHER_VALUE = {};
|
||||
function watch(source, cb, options) {
|
||||
if (!isFunction(cb)) {
|
||||
@@ -3692,6 +3766,12 @@ const Static = Symbol.for("v-stc");
|
||||
function isVNode(value) {
|
||||
return value ? value.__v_isVNode === true : false;
|
||||
}
|
||||
const InternalObjectKey = `__vInternal`;
|
||||
function guardReactiveProps(props) {
|
||||
if (!props)
|
||||
return null;
|
||||
return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
|
||||
}
|
||||
const emptyAppContext = createAppContext();
|
||||
let uid = 0;
|
||||
function createComponentInstance(vnode, parent, suspense) {
|
||||
@@ -4932,6 +5012,11 @@ function initApp(app) {
|
||||
}
|
||||
}
|
||||
const propsCaches = /* @__PURE__ */ Object.create(null);
|
||||
function renderProps(props) {
|
||||
const { uid: uid2, __counter } = getCurrentInstance();
|
||||
const propsId = (propsCaches[uid2] || (propsCaches[uid2] = [])).push(guardReactiveProps(props)) - 1;
|
||||
return uid2 + "," + propsId + "," + __counter;
|
||||
}
|
||||
function pruneComponentPropsCache(uid2) {
|
||||
delete propsCaches[uid2];
|
||||
}
|
||||
@@ -4972,6 +5057,22 @@ function getCreateApp() {
|
||||
return my[method];
|
||||
}
|
||||
}
|
||||
function stringifyStyle(value) {
|
||||
if (isString(value)) {
|
||||
return value;
|
||||
}
|
||||
return stringify(normalizeStyle(value));
|
||||
}
|
||||
function stringify(styles) {
|
||||
let ret = "";
|
||||
if (!styles || isString(styles)) {
|
||||
return ret;
|
||||
}
|
||||
for (const key in styles) {
|
||||
ret += `${key.startsWith(`--`) ? key : hyphenate(key)}:${styles[key]};`;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
function vOn(value, key) {
|
||||
const instance = getCurrentInstance();
|
||||
const ctx = instance.ctx;
|
||||
@@ -5121,8 +5222,10 @@ function withModelModifiers(fn, { number, trim }, isComponent = false) {
|
||||
}
|
||||
const o = (value, key) => vOn(value, key);
|
||||
const f = (source, renderItem) => vFor(source, renderItem);
|
||||
const s = (value) => stringifyStyle(value);
|
||||
const e = (target, ...sources) => extend(target, ...sources);
|
||||
const t = (val) => toDisplayString(val);
|
||||
const p = (props) => renderProps(props);
|
||||
const m = (fn, modifiers, isComponent = false) => withModelModifiers(fn, modifiers, isComponent);
|
||||
function createApp$1(rootComponent, rootProps = null) {
|
||||
rootComponent && (rootComponent.mpType = "app");
|
||||
@@ -5445,8 +5548,8 @@ function promisify$1(name, fn) {
|
||||
if (hasCallback(args)) {
|
||||
return wrapperReturnValue(name, invokeApi(name, fn, extend({}, args), rest));
|
||||
}
|
||||
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
|
||||
invokeApi(name, fn, extend({}, args, { success: resolve, fail: reject }), rest);
|
||||
return wrapperReturnValue(name, handlePromise(new Promise((resolve2, reject) => {
|
||||
invokeApi(name, fn, extend({}, args, { success: resolve2, fail: reject }), rest);
|
||||
})));
|
||||
};
|
||||
}
|
||||
@@ -5767,7 +5870,7 @@ function invokeGetPushCidCallbacks(cid2, errMsg) {
|
||||
getPushCidCallbacks.length = 0;
|
||||
}
|
||||
const API_GET_PUSH_CLIENT_ID = "getPushClientId";
|
||||
const getPushClientId = defineAsyncApi(API_GET_PUSH_CLIENT_ID, (_, { resolve, reject }) => {
|
||||
const getPushClientId = defineAsyncApi(API_GET_PUSH_CLIENT_ID, (_, { resolve: resolve2, reject }) => {
|
||||
Promise.resolve().then(() => {
|
||||
if (typeof enabled === "undefined") {
|
||||
enabled = false;
|
||||
@@ -5776,7 +5879,7 @@ const getPushClientId = defineAsyncApi(API_GET_PUSH_CLIENT_ID, (_, { resolve, re
|
||||
}
|
||||
getPushCidCallbacks.push((cid2, errMsg) => {
|
||||
if (cid2) {
|
||||
resolve({ cid: cid2 });
|
||||
resolve2({ cid: cid2 });
|
||||
} else {
|
||||
reject(errMsg);
|
||||
}
|
||||
@@ -5845,9 +5948,9 @@ function promisify(name, api) {
|
||||
if (isFunction(options.success) || isFunction(options.fail) || isFunction(options.complete)) {
|
||||
return wrapperReturnValue(name, invokeApi(name, api, extend({}, options), rest));
|
||||
}
|
||||
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
|
||||
return wrapperReturnValue(name, handlePromise(new Promise((resolve2, reject) => {
|
||||
invokeApi(name, api, extend({}, options, {
|
||||
success: resolve,
|
||||
success: resolve2,
|
||||
fail: reject
|
||||
}), rest);
|
||||
})));
|
||||
@@ -6454,13 +6557,13 @@ function initRuntimeSocket(hosts, port, id) {
|
||||
}
|
||||
const SOCKET_TIMEOUT = 500;
|
||||
function tryConnectSocket(host2, port, id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolve2, reject) => {
|
||||
const socket = index.connectSocket({
|
||||
url: `ws://${host2}:${port}/${id}`,
|
||||
multiple: true,
|
||||
// 支付宝小程序 是否开启多实例
|
||||
fail() {
|
||||
resolve(null);
|
||||
resolve2(null);
|
||||
}
|
||||
});
|
||||
const timer = setTimeout(() => {
|
||||
@@ -6468,19 +6571,19 @@ function tryConnectSocket(host2, port, id) {
|
||||
code: 1006,
|
||||
reason: "connect timeout"
|
||||
});
|
||||
resolve(null);
|
||||
resolve2(null);
|
||||
}, SOCKET_TIMEOUT);
|
||||
socket.onOpen((e2) => {
|
||||
clearTimeout(timer);
|
||||
resolve(socket);
|
||||
resolve2(socket);
|
||||
});
|
||||
socket.onClose((e2) => {
|
||||
clearTimeout(timer);
|
||||
resolve(null);
|
||||
resolve2(null);
|
||||
});
|
||||
socket.onError((e2) => {
|
||||
clearTimeout(timer);
|
||||
resolve(null);
|
||||
resolve2(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -7898,5 +8001,8 @@ exports.f = f;
|
||||
exports.index = index;
|
||||
exports.m = m;
|
||||
exports.o = o;
|
||||
exports.p = p;
|
||||
exports.resolveComponent = resolveComponent;
|
||||
exports.s = s;
|
||||
exports.t = t;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/common/vendor.js.map
|
||||
|
||||
Reference in New Issue
Block a user