mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
Compare commits
1 Commits
1f0e4bfffb
...
184eed5d14
Author | SHA1 | Date | |
---|---|---|---|
|
184eed5d14 |
@ -37,7 +37,7 @@
|
|||||||
"xlsx": "^0.18.5"
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cool-vue/vite-plugin": "^7.1.2",
|
"@cool-vue/vite-plugin": "^7.1.1",
|
||||||
"@types/file-saver": "^2.0.7",
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/lodash-es": "^4.17.8",
|
"@types/lodash-es": "^4.17.8",
|
||||||
"@types/mockjs": "^1.0.7",
|
"@types/mockjs": "^1.0.7",
|
||||||
|
@ -62,11 +62,9 @@ export function parseTableDict(value: any, item: ClTable.Column) {
|
|||||||
label: v,
|
label: v,
|
||||||
value: v
|
value: v
|
||||||
};
|
};
|
||||||
|
delete d.children;
|
||||||
|
|
||||||
return {
|
return d;
|
||||||
...d,
|
|
||||||
children: []
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 格式化返回
|
// 格式化返回
|
||||||
|
26
packages/vite-plugin/dist/index.js
vendored
26
packages/vite-plugin/dist/index.js
vendored
@ -724,31 +724,17 @@
|
|||||||
|
|
||||||
async function virtual() {
|
async function virtual() {
|
||||||
const virtualModuleIds = ["virtual:eps", "virtual:ctx"];
|
const virtualModuleIds = ["virtual:eps", "virtual:ctx"];
|
||||||
|
const eps = await createEps();
|
||||||
|
const ctx = await createCtx();
|
||||||
return {
|
return {
|
||||||
name: "vite-cool-virtual",
|
name: "vite-cool-virtual",
|
||||||
enforce: "pre",
|
enforce: "pre",
|
||||||
configureServer(server) {
|
|
||||||
server.middlewares.use(async (req, res, next) => {
|
|
||||||
// 页面刷新时触发
|
|
||||||
if (req.url == "/@vite/client") {
|
|
||||||
// 重新加载虚拟模块
|
|
||||||
virtualModuleIds.forEach((vm) => {
|
|
||||||
const mod = server.moduleGraph.getModuleById(`\0${vm}`);
|
|
||||||
if (mod) {
|
|
||||||
server.moduleGraph.invalidateModule(mod);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleHotUpdate({ file, server }) {
|
handleHotUpdate({ file, server }) {
|
||||||
// 文件修改时触发
|
if (!["pages.json", "dist", "build/cool"].some((e) => file.includes(e))) {
|
||||||
if (!["pages.json", "dist", "build/cool", "eps.json", "eps.d.ts"].some((e) => file.includes(e))) {
|
|
||||||
createCtx();
|
createCtx();
|
||||||
createEps().then((data) => {
|
createEps().then((data) => {
|
||||||
// 通知客户端刷新
|
// 通知客户端刷新
|
||||||
(server.hot || server.ws).send({
|
server.ws.send({
|
||||||
type: "custom",
|
type: "custom",
|
||||||
event: "eps-update",
|
event: "eps-update",
|
||||||
data,
|
data,
|
||||||
@ -761,15 +747,13 @@
|
|||||||
return "\0" + id;
|
return "\0" + id;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async load(id) {
|
load(id) {
|
||||||
if (id === "\0virtual:eps") {
|
if (id === "\0virtual:eps") {
|
||||||
const eps = await createEps();
|
|
||||||
return `
|
return `
|
||||||
export const eps = ${JSON.stringify(eps)}
|
export const eps = ${JSON.stringify(eps)}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
if (id === "\0virtual:ctx") {
|
if (id === "\0virtual:ctx") {
|
||||||
const ctx = await createCtx();
|
|
||||||
return `
|
return `
|
||||||
export const ctx = ${JSON.stringify(ctx)}
|
export const ctx = ${JSON.stringify(ctx)}
|
||||||
`;
|
`;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-vue/vite-plugin",
|
"name": "@cool-vue/vite-plugin",
|
||||||
"version": "7.1.2",
|
"version": "7.1.1",
|
||||||
"description": "cool-admin/cool-uni builder",
|
"description": "cool-admin/cool-uni builder",
|
||||||
"main": "/dist/index.js",
|
"main": "/dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -5,38 +5,19 @@ import { createCtx } from "./ctx";
|
|||||||
export async function virtual(): Promise<Plugin> {
|
export async function virtual(): Promise<Plugin> {
|
||||||
const virtualModuleIds: string[] = ["virtual:eps", "virtual:ctx"];
|
const virtualModuleIds: string[] = ["virtual:eps", "virtual:ctx"];
|
||||||
|
|
||||||
|
const eps = await createEps();
|
||||||
|
const ctx = await createCtx();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "vite-cool-virtual",
|
name: "vite-cool-virtual",
|
||||||
enforce: "pre",
|
enforce: "pre",
|
||||||
configureServer(server) {
|
|
||||||
server.middlewares.use(async (req, res, next) => {
|
|
||||||
// 页面刷新时触发
|
|
||||||
if (req.url == "/@vite/client") {
|
|
||||||
// 重新加载虚拟模块
|
|
||||||
virtualModuleIds.forEach((vm) => {
|
|
||||||
const mod = server.moduleGraph.getModuleById(`\0${vm}`);
|
|
||||||
|
|
||||||
if (mod) {
|
|
||||||
server.moduleGraph.invalidateModule(mod);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleHotUpdate({ file, server }) {
|
handleHotUpdate({ file, server }) {
|
||||||
// 文件修改时触发
|
if (!["pages.json", "dist", "build/cool"].some((e) => file.includes(e))) {
|
||||||
if (
|
|
||||||
!["pages.json", "dist", "build/cool", "eps.json", "eps.d.ts"].some((e) =>
|
|
||||||
file.includes(e),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
createCtx();
|
createCtx();
|
||||||
|
|
||||||
createEps().then((data) => {
|
createEps().then((data) => {
|
||||||
// 通知客户端刷新
|
// 通知客户端刷新
|
||||||
(server.hot || server.ws).send({
|
server.ws.send({
|
||||||
type: "custom",
|
type: "custom",
|
||||||
event: "eps-update",
|
event: "eps-update",
|
||||||
data,
|
data,
|
||||||
@ -49,17 +30,13 @@ export async function virtual(): Promise<Plugin> {
|
|||||||
return "\0" + id;
|
return "\0" + id;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async load(id) {
|
load(id) {
|
||||||
if (id === "\0virtual:eps") {
|
if (id === "\0virtual:eps") {
|
||||||
const eps = await createEps();
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
export const eps = ${JSON.stringify(eps)}
|
export const eps = ${JSON.stringify(eps)}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
if (id === "\0virtual:ctx") {
|
if (id === "\0virtual:ctx") {
|
||||||
const ctx = await createCtx();
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
export const ctx = ${JSON.stringify(ctx)}
|
export const ctx = ${JSON.stringify(ctx)}
|
||||||
`;
|
`;
|
||||||
|
@ -86,8 +86,8 @@ dependencies:
|
|||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@cool-vue/vite-plugin':
|
'@cool-vue/vite-plugin':
|
||||||
specifier: ^7.1.2
|
specifier: ^7.1.1
|
||||||
version: 7.1.2
|
version: 7.1.1
|
||||||
'@types/file-saver':
|
'@types/file-saver':
|
||||||
specifier: ^2.0.7
|
specifier: ^2.0.7
|
||||||
version: 2.0.7
|
version: 2.0.7
|
||||||
@ -482,8 +482,8 @@ packages:
|
|||||||
- typescript
|
- typescript
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@cool-vue/vite-plugin@7.1.2:
|
/@cool-vue/vite-plugin@7.1.1:
|
||||||
resolution: {integrity: sha512-VRkJWIJP3eMJod7gCqrSdpKUOHrJJYwW2jyuEo1LroFjgPqhf1qH2IvPFRreKDdiFfDlwwE4g67nP/VBI/CpOw==}
|
resolution: {integrity: sha512-bCf0+ICwjYWYdS3DOrgr74YulvQLVjzNKPiTeL32pTyTecmFSOqbiQ+PbVYxIPHtZjnNjupWOz5vYm1kmBscWQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vue/compiler-sfc': 3.4.25
|
'@vue/compiler-sfc': 3.4.25
|
||||||
axios: 1.6.8
|
axios: 1.6.8
|
||||||
|
Loading…
Reference in New Issue
Block a user