yapi to ts
当前为
// ==UserScript== // @name yapi-to-ts // @namespace http://172.16.101.32:7700/project/*/interface/api/* // @version 0.1.7 // @author monkey // @description yapi to ts // @license MIT // @icon https://vitejs.dev/logo.svg // @match http://172.16.101.32:7700/project/*/interface/api/* // @match http://172.16.101.32:7700/project/*/interface/api // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle.min.js // @require https://cdn.bootcdn.net/ajax/libs/highlight.js/11.8.0/highlight.min.js // @require https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js // @require https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.min.js // @grant GM_addStyle // @grant GM_setClipboard // ==/UserScript== (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const e=document.createElement("style");e.textContent=t,document.head.append(e)})(" body .el-notification__content p{white-space:pre}body .el-notification{width:430px!important}body .interface-title{display:flex;align-items:center}body .component-label>div{display:flex;align-items:center;justify-content:space-between}body .interface-title+button+div>div{display:flex;align-items:center;justify-content:space-between}body .ant-layout-sider{position:sticky;top:30px} "); (function (vue) { 'use strict'; var _GM_addStyle = /* @__PURE__ */ (() => typeof GM_addStyle != "undefined" ? GM_addStyle : void 0)(); var _GM_setClipboard = /* @__PURE__ */ (() => typeof GM_setClipboard != "undefined" ? GM_setClipboard : void 0)(); var _a; const isClient = typeof window !== "undefined"; const isString$1 = (val) => typeof val === "string"; const noop = () => { }; isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent); function resolveUnref(r) { return typeof r === "function" ? r() : vue.unref(r); } function identity(arg) { return arg; } function tryOnScopeDispose(fn) { if (vue.getCurrentScope()) { vue.onScopeDispose(fn); return true; } return false; } function useTimeoutFn(cb, interval, options = {}) { const { immediate = true } = options; const isPending = vue.ref(false); let timer = null; function clear() { if (timer) { clearTimeout(timer); timer = null; } } function stop() { isPending.value = false; clear(); } function start(...args) { clear(); isPending.value = true; timer = setTimeout(() => { isPending.value = false; timer = null; cb(...args); }, resolveUnref(interval)); } if (immediate) { isPending.value = true; if (isClient) start(); } tryOnScopeDispose(stop); return { isPending: vue.readonly(isPending), start, stop }; } function unrefElement(elRef) { var _a2; const plain = resolveUnref(elRef); return (_a2 = plain == null ? void 0 : plain.$el) != null ? _a2 : plain; } const defaultWindow = isClient ? window : void 0; function useEventListener(...args) { let target; let events; let listeners; let options; if (isString$1(args[0]) || Array.isArray(args[0])) { [events, listeners, options] = args; target = defaultWindow; } else { [target, events, listeners, options] = args; } if (!target) return noop; if (!Array.isArray(events)) events = [events]; if (!Array.isArray(listeners)) listeners = [listeners]; const cleanups = []; const cleanup = () => { cleanups.forEach((fn) => fn()); cleanups.length = 0; }; const register = (el, event, listener, options2) => { el.addEventListener(event, listener, options2); return () => el.removeEventListener(event, listener, options2); }; const stopWatch = vue.watch(() => [unrefElement(target), resolveUnref(options)], ([el, options2]) => { cleanup(); if (!el) return; cleanups.push(...events.flatMap((event) => { return listeners.map((listener) => register(el, event, listener, options2)); })); }, { immediate: true, flush: "post" }); const stop = () => { stopWatch(); cleanup(); }; tryOnScopeDispose(stop); return stop; } const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; const globalKey = "__vueuse_ssr_handlers__"; _global[globalKey] = _global[globalKey] || {}; var SwipeDirection; (function(SwipeDirection2) { SwipeDirection2["UP"] = "UP"; SwipeDirection2["RIGHT"] = "RIGHT"; SwipeDirection2["DOWN"] = "DOWN"; SwipeDirection2["LEFT"] = "LEFT"; SwipeDirection2["NONE"] = "NONE"; })(SwipeDirection || (SwipeDirection = {})); var __defProp = Object.defineProperty; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; const _TransitionPresets = { easeInSine: [0.12, 0, 0.39, 0], easeOutSine: [0.61, 1, 0.88, 1], easeInOutSine: [0.37, 0, 0.63, 1], easeInQuad: [0.11, 0, 0.5, 0], easeOutQuad: [0.5, 1, 0.89, 1], easeInOutQuad: [0.45, 0, 0.55, 1], easeInCubic: [0.32, 0, 0.67, 0], easeOutCubic: [0.33, 1, 0.68, 1], easeInOutCubic: [0.65, 0, 0.35, 1], easeInQuart: [0.5, 0, 0.75, 0], easeOutQuart: [0.25, 1, 0.5, 1], easeInOutQuart: [0.76, 0, 0.24, 1], easeInQuint: [0.64, 0, 0.78, 0], easeOutQuint: [0.22, 1, 0.36, 1], easeInOutQuint: [0.83, 0, 0.17, 1], easeInExpo: [0.7, 0, 0.84, 0], easeOutExpo: [0.16, 1, 0.3, 1], easeInOutExpo: [0.87, 0, 0.13, 1], easeInCirc: [0.55, 0, 1, 0.45], easeOutCirc: [0, 0.55, 0.45, 1], easeInOutCirc: [0.85, 0, 0.15, 1], easeInBack: [0.36, 0, 0.66, -0.56], easeOutBack: [0.34, 1.56, 0.64, 1], easeInOutBack: [0.68, -0.6, 0.32, 1.6] }; __spreadValues({ linear: identity }, _TransitionPresets); /** * @vue/shared v3.4.10 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ const hasOwnProperty$4 = Object.prototype.hasOwnProperty; const hasOwn = (val, key) => hasOwnProperty$4.call(val, key); const isString = (val) => typeof val === "string"; const isObject$1 = (val) => val !== null && typeof val === "object"; var freeGlobal = typeof global == "object" && global && global.Object === Object && global; const freeGlobal$1 = freeGlobal; var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root = freeGlobal$1 || freeSelf || Function("return this")(); const root$1 = root; var Symbol$1 = root$1.Symbol; const Symbol$2 = Symbol$1; var objectProto$4 = Object.prototype; var hasOwnProperty$3 = objectProto$4.hasOwnProperty; var nativeObjectToString$1 = objectProto$4.toString; var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0; function getRawTag(value) { var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1]; try { value[symToStringTag$1] = void 0; var unmasked = true; } catch (e) { } var result = nativeObjectToString$1.call(value); if (unmasked) { if (isOwn) { value[symToStringTag$1] = tag; } else { delete value[symToStringTag$1]; } } return result; } var objectProto$3 = Object.prototype; var nativeObjectToString = objectProto$3.toString; function objectToString(value) { return nativeObjectToString.call(value); } var nullTag = "[object Null]", undefinedTag = "[object Undefined]"; var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0; function baseGetTag(value) { if (value == null) { return value === void 0 ? undefinedTag : nullTag; } return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); } function isObjectLike(value) { return value != null && typeof value == "object"; } var symbolTag = "[object Symbol]"; function isSymbol(value) { return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag; } function arrayMap(array, iteratee) { var index = -1, length = array == null ? 0 : array.length, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } var isArray = Array.isArray; const isArray$1 = isArray; var INFINITY$1 = 1 / 0; var symbolProto = Symbol$2 ? Symbol$2.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0; function baseToString(value) { if (typeof value == "string") { return value; } if (isArray$1(value)) { return arrayMap(value, baseToString) + ""; } if (isSymbol(value)) { return symbolToString ? symbolToString.call(value) : ""; } var result = value + ""; return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result; } function isObject(value) { var type = typeof value; return value != null && (type == "object" || type == "function"); } var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]"; function isFunction(value) { if (!isObject(value)) { return false; } var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } var coreJsData = root$1["__core-js_shared__"]; const coreJsData$1 = coreJsData; var maskSrcKey = function() { var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || ""); return uid ? "Symbol(src)_1." + uid : ""; }(); function isMasked(func) { return !!maskSrcKey && maskSrcKey in func; } var funcProto$1 = Function.prototype; var funcToString$1 = funcProto$1.toString; function toSource(func) { if (func != null) { try { return funcToString$1.call(func); } catch (e) { } try { return func + ""; } catch (e) { } } return ""; } var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; var reIsHostCtor = /^\[object .+?Constructor\]$/; var funcProto = Function.prototype, objectProto$2 = Object.prototype; var funcToString = funcProto.toString; var hasOwnProperty$2 = objectProto$2.hasOwnProperty; var reIsNative = RegExp( "^" + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" ); function baseIsNative(value) { if (!isObject(value) || isMasked(value)) { return false; } var pattern = isFunction(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } function getValue(object, key) { return object == null ? void 0 : object[key]; } function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : void 0; } function eq(value, other) { return value === other || value !== value && other !== other; } var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/; function isKey(value, object) { if (isArray$1(value)) { return false; } var type = typeof value; if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) { return true; } return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object); } var nativeCreate = getNative(Object, "create"); const nativeCreate$1 = nativeCreate; function hashClear() { this.__data__ = nativeCreate$1 ? nativeCreate$1(null) : {}; this.size = 0; } function hashDelete(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } var HASH_UNDEFINED$1 = "__lodash_hash_undefined__"; var objectProto$1 = Object.prototype; var hasOwnProperty$1 = objectProto$1.hasOwnProperty; function hashGet(key) { var data = this.__data__; if (nativeCreate$1) { var result = data[key]; return result === HASH_UNDEFINED$1 ? void 0 : result; } return hasOwnProperty$1.call(data, key) ? data[key] : void 0; } var objectProto = Object.prototype; var hasOwnProperty = objectProto.hasOwnProperty; function hashHas(key) { var data = this.__data__; return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key); } var HASH_UNDEFINED = "__lodash_hash_undefined__"; function hashSet(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = nativeCreate$1 && value === void 0 ? HASH_UNDEFINED : value; return this; } function Hash(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } Hash.prototype.clear = hashClear; Hash.prototype["delete"] = hashDelete; Hash.prototype.get = hashGet; Hash.prototype.has = hashHas; Hash.prototype.set = hashSet; function listCacheClear() { this.__data__ = []; this.size = 0; } function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } var arrayProto = Array.prototype; var splice = arrayProto.splice; function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } function listCacheGet(key) { var data = this.__data__, index = assocIndexOf(data, key); return index < 0 ? void 0 : data[index][1]; } function listCacheHas(key) { return assocIndexOf(this.__data__, key) > -1; } function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } ListCache.prototype.clear = listCacheClear; ListCache.prototype["delete"] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; var Map = getNative(root$1, "Map"); const Map$1 = Map; function mapCacheClear() { this.size = 0; this.__data__ = { "hash": new Hash(), "map": new (Map$1 || ListCache)(), "string": new Hash() }; } function isKeyable(value) { var type = typeof value; return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; } function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; } function mapCacheDelete(key) { var result = getMapData(this, key)["delete"](key); this.size -= result ? 1 : 0; return result; } function mapCacheGet(key) { return getMapData(this, key).get(key); } function mapCacheHas(key) { return getMapData(this, key).has(key); } function mapCacheSet(key, value) { var data = getMapData(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } MapCache.prototype.clear = mapCacheClear; MapCache.prototype["delete"] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; var FUNC_ERROR_TEXT = "Expected a function"; function memoize(func, resolver) { if (typeof func != "function" || resolver != null && typeof resolver != "function") { throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function() { var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; memoized.cache = new (memoize.Cache || MapCache)(); return memoized; } memoize.Cache = MapCache; var MAX_MEMOIZE_SIZE = 500; function memoizeCapped(func) { var result = memoize(func, function(key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); var cache = result.cache; return result; } var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; var reEscapeChar = /\\(\\)?/g; var stringToPath = memoizeCapped(function(string) { var result = []; if (string.charCodeAt(0) === 46) { result.push(""); } string.replace(rePropName, function(match, number, quote, subString) { result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match); }); return result; }); const stringToPath$1 = stringToPath; function toString(value) { return value == null ? "" : baseToString(value); } function castPath(value, object) { if (isArray$1(value)) { return value; } return isKey(value, object) ? [value] : stringToPath$1(toString(value)); } var INFINITY = 1 / 0; function toKey(value) { if (typeof value == "string" || isSymbol(value)) { return value; } var result = value + ""; return result == "0" && 1 / value == -INFINITY ? "-0" : result; } function baseGet(object, path2) { path2 = castPath(path2, object); var index = 0, length = path2.length; while (object != null && index < length) { object = object[toKey(path2[index++])]; } return index && index == length ? object : void 0; } function get(object, path2, defaultValue) { var result = object == null ? void 0 : baseGet(object, path2); return result === void 0 ? defaultValue : result; } function fromPairs(pairs) { var index = -1, length = pairs == null ? 0 : pairs.length, result = {}; while (++index < length) { var pair = pairs[index]; result[pair[0]] = pair[1]; } return result; } const isUndefined = (val) => val === void 0; const isNumber = (val) => typeof val === "number"; const isElement = (e) => { if (typeof Element === "undefined") return false; return e instanceof Element; }; const isStringNumber = (val) => { if (!isString(val)) { return false; } return !Number.isNaN(Number(val)); }; const keysOf = (arr) => Object.keys(arr); function addUnit(value, defaultUnit = "px") { if (!value) return ""; if (isNumber(value) || isStringNumber(value)) { return `${value}${defaultUnit}`; } else if (isString(value)) { return value; } } /*! Element Plus Icons Vue v2.3.1 */ var circle_close_filled_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({ name: "CircleCloseFilled", __name: "circle-close-filled", setup(__props) { return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, [ vue.createElementVNode("path", { fill: "currentColor", d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336z" }) ])); } }); var circle_close_filled_default = circle_close_filled_vue_vue_type_script_setup_true_lang_default; var close_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({ name: "Close", __name: "close", setup(__props) { return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, [ vue.createElementVNode("path", { fill: "currentColor", d: "M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z" }) ])); } }); var close_default = close_vue_vue_type_script_setup_true_lang_default; var info_filled_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({ name: "InfoFilled", __name: "info-filled", setup(__props) { return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, [ vue.createElementVNode("path", { fill: "currentColor", d: "M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64m67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344M590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.992 12.992 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z" }) ])); } }); var info_filled_default = info_filled_vue_vue_type_script_setup_true_lang_default; var success_filled_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({ name: "SuccessFilled", __name: "success-filled", setup(__props) { return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, [ vue.createElementVNode("path", { fill: "currentColor", d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m-55.808 536.384-99.52-99.584a38.4 38.4 0 1 0-54.336 54.336l126.72 126.72a38.272 38.272 0 0 0 54.336 0l262.4-262.464a38.4 38.4 0 1 0-54.272-54.336z" }) ])); } }); var success_filled_default = success_filled_vue_vue_type_script_setup_true_lang_default; var warning_filled_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({ name: "WarningFilled", __name: "warning-filled", setup(__props) { return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1024 1024" }, [ vue.createElementVNode("path", { fill: "currentColor", d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m0 192a58.432 58.432 0 0 0-58.24 63.744l23.36 256.384a35.072 35.072 0 0 0 69.76 0l23.296-256.384A58.432 58.432 0 0 0 512 256m0 512a51.2 51.2 0 1 0 0-102.4 51.2 51.2 0 0 0 0 102.4" }) ])); } }); var warning_filled_default = warning_filled_vue_vue_type_script_setup_true_lang_default; const epPropKey = "__epPropKey"; const definePropType = (val) => val; const isEpProp = (val) => isObject$1(val) && !!val[epPropKey]; const buildProp = (prop, key) => { if (!isObject$1(prop) || isEpProp(prop)) return prop; const { values, required, default: defaultValue, type, validator } = prop; const _validator = values || validator ? (val) => { let valid = false; let allowedValues = []; if (values) { allowedValues = Array.from(values); if (hasOwn(prop, "default")) { allowedValues.push(defaultValue); } valid || (valid = allowedValues.includes(val)); } if (validator) valid || (valid = validator(val)); if (!valid && allowedValues.length > 0) { const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", "); vue.warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`); } return valid; } : void 0; const epProp = { type, required: !!required, validator: _validator, [epPropKey]: true }; if (hasOwn(prop, "default")) epProp.default = defaultValue; return epProp; }; const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [ key, buildProp(option, key) ])); const iconPropType = definePropType([ String, Object, Function ]); const CloseComponents = { Close: close_default }; const TypeComponentsMap = { success: success_filled_default, warning: warning_filled_default, error: circle_close_filled_default, info: info_filled_default }; const withInstall = (main, extra) => { main.install = (app) => { for (const comp of [main, ...Object.values(extra != null ? extra : {})]) { app.component(comp.name, comp); } }; if (extra) { for (const [key, comp] of Object.entries(extra)) { main[key] = comp; } } return main; }; const withInstallFunction = (fn, name) => { fn.install = (app) => { fn._context = app._context; app.config.globalProperties[name] = fn; }; return fn; }; const EVENT_CODE = { tab: "Tab", enter: "Enter", space: "Space", left: "ArrowLeft", up: "ArrowUp", right: "ArrowRight", down: "ArrowDown", esc: "Escape", delete: "Delete", backspace: "Backspace", numpadEnter: "NumpadEnter", pageUp: "PageUp", pageDown: "PageDown", home: "Home", end: "End" }; const componentSizes = ["", "default", "small", "large"]; var English = { name: "en", el: { colorpicker: { confirm: "OK", clear: "Clear", defaultLabel: "color picker", description: "current color is {color}. press enter to select a new color." }, datepicker: { now: "Now", today: "Today", cancel: "Cancel", clear: "Clear", confirm: "OK", dateTablePrompt: "Use the arrow keys and enter to select the day of the month", monthTablePrompt: "Use the arrow keys and enter to select the month", yearTablePrompt: "Use the arrow keys and enter to select the year", selectedDate: "Selected date", selectDate: "Select date", selectTime: "Select time", startDate: "Start Date", startTime: "Start Time", endDate: "End Date", endTime: "End Time", prevYear: "Previous Year", nextYear: "Next Year", prevMonth: "Previous Month", nextMonth: "Next Month", year: "", month1: "January", month2: "February", month3: "March", month4: "April", month5: "May", month6: "June", month7: "July", month8: "August", month9: "September", month10: "October", month11: "November", month12: "December", week: "week", weeks: { sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", fri: "Fri", sat: "Sat" }, weeksFull: { sun: "Sunday", mon: "Monday", tue: "Tuesday", wed: "Wednesday", thu: "Thursday", fri: "Friday", sat: "Saturday" }, months: { jan: "Jan", feb: "Feb", mar: "Mar", apr: "Apr", may: "May", jun: "Jun", jul: "Jul", aug: "Aug", sep: "Sep", oct: "Oct", nov: "Nov", dec: "Dec" } }, inputNumber: { decrease: "decrease number", increase: "increase number" }, select: { loading: "Loading", noMatch: "No matching data", noData: "No data", placeholder: "Select" }, dropdown: { toggleDropdown: "Toggle Dropdown" }, cascader: { noMatch: "No matching data", loading: "Loading", placeholder: "Select", noData: "No data" }, pagination: { goto: "Go to", pagesize: "/page", total: "Total {total}", pageClassifier: "", page: "Page", prev: "Go to previous page", next: "Go to next page", currentPage: "page {pager}", prevPages: "Previous {pager} pages", nextPages: "Next {pager} pages", deprecationWarning: "Deprecated usages detected, please refer to the el-pagination documentation for more details" }, dialog: { close: "Close this dialog" }, drawer: { close: "Close this dialog" }, messagebox: { title: "Message", confirm: "OK", cancel: "Cancel", error: "Illegal input", close: "Close this dialog" }, upload: { deleteTip: "press delete to remove", delete: "Delete", preview: "Preview", continue: "Continue" }, slider: { defaultLabel: "slider between {min} and {max}", defaultRangeStartLabel: "pick start value", defaultRangeEndLabel: "pick end value" }, table: { emptyText: "No Data", confirmFilter: "Confirm", resetFilter: "Reset", clearFilter: "All", sumText: "Sum" }, tour: { next: "Next", previous: "Previous", finish: "Finish" }, tree: { emptyText: "No Data" }, transfer: { noMatch: "No matching data", noData: "No data", titles: ["List 1", "List 2"], filterPlaceholder: "Enter keyword", noCheckedFormat: "{total} items", hasCheckedFormat: "{checked}/{total} checked" }, image: { error: "FAILED" }, pageHeader: { title: "Back" }, popconfirm: { confirmButtonText: "Yes", cancelButtonText: "No" } } }; const buildTranslator = (locale) => (path2, option) => translate(path2, option, vue.unref(locale)); const translate = (path2, option, locale) => get(locale, path2, path2).replace(/\{(\w+)\}/g, (_2, key) => { var _a2; return `${(_a2 = option == null ? void 0 : option[key]) != null ? _a2 : `{${key}}`}`; }); const buildLocaleContext = (locale) => { const lang = vue.computed(() => vue.unref(locale).name); const localeRef = vue.isRef(locale) ? locale : vue.ref(locale); return { lang, locale: localeRef, t: buildTranslator(locale) }; }; const localeContextKey = Symbol("localeContextKey"); const useLocale = (localeOverrides) => { const locale = localeOverrides || vue.inject(localeContextKey, vue.ref()); return buildLocaleContext(vue.computed(() => locale.value || English)); }; const defaultNamespace = "el"; const statePrefix = "is-"; const _bem = (namespace, block, blockSuffix, element, modifier) => { let cls = `${namespace}-${block}`; if (blockSuffix) { cls += `-${blockSuffix}`; } if (element) { cls += `__${element}`; } if (modifier) { cls += `--${modifier}`; } return cls; }; const namespaceContextKey = Symbol("namespaceContextKey"); const useGetDerivedNamespace = (namespaceOverrides) => { const derivedNamespace = namespaceOverrides || (vue.getCurrentInstance() ? vue.inject(namespaceContextKey, vue.ref(defaultNamespace)) : vue.ref(defaultNamespace)); const namespace = vue.computed(() => { return vue.unref(derivedNamespace) || defaultNamespace; }); return namespace; }; const useNamespace = (block, namespaceOverrides) => { const namespace = useGetDerivedNamespace(namespaceOverrides); const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", ""); const e = (element) => element ? _bem(namespace.value, block, "", element, "") : ""; const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : ""; const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : ""; const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : ""; const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : ""; const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : ""; const is = (name, ...args) => { const state = args.length >= 1 ? args[0] : true; return name && state ? `${statePrefix}${name}` : ""; }; const cssVar = (object) => { const styles = {}; for (const key in object) { if (object[key]) { styles[`--${namespace.value}-${key}`] = object[key]; } } return styles; }; const cssVarBlock = (object) => { const styles = {}; for (const key in object) { if (object[key]) { styles[`--${namespace.value}-${block}-${key}`] = object[key]; } } return styles; }; const cssVarName = (name) => `--${namespace.value}-${name}`; const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`; return { namespace, b, e, m, be, em, bm, bem, is, cssVar, cssVarName, cssVarBlock, cssVarBlockName }; }; const zIndex = vue.ref(0); const defaultInitialZIndex = 2e3; const zIndexContextKey = Symbol("zIndexContextKey"); const useZIndex = (zIndexOverrides) => { const zIndexInjection = zIndexOverrides || (vue.getCurrentInstance() ? vue.inject(zIndexContextKey, void 0) : void 0); const initialZIndex = vue.computed(() => { const zIndexFromInjection = vue.unref(zIndexInjection); return isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex; }); const currentZIndex = vue.computed(() => initialZIndex.value + zIndex.value); const nextZIndex = () => { zIndex.value++; return currentZIndex.value; }; return { initialZIndex, currentZIndex, nextZIndex }; }; buildProp({ type: String, values: componentSizes, required: false }); const SIZE_INJECTION_KEY = Symbol("size"); const configProviderContextKey = Symbol(); const globalConfig = vue.ref(); function useGlobalConfig(key, defaultValue = void 0) { const config = vue.getCurrentInstance() ? vue.inject(configProviderContextKey, globalConfig) : globalConfig; if (key) { return vue.computed(() => { var _a2, _b; return (_b = (_a2 = config.value) == null ? void 0 : _a2[key]) != null ? _b : defaultValue; }); } else { return config; } } function useGlobalComponentSettings(block, sizeFallback) { const config = useGlobalConfig(); const ns = useNamespace(block, vue.computed(() => { var _a2; return ((_a2 = config.value) == null ? void 0 : _a2.namespace) || defaultNamespace; })); const locale = useLocale(vue.computed(() => { var _a2; return (_a2 = config.value) == null ? void 0 : _a2.locale; })); const zIndex2 = useZIndex(vue.computed(() => { var _a2; return ((_a2 = config.value) == null ? void 0 : _a2.zIndex) || defaultInitialZIndex; })); const size = vue.computed(() => { var _a2; return vue.unref(sizeFallback) || ((_a2 = config.value) == null ? void 0 : _a2.size) || ""; }); provideGlobalConfig(vue.computed(() => vue.unref(config) || {})); return { ns, locale, zIndex: zIndex2, size }; } const provideGlobalConfig = (config, app, global2 = false) => { var _a2; const inSetup = !!vue.getCurrentInstance(); const oldConfig = inSetup ? useGlobalConfig() : void 0; const provideFn = (_a2 = app == null ? void 0 : app.provide) != null ? _a2 : inSetup ? vue.provide : void 0; if (!provideFn) { return; } const context = vue.computed(() => { const cfg = vue.unref(config); if (!(oldConfig == null ? void 0 : oldConfig.value)) return cfg; return mergeConfig(oldConfig.value, cfg); }); provideFn(configProviderContextKey, context); provideFn(localeContextKey, vue.computed(() => context.value.locale)); provideFn(namespaceContextKey, vue.computed(() => context.value.namespace)); provideFn(zIndexContextKey, vue.computed(() => context.value.zIndex)); provideFn(SIZE_INJECTION_KEY, { size: vue.computed(() => context.value.size || "") }); if (global2 || !globalConfig.value) { globalConfig.value = context.value; } return context; }; const mergeConfig = (a, b) => { var _a2; const keys = [.../* @__PURE__ */ new Set([...keysOf(a), ...keysOf(b)])]; const obj = {}; for (const key of keys) { obj[key] = (_a2 = b[key]) != null ? _a2 : a[key]; } return obj; }; var _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; const iconProps = buildProps({ size: { type: definePropType([Number, String]) }, color: { type: String } }); const __default__$1 = vue.defineComponent({ name: "ElIcon", inheritAttrs: false }); const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({ ...__default__$1, props: iconProps, setup(__props) { const props = __props; const ns = useNamespace("icon"); const style2 = vue.computed(() => { const { size, color } = props; if (!size && !color) return {}; return { fontSize: isUndefined(size) ? void 0 : addUnit(size), "--color": color }; }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("i", vue.mergeProps({ class: vue.unref(ns).b(), style: vue.unref(style2) }, _ctx.$attrs), [ vue.renderSlot(_ctx.$slots, "default") ], 16); }; } }); var Icon = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "icon.vue"]]); const ElIcon = withInstall(Icon); const notificationTypes = [ "success", "info", "warning", "error" ]; const notificationProps = buildProps({ customClass: { type: String, default: "" }, dangerouslyUseHTMLString: { type: Boolean, default: false }, duration: { type: Number, default: 4500 }, icon: { type: iconPropType }, id: { type: String, default: "" }, message: { type: definePropType([String, Object]), default: "" }, offset: { type: Number, default: 0 }, onClick: { type: definePropType(Function), default: () => void 0 }, onClose: { type: definePropType(Function), required: true }, position: { type: String, values: ["top-right", "top-left", "bottom-right", "bottom-left"], default: "top-right" }, showClose: { type: Boolean, default: true }, title: { type: String, default: "" }, type: { type: String, values: [...notificationTypes, ""], default: "" }, zIndex: Number }); const notificationEmits = { destroy: () => true }; const _hoisted_1 = ["id"]; const _hoisted_2 = ["textContent"]; const _hoisted_3 = { key: 0 }; const _hoisted_4 = ["innerHTML"]; const __default__ = vue.defineComponent({ name: "ElNotification" }); const _sfc_main = /* @__PURE__ */ vue.defineComponent({ ...__default__, props: notificationProps, emits: notificationEmits, setup(__props, { expose }) { const props = __props; const { ns, zIndex: zIndex2 } = useGlobalComponentSettings("notification"); const { nextZIndex, currentZIndex } = zIndex2; const { Close } = CloseComponents; const visible = vue.ref(false); let timer = void 0; const typeClass = vue.computed(() => { const type = props.type; return type && TypeComponentsMap[props.type] ? ns.m(type) : ""; }); const iconComponent = vue.computed(() => { if (!props.type) return props.icon; return TypeComponentsMap[props.type] || props.icon; }); const horizontalClass = vue.computed(() => props.position.endsWith("right") ? "right" : "left"); const verticalProperty = vue.computed(() => props.position.startsWith("top") ? "top" : "bottom"); const positionStyle = vue.computed(() => { var _a2; return { [verticalProperty.value]: `${props.offset}px`, zIndex: (_a2 = props.zIndex) != null ? _a2 : currentZIndex.value }; }); function startTimer() { if (props.duration > 0) { ({ stop: timer } = useTimeoutFn(() => { if (visible.value) close2(); }, props.duration)); } } function clearTimer() { timer == null ? void 0 : timer(); } function close2() { visible.value = false; } function onKeydown({ code }) { if (code === EVENT_CODE.delete || code === EVENT_CODE.backspace) { clearTimer(); } else if (code === EVENT_CODE.esc) { if (visible.value) { close2(); } } else { startTimer(); } } vue.onMounted(() => { startTimer(); nextZIndex(); visible.value = true; }); useEventListener(document, "keydown", onKeydown); expose({ visible, close: close2 }); return (_ctx, _cache) => { return vue.openBlock(), vue.createBlock(vue.Transition, { name: vue.unref(ns).b("fade"), onBeforeLeave: _ctx.onClose, onAfterLeave: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("destroy")), persisted: "" }, { default: vue.withCtx(() => [ vue.withDirectives(vue.createElementVNode("div", { id: _ctx.id, class: vue.normalizeClass([vue.unref(ns).b(), _ctx.customClass, vue.unref(horizontalClass)]), style: vue.normalizeStyle(vue.unref(positionStyle)), role: "alert", onMouseenter: clearTimer, onMouseleave: startTimer, onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args)) }, [ vue.unref(iconComponent) ? (vue.openBlock(), vue.createBlock(vue.unref(ElIcon), { key: 0, class: vue.normalizeClass([vue.unref(ns).e("icon"), vue.unref(typeClass)]) }, { default: vue.withCtx(() => [ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(iconComponent)))) ]), _: 1 }, 8, ["class"])) : vue.createCommentVNode("v-if", true), vue.createElementVNode("div", { class: vue.normalizeClass(vue.unref(ns).e("group")) }, [ vue.createElementVNode("h2", { class: vue.normalizeClass(vue.unref(ns).e("title")), textContent: vue.toDisplayString(_ctx.title) }, null, 10, _hoisted_2), vue.withDirectives(vue.createElementVNode("div", { class: vue.normalizeClass(vue.unref(ns).e("content")), style: vue.normalizeStyle(!!_ctx.title ? void 0 : { margin: 0 }) }, [ vue.renderSlot(_ctx.$slots, "default", {}, () => [ !_ctx.dangerouslyUseHTMLString ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_3, vue.toDisplayString(_ctx.message), 1)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [ vue.createCommentVNode(" Caution here, message could've been compromised, never use user's input as message "), vue.createElementVNode("p", { innerHTML: _ctx.message }, null, 8, _hoisted_4) ], 2112)) ]) ], 6), [ [vue.vShow, _ctx.message] ]), _ctx.showClose ? (vue.openBlock(), vue.createBlock(vue.unref(ElIcon), { key: 0, class: vue.normalizeClass(vue.unref(ns).e("closeBtn")), onClick: vue.withModifiers(close2, ["stop"]) }, { default: vue.withCtx(() => [ vue.createVNode(vue.unref(Close)) ]), _: 1 }, 8, ["class", "onClick"])) : vue.createCommentVNode("v-if", true) ], 2) ], 46, _hoisted_1), [ [vue.vShow, visible.value] ]) ]), _: 3 }, 8, ["name", "onBeforeLeave"]); }; } }); var NotificationConstructor = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "notification.vue"]]); const notifications = { "top-left": [], "top-right": [], "bottom-left": [], "bottom-right": [] }; const GAP_SIZE = 16; let seed = 1; const notify = function(options = {}, context = null) { if (!isClient) return { close: () => void 0 }; if (typeof options === "string" || vue.isVNode(options)) { options = { message: options }; } const position = options.position || "top-right"; let verticalOffset = options.offset || 0; notifications[position].forEach(({ vm: vm2 }) => { var _a2; verticalOffset += (((_a2 = vm2.el) == null ? void 0 : _a2.offsetHeight) || 0) + GAP_SIZE; }); verticalOffset += GAP_SIZE; const id = `notification_${seed++}`; const userOnClose = options.onClose; const props = { ...options, offset: verticalOffset, id, onClose: () => { close(id, position, userOnClose); } }; let appendTo = document.body; if (isElement(options.appendTo)) { appendTo = options.appendTo; } else if (isString(options.appendTo)) { appendTo = document.querySelector(options.appendTo); } if (!isElement(appendTo)) { appendTo = document.body; } const container = document.createElement("div"); const vm = vue.createVNode(NotificationConstructor, props, vue.isVNode(props.message) ? { default: () => props.message } : null); vm.appContext = context != null ? context : notify._context; vm.props.onDestroy = () => { vue.render(null, container); }; vue.render(vm, container); notifications[position].push({ vm }); appendTo.appendChild(container.firstElementChild); return { close: () => { vm.component.exposed.visible.value = false; } }; }; notificationTypes.forEach((type) => { notify[type] = (options = {}) => { if (typeof options === "string" || vue.isVNode(options)) { options = { message: options }; } return notify({ ...options, type }); }; }); function close(id, position, userOnClose) { const orientedNotifications = notifications[position]; const idx = orientedNotifications.findIndex(({ vm: vm2 }) => { var _a2; return ((_a2 = vm2.component) == null ? void 0 : _a2.props.id) === id; }); if (idx === -1) return; const { vm } = orientedNotifications[idx]; if (!vm) return; userOnClose == null ? void 0 : userOnClose(vm); const removedHeight = vm.el.offsetHeight; const verticalPos = position.split("-")[0]; orientedNotifications.splice(idx, 1); const len = orientedNotifications.length; if (len < 1) return; for (let i = idx; i < len; i++) { const { el, component } = orientedNotifications[i].vm; const pos = Number.parseInt(el.style[verticalPos], 10) - removedHeight - GAP_SIZE; component.props.offset = pos; } } function closeAll() { for (const orientedNotifications of Object.values(notifications)) { orientedNotifications.forEach(({ vm }) => { vm.component.exposed.visible.value = false; }); } } notify.closeAll = closeAll; notify._context = null; const ElNotification = withInstallFunction(notify, "$notify"); const jsttCompileConfigOptions = { bannerComment: "", format: false, style: { bracketSpacing: false, printWidth: 120, semi: true, singleQuote: true, tabWidth: 2, trailingComma: "none", useTabs: false }, strictIndexSignatures: true }; function compileJSONSchema2TS(schema, name) { return jstt.compile(schema, name, jsttCompileConfigOptions).then((code) => formatComment2SingleLine(code)).catch((err) => console.error(err)); } function formatComment2SingleLine(content = "") { return content.replace( /\/\*([^/]*)\*\//gm, (_2, p1) => `/** ${p1.replace(/[*\s\n]/gm, "")} */` ).replaceAll("string &", ""); } const getDetail = (id) => { return fetch(`http://172.16.101.32:7700/api/interface/get?id=${id}`).then((res) => res.json()).then((res) => { return res.data; }); }; const fetchData = () => { if (!location.href.includes("api/cat_")) { return getDetail(location.href.match(/api\/(\d+)/)[1]); } else { return Promise.reject(new Error("请在接口详情页使用")); } }; function copy(text) { ElNotification({ title: "复制成功", dangerouslyUseHTMLString: true, message: hljs.highlight(text, { language: "typescript" }).value, type: "success" }); _GM_setClipboard(text); } function requestName(item) { return _.camelCase( item.path.replace(/\{(.*)\}$/, "_by_$1").replaceAll("/", "_").replace(/^_/, "").replace(/_$/, "") ); } function paramsDto(item) { return _.upperFirst(requestName(item)) + "ParamsDto"; } function dataDto(item) { return _.upperFirst(requestName(item)) + "DataDto"; } function convertType(type) { return { int32: "number", int64: "number" }[type] || type || "any"; } function isCate() { const matched = location.href.match(/cat_(\d+)$/); return !!matched; } function isAll() { const matched = location.href.match(/interface\/api$/); return !!matched; } async function copyRequest(item) { const isAxiosNative = localStorage.getItem("axios-native") === "true"; const data = item || await fetchData(); const name = requestName(data); let arg = ""; let argType = ""; if (_.size(data.req_query)) { arg = "params"; argType = ": " + (settingsVm.anyType ? "any" : paramsDto(data)); } if (_.size(data.req_body_other)) { arg = "data"; argType = ": " + (settingsVm.anyType ? "any" : dataDto(data)); } let pathArg = ""; if (_.size(data.req_params)) { data.req_params.forEach((item2) => { pathArg += `${item2.name}: ${convertType(item2.type)},`; }); } const responseDto = settingsVm.anyType ? "any" : _.upperFirst(name) + "ResponseDto"; let text = ` // ${data.title} 作者: ${data.username} http://172.16.101.32:7700/project/${data.project_id}/interface/api/${data._id} `; if (isAxiosNative) { text += `export function ${name}(${pathArg}${arg}${argType}): Promise<${responseDto}> { return axiosRequest.${_.toLower(data.method)}( \`${data.path.replaceAll("{", "${")}\`,${arg ? "{" + arg + "}" : ""}) }`; } else { text += `export function ${name}(${pathArg}${arg}${argType}): Promise<${responseDto}> { return axiosRequest.${_.toLower(data.method)}({ url: \`${data.path.replaceAll("{", "${")}\`, ${arg} }) }`; } if (item) { return text; } else { copy(text); } } async function copyGroupRequest() { const href = location.href; const matched = href.match(/cat_(\d+)$/); const id = matched == null ? void 0 : matched[1]; const list = await fetch( id ? `http://172.16.101.32:7700/api/interface/list_cat?page=1&limit=9999&catid=${id}` : `http://172.16.101.32:7700/api/interface/list?page=1&limit=9999&project_id=${projectId}` ).then((res) => res.json()).then((res) => { return res.data.list; }); let text = ""; const resList = await Promise.all(list.map((item) => getDetail(item._id))); for (const data of resList) { text += await copyRequest(data); } copy(text); } async function copyInterface(item) { const data = item || await fetchData(); const name = requestName(data); let text = `// ${data.title} 作者: ${data.username} http://172.16.101.32:7700/project/${data.project_id}/interface/api/${data._id}`; let text1 = ""; let text2 = ""; if (data.req_body_other || data.req_body) { text2 = await compileJSONSchema2TS( JSON.parse(data.req_body_other || data.req_body), dataDto(data) ); text2 = text2.replaceAll("number & string", "number"); } let text3 = await compileJSONSchema2TS( JSON.parse(data.res_body), `${_.upperFirst(name)}ResponseDto` ); text3 = text3.replaceAll("?: ", ": "); const result = _.compact([text, text1, text2, text3]).join("\n"); if (item) { return result; } else { copy(result); } } async function copyGroupInterface(event) { const href = location.href; const matched = href.match(/cat_(\d+)$/); const id = matched == null ? void 0 : matched[1]; const list = await fetch( id ? `http://172.16.101.32:7700/api/interface/list_cat?page=1&limit=9999&catid=${id}` : `http://172.16.101.32:7700/api/interface/list?page=1&limit=9999&project_id=${projectId}` ).then((res) => res.json()).then((res) => { return res.data.list; }); let text = ""; const resList = await Promise.all(list.map((item) => getDetail(item._id))); for (const data of resList) { text += await copyInterface(data); } copy(text); } async function copyResponseParameterInterface() { const data = await fetchData(); const text = ``; const name = requestName(data); let content = await compileJSONSchema2TS( JSON.parse(data.res_body), _.upperFirst(name) + "ResponseDto" ); content = content.replaceAll("?: ", ": "); copy(text + content); } async function copyBodyParameterInterface() { const data = await fetchData(); const text = ``; requestName(data); const content = await compileJSONSchema2TS( JSON.parse(data.req_body_other), dataDto(data) ); copy(text + content); } _GM_addStyle( "@import url('https://cdn.bootcdn.net/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css');" ); _GM_addStyle( "@import url('https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.12/index.min.css');" ); window.projectId = location.href.match(/project\/(\d+)/)[1]; window.settingsVm = {}; function insertButton() { if (document.querySelector(".copy-request")) { return; } if (!document.querySelector(".interface-title")) { return; } const requestParams = $(".interface-title:contains('基本信息')"); if (requestParams.length) { const checked = localStorage.getItem("axios-native") === "true"; requestParams.append( '<button class="copy-request ant-btn ant-btn-primary ant-btn-md" style="margin-left:10px;">req</button>' ); requestParams.append( '<button class="copy-interface ant-btn ant-btn-primary ant-btn-md" style="margin-left:10px;">ts</button>' ); requestParams.append( `<label><input type="checkbox" class="set-axios-native" ${checked ? "checked" : ""} style="margin:0 10px;" />native axios</label>` ); document.querySelector(".copy-request").addEventListener("click", () => copyRequest()); document.querySelector(".copy-interface").addEventListener("click", () => copyInterface()); document.querySelector(".set-axios-native").addEventListener("change", (event) => { localStorage.setItem("axios-native", event.target.checked); }); } const bodyParameter = $(".col-title:contains('Body:')"); if (bodyParameter.length) { bodyParameter.append( '<button class="body-parameter-copy-request ant-btn ant-btn-primary ant-btn-md" style="margin-left:10px;">ts</button>' ); document.querySelector(".body-parameter-copy-request").addEventListener("click", copyBodyParameterInterface); } const responseParameter = $(".interface-title:contains('返回数据')"); if (responseParameter.length) { responseParameter.append( '<button class="response-parameter-copy-request ant-btn ant-btn-primary ant-btn-md" style="margin-left:10px;">ts</button>' ); document.querySelector(".response-parameter-copy-request").addEventListener("click", copyResponseParameterInterface); } } function insertGroupButton() { if (document.querySelector(".group-copy-request")) { return; } if (document.querySelector(".group-copy-interface")) { return; } const title = $(".interface-title").next().next().children(); if (isAll()) { title.append(`<div></div>`); } title.append(`“ <div> <button class="group-copy-request ant-btn ant-btn-primary ant-btn-md" style="padding: 1px 6px;font-size: 12px;width: 60px">req</button> <button class="group-copy-interface ant-btn ant-btn-primary ant-btn-md" style="padding: 1px 6px;font-size: 12px;width: 60px">ts</button> </div> `); $(".group-copy-request").on("click", copyGroupRequest); $(".group-copy-interface").on("click", copyGroupInterface); } function insertPathName() { $(".copy-request-func").remove(); const funcName = requestName({ path: $(".interface-url-icon").prev().text() }); $(".interface-url-icon").parent().append( `<button class="copy-request-func ant-btn ant-btn-primary ant-btn-md" style="margin-left:10px;">${funcName}</button>` ); document.querySelector(".copy-request-func").addEventListener("click", () => copy(funcName)); } const path = vue.ref(""); setInterval(() => { path.value = location.pathname; }, 100); vue.watch(path, async (val) => { if (isCate() || isAll()) { setTimeout(() => { insertGroupButton(); }, 100); } else { setTimeout(() => { insertButton(); insertPathName(); }, 100); } }); })(Vue);