mvframe 1.0.4

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/store.js ADDED
@@ -0,0 +1,155 @@
1
+ import { createPinia as g, defineStore as h } from "pinia";
2
+ const T = () => ({
3
+ lang: "en_us"
4
+ }), y = {
5
+ saveData(t, e) {
6
+ this[t] = e;
7
+ },
8
+ setLang(t) {
9
+ this.lang = t;
10
+ }
11
+ }, $ = {
12
+ state: T,
13
+ actions: y
14
+ }, S = () => ({
15
+ useTab: !1,
16
+ // 是否使用tab
17
+ tabs: [],
18
+ ctab: {}
19
+ // current tab
20
+ }), d = {
21
+ saveData(t, e) {
22
+ this[t] = e;
23
+ },
24
+ saveCurrentTab(t) {
25
+ this.ctab = t, localStorage.setItem("ctab", JSON.stringify(t));
26
+ },
27
+ saveTab(t) {
28
+ const { data: e, index: s } = this.tabs.filter1((r) => r.name === t.name);
29
+ if (e)
30
+ if (JSON.stringify(e.params) === JSON.stringify(t.params) && JSON.stringify(e.query) === JSON.stringify(t.query)) {
31
+ this.saveCurrentTab(e);
32
+ return;
33
+ } else
34
+ this.closeTab(e, s);
35
+ const { fullPath: a, name: i, meta: n, params: c, query: u } = t;
36
+ if (i !== "Login") {
37
+ const r = a.split("/");
38
+ let l;
39
+ r[r.length - 1] === "Home" ? l = r[r.length - 2] : l = r[r.length - 1], n.icon && (l = n.icon);
40
+ const b = {
41
+ name: i,
42
+ meta: n,
43
+ path: r,
44
+ params: c,
45
+ query: u,
46
+ icon: l
47
+ }, { index: m } = this.tabs.filter1((p) => p.name === this.ctab.name);
48
+ this.tabs.splice(m + 1, 0, b), this.saveCurrentTab(b);
49
+ }
50
+ },
51
+ closeTab(t, e) {
52
+ var s;
53
+ this.tabs.splice(e, 1), t.name === this.ctab.name && ((s = globalThis.$router) == null || s.push({ name: this.tabs[e - 1 > 0 ? e - 1 : 0].name }));
54
+ },
55
+ closeRightTab(t, e) {
56
+ var i;
57
+ const s = [];
58
+ let a = !1;
59
+ this.tabs.forEach((n, c) => {
60
+ e >= c ? s.push(n) : n.name === this.ctab.name && (a = !0);
61
+ }), this.tabs = s, a && ((i = globalThis.$router) == null || i.push({ name: t.name }));
62
+ },
63
+ closeLeftTab(t, e) {
64
+ var i;
65
+ const s = [];
66
+ let a = !1;
67
+ this.tabs.forEach((n, c) => {
68
+ e <= c ? s.push(n) : n.name === this.ctab.name && (a = !0);
69
+ }), this.tabs = s, a && ((i = globalThis.$router) == null || i.push({ name: t.name }));
70
+ },
71
+ closeOtherTab(t, e) {
72
+ var s;
73
+ this.tabs = [t], t.name !== this.ctab.name && ((s = globalThis.$router) == null || s.push({ name: t.name }));
74
+ },
75
+ closeAllTab() {
76
+ this.tabs = [];
77
+ }
78
+ }, v = {}, w = {
79
+ state: S,
80
+ actions: d,
81
+ getters: v
82
+ }, O = () => ({
83
+ type: "",
84
+ visible: !1,
85
+ options: [],
86
+ el: null,
87
+ position: {
88
+ x: 0,
89
+ y: 0
90
+ }
91
+ }), J = {
92
+ saveData(t, e) {
93
+ this[t] = e;
94
+ },
95
+ show({ el: t, position: e }) {
96
+ this.visible = !0, e ? this.position = e : t && (this.el = t);
97
+ },
98
+ hide() {
99
+ this.visible = !1, this.el = null, this.position = {
100
+ x: 0,
101
+ y: 0
102
+ }, this.type = "";
103
+ }
104
+ }, N = {}, x = {
105
+ state: O,
106
+ actions: J,
107
+ getters: N
108
+ }, D = g(), o = {}, E = (t) => {
109
+ Object.entries(t).forEach(([e, s]) => {
110
+ const a = e.match(/chip\/(.+?)\.js$/);
111
+ if (!a || !(s != null && s.default)) {
112
+ console.warn(`Invalid store module: ${e}`);
113
+ return;
114
+ }
115
+ const i = a[1].replace(/\//g, "_");
116
+ try {
117
+ o[i] = h(i, s.default);
118
+ } catch (n) {
119
+ console.error(`Failed to register store module '${i}':`, n);
120
+ }
121
+ });
122
+ };
123
+ o.init = h("init", $);
124
+ o.tab = h("tab", w);
125
+ o.rmenu = h("rmenu", x);
126
+ const f = (t) => {
127
+ try {
128
+ switch (window.$getType(t)) {
129
+ case "Array":
130
+ t.forEach(f);
131
+ break;
132
+ case "String":
133
+ const s = localStorage.getItem(t);
134
+ s && o.tab().saveData(t, JSON.parse(s));
135
+ break;
136
+ default:
137
+ t = [], console.warn(`Invalid key: ${t}`);
138
+ break;
139
+ }
140
+ } catch (e) {
141
+ console.error(`Failed to parse '${t}' from localStorage:`, e);
142
+ }
143
+ }, I = (t, { storeChips: e, useTab: s } = {}) => {
144
+ try {
145
+ t.use(D).provide("store", o);
146
+ } catch (a) {
147
+ throw new Error("Failed to inject store into app:", a);
148
+ }
149
+ return s && (o.tab().saveData("useTab", !0), f(["tabs", "ctab"])), e && E(e), o;
150
+ };
151
+ export {
152
+ I as a,
153
+ D as p,
154
+ o as s
155
+ };
package/dist/util.js ADDED
@@ -0,0 +1,196 @@
1
+ const I = (s) => {
2
+ const f = (e) => {
3
+ if (e.startsWith("/"))
4
+ return new URL(e, import.meta.url).href;
5
+ if (e)
6
+ return new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
7
+ throw new Error("please provide an image url with getImg");
8
+ };
9
+ s.config.globalProperties.$getImg = f, globalThis.$getImg = f, globalThis.$getLang = () => localStorage.getItem("lang") || globalThis.config.lang || "en_us", globalThis.token = "WQpvrYIEnSzAxhOWrbUpGvElhGztdOjOGOdbrSlhUYlrQArOdpMhY1vYMSA7l4xMOUl9MAl1I6AvSrQ8vlE0bpChQ0UWMMlYt0hQC0M0pSz0rUhvlIllSWzMESnAMUlt";
10
+ const m = (e) => Number(e.match(/\d+(\.\d+)?/g).join(""));
11
+ globalThis.$md5 = (e) => m(e);
12
+ const $ = (e, r = 0) => {
13
+ let o = parseInt(Math.random() * e);
14
+ return o += r, o;
15
+ };
16
+ globalThis.$rn = $;
17
+ const y = (e, r) => {
18
+ let o = [];
19
+ for (let t = 0; t < e; t++)
20
+ o.push(r(t));
21
+ return o;
22
+ };
23
+ globalThis.$fd = y;
24
+ const u = (e, r = !1) => e.substr(0, 1).toUpperCase() + (r ? e.substr(1, e.length).toLowerCase() : e.substr(1, e.length));
25
+ s.config.globalProperties.$toUpperCamel = u, globalThis.$toUpperCamel = u;
26
+ const g = (e, r = 2) => {
27
+ const o = globalThis.$getType(e);
28
+ let t;
29
+ o === "Number" ? (e = e.toFixed(r), t = String(e), e = String(Math.abs(e))) : o === "String" && (t = e, e = String(Math.abs(Number(e))));
30
+ const n = e.split(".");
31
+ let l = n[0].split("");
32
+ l = l.reverse();
33
+ let a = [];
34
+ l.forEach((A, d) => {
35
+ d !== 0 && d % 3 === 0 && a.push(","), a.push(A);
36
+ });
37
+ let i = a.reverse().join("");
38
+ return globalThis.$getType(r) === "Number" && r > 0 && (i += ".", n[1] ? i += n[1].padEnd(r, 0).substr(0, r) : i += "0".padEnd(r, "0")), Number(t) !== Number(e) ? `-${i}` : i;
39
+ };
40
+ globalThis.$fa = g, s.config.globalProperties.$fa = g;
41
+ const T = (e, r) => {
42
+ var n, l;
43
+ const o = r == null ? void 0 : r[e];
44
+ if (o != null)
45
+ return o;
46
+ const t = (l = (n = globalThis.$config) == null ? void 0 : n.table) == null ? void 0 : l.summaryMetric;
47
+ return t == null ? null : typeof t == "function" ? t(e) ?? null : t[e] ?? null;
48
+ }, p = ({ prop: e, currency: r, value: o, obj: t }) => {
49
+ const n = T(e, t);
50
+ if (n == null || typeof n != "object")
51
+ return globalThis.$fa(o, 2);
52
+ if (n.unit === "currency") {
53
+ const l = r ?? n.currency;
54
+ return l ? `${l} ${globalThis.$fa(o, n == null ? void 0 : n.precision)}` : globalThis.$fa(o, n == null ? void 0 : n.precision);
55
+ }
56
+ return n.unit === "%" ? `${globalThis.$fa(o, n == null ? void 0 : n.precision)}%` : globalThis.$fa(o, n == null ? void 0 : n.precision);
57
+ };
58
+ globalThis.$fu = p, s.config.globalProperties.$fu = p;
59
+ const C = (e = () => {
60
+ }, r = 2) => {
61
+ const o = Math.max(0, Number(r) || 2) * 100;
62
+ return new Promise((t, n) => {
63
+ setTimeout(() => {
64
+ try {
65
+ const l = e();
66
+ l != null && typeof l.then == "function" ? Promise.resolve(l).then((a) => t(a === void 0 ? !0 : a)).catch(n) : t(l === void 0 ? !0 : l);
67
+ } catch (l) {
68
+ n(l);
69
+ }
70
+ }, o);
71
+ });
72
+ };
73
+ globalThis.$pm = C;
74
+ const k = (e = () => {
75
+ }, r = 500) => {
76
+ let o;
77
+ return function(...t) {
78
+ o && clearTimeout(o), o = setTimeout(() => {
79
+ e.apply(this, t);
80
+ }, r);
81
+ };
82
+ };
83
+ globalThis.$db = k, Number.prototype.toFixedNumber = function(e) {
84
+ return Number(this.toFixed(e));
85
+ }, Array.prototype.filter1 = function(e) {
86
+ if (!e || typeof e != "function")
87
+ throw new Error(e + " is not a function");
88
+ let r, o;
89
+ for (let t = 0; t < this.length; t++)
90
+ if (e(this[t], t, this)) {
91
+ o = t, r = this[t];
92
+ break;
93
+ }
94
+ return {
95
+ index: o,
96
+ data: r
97
+ };
98
+ }, globalThis.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
99
+ const b = (e) => {
100
+ var o;
101
+ const r = (o = s.config.globalProperties) == null ? void 0 : o.$message;
102
+ r != null && r.success && r.success({ message: e, center: !0, duration: 5e3 });
103
+ }, h = (e, r) => {
104
+ var n;
105
+ if (!e) {
106
+ console.info("No Value");
107
+ return;
108
+ }
109
+ const o = ((n = globalThis.$l) == null ? void 0 : n.call(globalThis, "Copied")) || "Copied";
110
+ let t;
111
+ if (r ? globalThis.$getType(r) !== "Boolean" ? t = `${o} ${r}: ${e}` : t = `${o}: ${e}` : t = o, navigator.clipboard && globalThis.isSecureContext)
112
+ navigator.clipboard.writeText(e).then(() => b(t));
113
+ else {
114
+ let l = document.createElement("textarea");
115
+ l.value = e, l.style.position = "fixed", l.style.opacity = 0, document.body.appendChild(l), l.select(), document.execCommand("Copy"), l.remove(), b(t);
116
+ }
117
+ };
118
+ globalThis.$copy = h, s.config.globalProperties.$copy = h;
119
+ const w = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "k" : parseInt(e / 1e6) + "m";
120
+ globalThis.$sc = w;
121
+ const F = {
122
+ cpa: "avgCPA",
123
+ cpt: "avgCPT"
124
+ }, M = (e, r = F) => {
125
+ const o = r[e.name];
126
+ o && (e.name = o);
127
+ };
128
+ globalThis.$nr = M;
129
+ const x = (e, r) => (Object.keys(e).forEach((o) => {
130
+ objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
131
+ }), e);
132
+ globalThis.$nro = x;
133
+ const O = (e) => {
134
+ let r = 0;
135
+ return Object.keys(e).forEach((o) => {
136
+ (globalThis.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && r++;
137
+ }), r;
138
+ };
139
+ globalThis.$pc = O;
140
+ const c = {
141
+ info: {
142
+ tag: "background-color:#0085FF; color:#f1f7ff; border-radius: 2px 0 0 2px;",
143
+ style: "background-color:#f1f7ff; color:#0085FF;"
144
+ },
145
+ log: {
146
+ tag: "background-color:#FFFFFF; color:#272b41; border-radius: 2px 0 0 2px;",
147
+ style: "background-color:#272b41; color:#FFFFFF;"
148
+ },
149
+ error: {
150
+ tag: "background-color:#ff4d4f; color:#fff3f3; border-radius: 2px 0 0 2px;",
151
+ style: "background-color:#fff3f3; color:#ff4d4f;"
152
+ },
153
+ warn: {
154
+ tag: "background-color:#fa8b0c; color:#fffbf6; border-radius: 2px 0 0 2px;",
155
+ style: "background-color:#fffbf6; color:#fa8b0c;"
156
+ },
157
+ success: {
158
+ tag: "background-color:#20c997; color:#f6fffc; border-radius: 2px 0 0 2px;",
159
+ style: "background-color:#f6fffc; color:#20c997;"
160
+ }
161
+ }, S = (e) => {
162
+ let r = !1;
163
+ for (let o in e)
164
+ if (globalThis.$getType(e[o]) === "Object") {
165
+ r = !0;
166
+ break;
167
+ }
168
+ return r;
169
+ }, U = ["info", "log", "warn", "error", "success"];
170
+ globalThis.$c = {}, U.forEach((e) => {
171
+ globalThis.$c[e] = (...r) => {
172
+ const o = e.toUpperCase();
173
+ S(r) ? (console.groupCollapsed(`%c ${o} `, `${c[e].tag}`), console[e](r), console.groupEnd()) : console.info(
174
+ `%c ${o} %c┆${r}┆`,
175
+ `${c[e].tag}`,
176
+ `${c[e].style}`
177
+ );
178
+ };
179
+ }), window.$deepClone = function(e) {
180
+ if (e == null)
181
+ return e;
182
+ const r = window.$getType(e);
183
+ if (r !== "Object" && r !== "Array")
184
+ return e;
185
+ let o = r === "Array" ? [] : {};
186
+ for (let t in e)
187
+ if (Object.prototype.hasOwnProperty.call(e, t)) {
188
+ const n = window.$getType(e[t]);
189
+ n === "Object" || n === "Array" ? o[t] = window.$deepClone(e[t]) : o[t] = e[t];
190
+ }
191
+ return o;
192
+ };
193
+ };
194
+ export {
195
+ I as u
196
+ };
package/dist/vendor.js ADDED
@@ -0,0 +1,87 @@
1
+ import "vue";
2
+ import { u as s } from "./util.js";
3
+ import { d as c } from "./directive.js";
4
+ import { s as m, p as u, a as p } from "./store.js";
5
+ import { createRouter as f, createWebHistory as l } from "vue-router";
6
+ import { _ as v } from "./cpt/BtnGroup.js";
7
+ import { _ as b } from "./cpt/Form.js";
8
+ import { _ as d } from "./cpt/Frame.js";
9
+ import { _ as g } from "./cpt/Icon.js";
10
+ import { _ as y } from "./cpt/Input.js";
11
+ import { _ as h } from "./cpt/Page.js";
12
+ import { _ as x } from "./cpt/Select.js";
13
+ import { _ as O } from "./cpt/SelectV2.js";
14
+ import { _ as j } from "./cpt/Table.js";
15
+ import { _ as T } from "./cpt/Tabs.js";
16
+ import { _ as M } from "./cpt/Textarea.js";
17
+ const P = ({ router: e, useAdmin: t, adminPermission: o, noaccess: r }) => {
18
+ e.beforeEach((n, a, i) => {
19
+ t ? n.meta.admin && o() ? i() : r && r(i) : i();
20
+ }), e.afterEach((n, a) => {
21
+ const i = m.tab(u);
22
+ document.title = n.meta.title, i.saveTab(n);
23
+ });
24
+ }, E = (e, { routes: t, guard: o, useAdmin: r = !1, adminPermission: n = () => !0, noaccess: a }) => {
25
+ const i = f({
26
+ history: l(),
27
+ routes: t
28
+ });
29
+ o && o(i), P({ router: i, useAdmin: r, adminPermission: n, noaccess: a }), e.use(i), globalThis.$router = i;
30
+ }, K = (e, t) => {
31
+ const o = e.__vccOpts || e;
32
+ for (const [r, n] of t)
33
+ o[r] = n;
34
+ return o;
35
+ };
36
+ function L(e) {
37
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
38
+ }
39
+ function Q(e) {
40
+ if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
41
+ var t = e.default;
42
+ if (typeof t == "function") {
43
+ var o = function r() {
44
+ return this instanceof r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
45
+ };
46
+ o.prototype = t.prototype;
47
+ } else o = {};
48
+ return Object.defineProperty(o, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
49
+ var n = Object.getOwnPropertyDescriptor(e, r);
50
+ Object.defineProperty(o, r, n.get ? n : {
51
+ enumerable: !0,
52
+ get: function() {
53
+ return e[r];
54
+ }
55
+ });
56
+ }), o;
57
+ }
58
+ const _ = /* @__PURE__ */ Object.assign({ "../component/BtnGroup/index.vue": v, "../component/Form/index.vue": b, "../component/Frame/index.vue": d, "../component/Icon/index.vue": g, "../component/Input/index.vue": y, "../component/Page/index.vue": h, "../component/Select/index.vue": x, "../component/SelectV2/index.vue": O, "../component/Table/index.vue": j, "../component/Tabs/index.vue": T, "../component/Textarea/index.vue": M }), F = (e) => {
59
+ for (let t in _) {
60
+ let o = t.match(/\.\.\/component\/(.*)\/index.vue/)[1];
61
+ e.component(o, _[t].default);
62
+ }
63
+ }, w = {
64
+ name: "Matt Avias Frame",
65
+ copyright: "©2026",
66
+ version: "1.0.4",
67
+ author: "Matt Avias",
68
+ date: "2026-02-26",
69
+ /** Table 等表格默认;业务在 app.use(mvframe, { config }) 里覆盖 */
70
+ table: {
71
+ /** 同 Table 的 summary-metric:{ [prop]: { unit, precision, currency } } 或 (prop) => metric */
72
+ summaryMetric: null
73
+ }
74
+ }, A = (e, t = {}) => {
75
+ globalThis.$config = {
76
+ ...w,
77
+ ...t
78
+ };
79
+ }, U = (e, t) => {
80
+ e.use(A, t.config).use(F).use(s).use(c).use(p, t.pinia).use(E, t.vueRouter);
81
+ };
82
+ export {
83
+ K as _,
84
+ Q as a,
85
+ L as g,
86
+ U as i
87
+ };