mvframe 1.0.10 → 1.0.13
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/Config.js +200 -0
- package/dist/composition.js +267 -133
- package/dist/css/cpt.css +1 -1
- package/dist/css/style.css +1 -1
- package/dist/index.js +2003 -1050
- package/dist/store.js +40 -33
- package/dist/util.js +23 -19
- package/package.json +4 -1
- package/scripts/scaffold-app.js +16 -9
package/dist/store.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { createPinia as
|
|
1
|
+
import { createPinia as p, defineStore as h } from "pinia";
|
|
2
2
|
const T = () => ({
|
|
3
|
-
lang: "en_us"
|
|
3
|
+
lang: "en_us",
|
|
4
|
+
/** 路由切换 / 异步页面 chunk 加载期间为 true,由 router guard 维护 */
|
|
5
|
+
pageLoading: !1
|
|
4
6
|
}), y = {
|
|
5
7
|
saveData(t, e) {
|
|
6
8
|
this[t] = e;
|
|
7
9
|
},
|
|
8
10
|
setLang(t) {
|
|
9
11
|
this.lang = t;
|
|
12
|
+
},
|
|
13
|
+
setPageLoading(t) {
|
|
14
|
+
this.pageLoading = !!t;
|
|
10
15
|
}
|
|
11
16
|
}, $ = {
|
|
12
17
|
state: T,
|
|
13
18
|
actions: y
|
|
14
|
-
},
|
|
19
|
+
}, d = () => ({
|
|
15
20
|
useTab: !1,
|
|
16
21
|
// 是否使用tab
|
|
17
22
|
tabs: [],
|
|
18
23
|
ctab: {}
|
|
19
24
|
// current tab
|
|
20
|
-
}),
|
|
25
|
+
}), S = {
|
|
21
26
|
saveData(t, e) {
|
|
22
27
|
this[t] = e;
|
|
23
28
|
},
|
|
@@ -32,19 +37,19 @@ const T = () => ({
|
|
|
32
37
|
return;
|
|
33
38
|
} else
|
|
34
39
|
this.closeTab(e, s);
|
|
35
|
-
const { fullPath: a, name:
|
|
36
|
-
if (
|
|
40
|
+
const { fullPath: a, name: n, meta: i, params: c, query: u } = t;
|
|
41
|
+
if (n !== "Login") {
|
|
37
42
|
const r = a.split("/");
|
|
38
43
|
let l;
|
|
39
|
-
r[r.length - 1] === "Home" ? l = r[r.length - 2] : l = r[r.length - 1],
|
|
44
|
+
r[r.length - 1] === "Home" ? l = r[r.length - 2] : l = r[r.length - 1], i.icon && (l = i.icon);
|
|
40
45
|
const b = {
|
|
41
|
-
name:
|
|
42
|
-
meta:
|
|
46
|
+
name: n,
|
|
47
|
+
meta: i,
|
|
43
48
|
path: r,
|
|
44
49
|
params: c,
|
|
45
50
|
query: u,
|
|
46
51
|
icon: l
|
|
47
|
-
}, { index: m } = this.tabs.filter1((
|
|
52
|
+
}, { index: m } = this.tabs.filter1((g) => g.name === this.ctab.name);
|
|
48
53
|
this.tabs.splice(m + 1, 0, b), this.saveCurrentTab(b);
|
|
49
54
|
}
|
|
50
55
|
},
|
|
@@ -53,20 +58,20 @@ const T = () => ({
|
|
|
53
58
|
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
59
|
},
|
|
55
60
|
closeRightTab(t, e) {
|
|
56
|
-
var
|
|
61
|
+
var n;
|
|
57
62
|
const s = [];
|
|
58
63
|
let a = !1;
|
|
59
|
-
this.tabs.forEach((
|
|
60
|
-
e >= c ? s.push(
|
|
61
|
-
}), this.tabs = s, a && ((
|
|
64
|
+
this.tabs.forEach((i, c) => {
|
|
65
|
+
e >= c ? s.push(i) : i.name === this.ctab.name && (a = !0);
|
|
66
|
+
}), this.tabs = s, a && ((n = globalThis.$router) == null || n.push({ name: t.name }));
|
|
62
67
|
},
|
|
63
68
|
closeLeftTab(t, e) {
|
|
64
|
-
var
|
|
69
|
+
var n;
|
|
65
70
|
const s = [];
|
|
66
71
|
let a = !1;
|
|
67
|
-
this.tabs.forEach((
|
|
68
|
-
e <= c ? s.push(
|
|
69
|
-
}), this.tabs = s, a && ((
|
|
72
|
+
this.tabs.forEach((i, c) => {
|
|
73
|
+
e <= c ? s.push(i) : i.name === this.ctab.name && (a = !0);
|
|
74
|
+
}), this.tabs = s, a && ((n = globalThis.$router) == null || n.push({ name: t.name }));
|
|
70
75
|
},
|
|
71
76
|
closeOtherTab(t, e) {
|
|
72
77
|
var s;
|
|
@@ -76,8 +81,8 @@ const T = () => ({
|
|
|
76
81
|
this.tabs = [];
|
|
77
82
|
}
|
|
78
83
|
}, v = {}, w = {
|
|
79
|
-
state:
|
|
80
|
-
actions:
|
|
84
|
+
state: d,
|
|
85
|
+
actions: S,
|
|
81
86
|
getters: v
|
|
82
87
|
}, O = () => ({
|
|
83
88
|
type: "",
|
|
@@ -88,7 +93,7 @@ const T = () => ({
|
|
|
88
93
|
x: 0,
|
|
89
94
|
y: 0
|
|
90
95
|
}
|
|
91
|
-
}),
|
|
96
|
+
}), L = {
|
|
92
97
|
saveData(t, e) {
|
|
93
98
|
this[t] = e;
|
|
94
99
|
},
|
|
@@ -101,28 +106,30 @@ const T = () => ({
|
|
|
101
106
|
y: 0
|
|
102
107
|
}, this.type = "";
|
|
103
108
|
}
|
|
104
|
-
}, N = {},
|
|
109
|
+
}, N = {}, J = {
|
|
105
110
|
state: O,
|
|
106
|
-
actions:
|
|
111
|
+
actions: L,
|
|
107
112
|
getters: N
|
|
108
|
-
},
|
|
113
|
+
}, x = p(), o = {}, D = (t) => {
|
|
114
|
+
const e = t.match(/(?:^|[/\\])([^/\\]+)\.js$/);
|
|
115
|
+
return e ? e[1] : null;
|
|
116
|
+
}, E = (t) => {
|
|
109
117
|
Object.entries(t).forEach(([e, s]) => {
|
|
110
|
-
const a = e
|
|
118
|
+
const a = D(e);
|
|
111
119
|
if (!a || !(s != null && s.default)) {
|
|
112
120
|
console.warn(`Invalid store module: ${e}`);
|
|
113
121
|
return;
|
|
114
122
|
}
|
|
115
|
-
const i = a[1].replace(/\//g, "_");
|
|
116
123
|
try {
|
|
117
|
-
o[
|
|
124
|
+
o[a] = h(a, s.default);
|
|
118
125
|
} catch (n) {
|
|
119
|
-
console.error(`Failed to register store module '${
|
|
126
|
+
console.error(`Failed to register store module '${a}':`, n);
|
|
120
127
|
}
|
|
121
128
|
});
|
|
122
129
|
};
|
|
123
130
|
o.init = h("init", $);
|
|
124
131
|
o.tab = h("tab", w);
|
|
125
|
-
o.rmenu = h("rmenu",
|
|
132
|
+
o.rmenu = h("rmenu", J);
|
|
126
133
|
const f = (t) => {
|
|
127
134
|
try {
|
|
128
135
|
switch (window.$getType(t)) {
|
|
@@ -140,16 +147,16 @@ const f = (t) => {
|
|
|
140
147
|
} catch (e) {
|
|
141
148
|
console.error(`Failed to parse '${t}' from localStorage:`, e);
|
|
142
149
|
}
|
|
143
|
-
},
|
|
150
|
+
}, F = (t, { storeChips: e, useTab: s } = {}) => {
|
|
144
151
|
try {
|
|
145
|
-
t.use(
|
|
152
|
+
t.use(x).provide("store", o);
|
|
146
153
|
} catch (a) {
|
|
147
154
|
throw new Error("Failed to inject store into app:", a);
|
|
148
155
|
}
|
|
149
156
|
return s && (o.tab().saveData("useTab", !0), f(["tabs", "ctab"])), e && E(e), o;
|
|
150
157
|
};
|
|
151
158
|
export {
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
F as a,
|
|
160
|
+
x as p,
|
|
154
161
|
o as s
|
|
155
162
|
};
|
package/dist/util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { MVFRAME_STORAGE_LANG as U } from "./composition.js";
|
|
2
|
+
const P = (s) => {
|
|
2
3
|
const f = (e) => {
|
|
3
4
|
if (e.startsWith("/"))
|
|
4
5
|
return new URL(e, import.meta.url).href;
|
|
@@ -6,7 +7,10 @@ const I = (s) => {
|
|
|
6
7
|
return new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
|
|
7
8
|
throw new Error("please provide an image url with getImg");
|
|
8
9
|
};
|
|
9
|
-
s.config.globalProperties.$getImg = f, globalThis.$getImg = f, globalThis.$getLang = () =>
|
|
10
|
+
s.config.globalProperties.$getImg = f, globalThis.$getImg = f, globalThis.$getLang = () => {
|
|
11
|
+
var e;
|
|
12
|
+
return localStorage.getItem(U) || ((e = globalThis.$config) == null ? void 0 : e.lang) || "en_us";
|
|
13
|
+
}, globalThis.token = "WQpvrYIEnSzAxhOWrbUpGvElhGztdOjOGOdbrSlhUYlrQArOdpMhY1vYMSA7l4xMOUl9MAl1I6AvSrQ8vlE0bpChQ0UWMMlYt0hQC0M0pSz0rUhvlIllSWzMESnAMUlt";
|
|
10
14
|
const m = (e) => Number(e.match(/\d+(\.\d+)?/g).join(""));
|
|
11
15
|
globalThis.$md5 = (e) => m(e);
|
|
12
16
|
const $ = (e, r = 0) => {
|
|
@@ -31,8 +35,8 @@ const I = (s) => {
|
|
|
31
35
|
let l = n[0].split("");
|
|
32
36
|
l = l.reverse();
|
|
33
37
|
let a = [];
|
|
34
|
-
l.forEach((
|
|
35
|
-
d !== 0 && d % 3 === 0 && a.push(","), a.push(
|
|
38
|
+
l.forEach((E, d) => {
|
|
39
|
+
d !== 0 && d % 3 === 0 && a.push(","), a.push(E);
|
|
36
40
|
});
|
|
37
41
|
let i = a.reverse().join("");
|
|
38
42
|
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;
|
|
@@ -71,7 +75,7 @@ const I = (s) => {
|
|
|
71
75
|
});
|
|
72
76
|
};
|
|
73
77
|
globalThis.$pm = C;
|
|
74
|
-
const
|
|
78
|
+
const M = (e = () => {
|
|
75
79
|
}, r = 500) => {
|
|
76
80
|
let o;
|
|
77
81
|
return function(...t) {
|
|
@@ -80,7 +84,7 @@ const I = (s) => {
|
|
|
80
84
|
}, r);
|
|
81
85
|
};
|
|
82
86
|
};
|
|
83
|
-
globalThis.$db =
|
|
87
|
+
globalThis.$db = M, Number.prototype.toFixedNumber = function(e) {
|
|
84
88
|
return Number(this.toFixed(e));
|
|
85
89
|
}, Array.prototype.filter1 = function(e) {
|
|
86
90
|
if (!e || typeof e != "function")
|
|
@@ -116,27 +120,27 @@ const I = (s) => {
|
|
|
116
120
|
}
|
|
117
121
|
};
|
|
118
122
|
globalThis.$copy = h, s.config.globalProperties.$copy = h;
|
|
119
|
-
const
|
|
120
|
-
globalThis.$sc =
|
|
123
|
+
const k = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "k" : parseInt(e / 1e6) + "m";
|
|
124
|
+
globalThis.$sc = k;
|
|
121
125
|
const F = {
|
|
122
126
|
cpa: "avgCPA",
|
|
123
127
|
cpt: "avgCPT"
|
|
124
|
-
},
|
|
128
|
+
}, w = (e, r = F) => {
|
|
125
129
|
const o = r[e.name];
|
|
126
130
|
o && (e.name = o);
|
|
127
131
|
};
|
|
128
|
-
globalThis.$nr =
|
|
129
|
-
const
|
|
132
|
+
globalThis.$nr = w;
|
|
133
|
+
const O = (e, r) => (Object.keys(e).forEach((o) => {
|
|
130
134
|
objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
|
|
131
135
|
}), e);
|
|
132
|
-
globalThis.$nro =
|
|
133
|
-
const
|
|
136
|
+
globalThis.$nro = O;
|
|
137
|
+
const x = (e) => {
|
|
134
138
|
let r = 0;
|
|
135
139
|
return Object.keys(e).forEach((o) => {
|
|
136
140
|
(globalThis.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && r++;
|
|
137
141
|
}), r;
|
|
138
142
|
};
|
|
139
|
-
globalThis.$pc =
|
|
143
|
+
globalThis.$pc = x;
|
|
140
144
|
const c = {
|
|
141
145
|
info: {
|
|
142
146
|
tag: "background-color:#0085FF; color:#f1f7ff; border-radius: 2px 0 0 2px;",
|
|
@@ -158,7 +162,7 @@ const I = (s) => {
|
|
|
158
162
|
tag: "background-color:#20c997; color:#f6fffc; border-radius: 2px 0 0 2px;",
|
|
159
163
|
style: "background-color:#f6fffc; color:#20c997;"
|
|
160
164
|
}
|
|
161
|
-
},
|
|
165
|
+
}, A = (e) => {
|
|
162
166
|
let r = !1;
|
|
163
167
|
for (let o in e)
|
|
164
168
|
if (globalThis.$getType(e[o]) === "Object") {
|
|
@@ -166,11 +170,11 @@ const I = (s) => {
|
|
|
166
170
|
break;
|
|
167
171
|
}
|
|
168
172
|
return r;
|
|
169
|
-
},
|
|
170
|
-
globalThis.$c = {},
|
|
173
|
+
}, S = ["info", "log", "warn", "error", "success"];
|
|
174
|
+
globalThis.$c = {}, S.forEach((e) => {
|
|
171
175
|
globalThis.$c[e] = (...r) => {
|
|
172
176
|
const o = e.toUpperCase();
|
|
173
|
-
|
|
177
|
+
A(r) ? (console.groupCollapsed(`%c ${o} `, `${c[e].tag}`), console[e](r), console.groupEnd()) : console.info(
|
|
174
178
|
`%c ${o} %c┆${r}┆`,
|
|
175
179
|
`${c[e].tag}`,
|
|
176
180
|
`${c[e].style}`
|
|
@@ -192,5 +196,5 @@ const I = (s) => {
|
|
|
192
196
|
};
|
|
193
197
|
};
|
|
194
198
|
export {
|
|
195
|
-
|
|
199
|
+
P as u
|
|
196
200
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mvframe",
|
|
3
3
|
"packageManager": "yarn@4.4.1",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"author": "matt avis",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"scripts/scaffold-app.js",
|
|
47
47
|
".cursor/skills/mvframe-app-init"
|
|
48
48
|
],
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"element-plus": "^2.2.0"
|
|
51
|
+
},
|
|
49
52
|
"dependencies": {
|
|
50
53
|
"pinia": "^3.0.0",
|
|
51
54
|
"vue": "^3.3.4",
|
package/scripts/scaffold-app.js
CHANGED
|
@@ -41,6 +41,8 @@ const SCAFFOLD_DEPENDENCIES = {
|
|
|
41
41
|
"@vue/shared": "^3.5.0",
|
|
42
42
|
"vue-router": "^4.6.0",
|
|
43
43
|
pinia: "^3.0.0",
|
|
44
|
+
/** mvframe 产物对 Table 列配置等直接 import,strict 包管理器下需直连依赖 */
|
|
45
|
+
vuedraggable: "^4.1.0",
|
|
44
46
|
mvframe: "^1.0.0",
|
|
45
47
|
"element-plus": "^2.13.0",
|
|
46
48
|
};
|
|
@@ -129,6 +131,8 @@ import mvframe from "mvframe";
|
|
|
129
131
|
import routes from "./router/index.js";
|
|
130
132
|
import appConfig from "./config/index.js";
|
|
131
133
|
import "./assets/style/index.scss";
|
|
134
|
+
import "mvframe/style";
|
|
135
|
+
import "mvframe/style/cpt";
|
|
132
136
|
|
|
133
137
|
const app = createApp(App);
|
|
134
138
|
app.use(ElementPlus);
|
|
@@ -296,14 +300,9 @@ export {};
|
|
|
296
300
|
|
|
297
301
|
write(
|
|
298
302
|
"src/assets/style/index.scss",
|
|
299
|
-
`/*
|
|
300
|
-
|
|
301
|
-
/*
|
|
302
|
-
* - monorepo / 源码依赖:*/
|
|
303
|
-
/* @import "mvframe/src/style/index.scss"; */
|
|
304
|
-
|
|
305
|
-
/* - 发布包全量样式:*/
|
|
306
|
-
/* @import "mvframe/style"; */
|
|
303
|
+
`/* 项目全局样式入口(main.js 已 import 本文件) */
|
|
304
|
+
/* MVFrame:main.js 已 import "mvframe/style" 与 "mvframe/style/cpt"(发布包 CSS),勿在此处再 @import 同一路径,避免重复。 */
|
|
305
|
+
/* 若需在 SCSS 内 @use 变量/mixin,可指向 node_modules 内 mvframe 源码路径或 monorepo workspace 路径。 */
|
|
307
306
|
|
|
308
307
|
body {
|
|
309
308
|
margin: 0;
|
|
@@ -433,9 +432,17 @@ yarn install
|
|
|
433
432
|
|
|
434
433
|
这是 **Vue 3 自带的底层包**,一般不必手写;在 **pnpm / 严格 node_modules** 等环境下可能未被提升到可被 Vite 解析的位置。脚手架已在 \`dependencies\` 中合并 \`@vue/shared\`(与 \`vue\` 同主版本);老项目可手动执行 \`yarn add @vue/shared@^3.5\`。
|
|
435
434
|
|
|
435
|
+
### 报错无法解析 \`vuedraggable\`
|
|
436
|
+
|
|
437
|
+
发布包 \`dist/index.js\` 会对 \`vuedraggable\` 做 **直连 import**(如 Table 列配置)。脚手架已在 \`dependencies\` 中写入 \`vuedraggable@^4.1.0\`;老项目可 \`yarn add vuedraggable@^4.1\`。
|
|
438
|
+
|
|
436
439
|
## 样式
|
|
437
440
|
|
|
438
|
-
|
|
441
|
+
\`src/main.js\` 已包含 \`import "mvframe/style"\` 与 \`import "mvframe/style/cpt"\`(分别对应工具类/变量与 **Mvc\*** 组件 scoped 等样式),一般 **无需** 在 \`index.scss\` 再引一遍 mvframe 的 dist CSS,以免重复。项目级覆盖写在 \`src/assets/style/index.scss\` 即可。
|
|
442
|
+
|
|
443
|
+
## 子路径(按需)
|
|
444
|
+
|
|
445
|
+
发布包 \`exports\` 还提供 \`mvframe/composition\`、\`mvframe/util\`、\`mvframe/store\` 等,业务侧可 \`import { ... } from "mvframe/composition"\` 等,参见包内 \`package.json\` 的 \`exports\`。
|
|
439
446
|
|
|
440
447
|
## 目录约定
|
|
441
448
|
|