开发者社区> 问答> 正文

在PHP中复制缩小的JS

我一直在用PHP复制JS代码。自从代码最小化以来,我花了不到两个月的时间才能弄清楚该怎么做,而我的大脑也只炸了一半。我需要做的就是在以下代码中复制“ device-id”和“ sign”变量的结果:

"use strict";
(function(t, i, r) {
    Object.defineProperty(e, "__esModule", {
        value: !0
    }), e.post = e.get = void 0;
    var a = g(n(22)),
        o = g(n(41)),
        s = g(n(16)),
        l = g(n(17)),
        u = (e.get = function() {
            var t = (0, l.default)(s.default.mark(function t(e) {
                var n, i, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
                return arguments.length > 2 && void 0 !== arguments[2] && arguments[2], s.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                        case 0:
                            if (r = w(r), t.prev = 1, n = void 0, -1 === e.indexOf("http")) {
                                t.next = 9;
                                break
                            }
                            return t.next = 6, y.get(e, {
                                params: r
                            });
                        case 6:
                            n = t.sent, t.next = 12;
                            break;
                        case 9:
                            return t.next = 11, y.get("/api" + e, {
                                params: r
                            });
                        case 11:
                            n = t.sent;
                        case 12:
                            return i = n.data, t.abrupt("return", b({
                                type: "get",
                                url: e,
                                data: i
                            }));
                        case 16:
                            return t.prev = 16, t.t0 = t.catch(1), t.abrupt("return", x(t.t0));
                        case 19:
                        case "end":
                            return t.stop()
                    }
                }, t, this, [
                    [1, 16]
                ])
            }));
            return function(e) {
                return t.apply(this, arguments)
            }
        }(), e.post = function() {
            var t = (0, l.default)(s.default.mark(function t(e) {
                var n, i, r, a, o, l, u = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
                return arguments.length > 2 && void 0 !== arguments[2] && arguments[2], s.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                        case 0:
                            if (n = C(), i = (0, f.getLogin)(), r = i.token, a = i.uid, r && (n.token = r, n.uid = a), S(n), t.prev = 4, o = void 0, -1 === e.indexOf("http")) {
                                t.next = 12;
                                break
                            }
                            return t.next = 9, y.post(e, h.default.stringify(u, {
                                allowDots: !0
                            }));
                        case 9:
                            o = t.sent, t.next = 15;
                            break;
                        case 12:
                            return t.next = 14, y.post("/api" + e, h.default.stringify(u, {
                                allowDots: !0
                            }));
                        case 14:
                            o = t.sent;
                        case 15:
                            return l = o.data, t.abrupt("return", b({
                                type: "post",
                                url: e,
                                data: l
                            }));
                        case 19:
                            return t.prev = 19, t.t0 = t.catch(4), t.abrupt("return", x(t.t0));
                        case 22:
                        case "end":
                            return t.stop()
                    }
                }, t, this, [
                    [4, 19]
                ])
            }));
            return function(e) {
                return t.apply(this, arguments)
            }
        }(), g(n(572))),
        c = n(782),
        d = g(n(799)),
        f = n(100),
        h = g(n(800)),
        p = g(n(29)),
        m = g(n(593)),
        v = (g(n(60)), n(357));

    function g(t) {
        return t && t.__esModule ? t : {
            default: t
        }
    }(0, c.shim)();
    var y = u.default.create({
            baseURL: window.location.origin,
            timeout: 5e3
        }),
        _ = t.debounce(function(t) {
            t.code === i.KICK ? m.default.error("您的账号已在别处登录") : m.default.error(t.message), p.default.dispatch(r.LOGOUT)
        }, 1e3),
        b = function(e) {
            e.type, e.url;
            var n = e.data;
            return n.code === i.FORBIDDEN ? (window.location.href = "/forbidden.html", [!1, n]) : 1 === n.code || 0 === n.errno ? [!0, n.data] : n && t.isEmpty(n) ? [!1, void 0] : n && t.isUndefined(n.code) && !n.errno ? [!0, n ? n.data : void 0] : n.code === i.EXPIRE || n.code === i.KICK ? (_(n), [!1, n]) : [!1, n]
        },
        x = function(t) {
            return -1 !== t.message.indexOf("Network Error") && (t.message = "网络异常,请检查网络是否正确。"), [!1, t]
        };

    function w(t) {
        return t || {}
    }

    function C() {
        var t = Date.parse(new Date),
            e = {};
        e["device-id"] = (0, v.getUUID)(), e["os-type"] = 0, e.timestamp = t, e.version = "1.0";
        var n = function t(e, n, i) {
            if (null == e) return "";
            var r = "",
                o = void 0 === e ? "undefined" : (0, a.default)(e);
            if ("string" == o || "number" == o || "boolean" == o) r += "&" + n + "=" + (null == i || i ? encodeURIComponent(e) : e);
            else
                for (var s in e) {
                    var l = null == n ? s : n + (e instanceof Array ? "[" + s + "]" : "." + s);
                    r += t(e[s], l, i)
                }
            return r
        }(e).substr(1);
        return e.sign = (0, d.default)(n + "global"), e["app-type"] = 2, e
    }

    function S(t) {
        delete u.default.defaults.headers.common.uid, delete u.default.defaults.headers.common.token;
        var e = u.default.defaults.headers.common || {};
        u.default.defaults.headers.common = (0, o.default)(e, t)
    }
}).call(this, n(6), n(679).default, n(13).default)

我已经取得了一些进步,但是我对自己的技术没有足够的信心来确保它朝着正确的方向发展。任何帮助将不胜感激

展开
收起
社区秘书 2019-11-27 16:27:23 710 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
JavaScript函数 立即下载
Delivering Javascript to World 立即下载
编程语言如何演化-以JS的private为例 立即下载