mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-11 13:02:49 +00:00
优化
This commit is contained in:
parent
77edff6a5c
commit
0df167181d
@ -39,7 +39,7 @@
|
|||||||
"xlsx": "^0.18.5"
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cool-vue/vite-plugin": "^8.0.1",
|
"@cool-vue/vite-plugin": "^8.0.3",
|
||||||
"@intlify/unplugin-vue-i18n": "^6.0.3",
|
"@intlify/unplugin-vue-i18n": "^6.0.3",
|
||||||
"@rushstack/eslint-patch": "^1.10.5",
|
"@rushstack/eslint-patch": "^1.10.5",
|
||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node20": "^20.1.4",
|
||||||
|
|||||||
47
packages/vite-plugin/dist/index.js
vendored
47
packages/vite-plugin/dist/index.js
vendored
@ -1,8 +1,8 @@
|
|||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs'), require('path'), require('prettier'), require('axios'), require('lodash'), require('glob'), require('node:util'), require('svgo')) :
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs'), require('path'), require('prettier'), require('axios'), require('lodash'), require('@vue/compiler-sfc'), require('magic-string'), require('glob'), require('node:util'), require('svgo')) :
|
||||||
typeof define === 'function' && define.amd ? define(['exports', 'fs', 'path', 'prettier', 'axios', 'lodash', 'glob', 'node:util', 'svgo'], factory) :
|
typeof define === 'function' && define.amd ? define(['exports', 'fs', 'path', 'prettier', 'axios', 'lodash', '@vue/compiler-sfc', 'magic-string', 'glob', 'node:util', 'svgo'], factory) :
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.fs, global.path, global.prettier, global.axios, global.lodash, global.glob, global.util, global.svgo));
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.fs, global.path, global.prettier, global.axios, global.lodash, global.compilerSfc, global.magicString, global.glob, global.util, global.svgo));
|
||||||
})(this, (function (exports, fs, path, prettier, axios, lodash, glob, util, svgo) { 'use strict';
|
})(this, (function (exports, fs, path, prettier, axios, lodash, compilerSfc, magicString, glob, util, svgo) { 'use strict';
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
type: "admin",
|
type: "admin",
|
||||||
@ -521,7 +521,10 @@
|
|||||||
}
|
}
|
||||||
// 创建 dict
|
// 创建 dict
|
||||||
async function createDict() {
|
async function createDict() {
|
||||||
return axios.get(config.reqUrl + "/" + config.type + "/dict/info/types").then((res) => {
|
const url = config.reqUrl + "/" + config.type + "/dict/info/types";
|
||||||
|
return axios
|
||||||
|
.get(url)
|
||||||
|
.then((res) => {
|
||||||
const { code, data } = res.data;
|
const { code, data } = res.data;
|
||||||
if (code === 1000) {
|
if (code === 1000) {
|
||||||
let v = "string";
|
let v = "string";
|
||||||
@ -530,6 +533,9 @@
|
|||||||
}
|
}
|
||||||
return `type DictKey = ${v}`;
|
return `type DictKey = ${v}`;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
error(`[cool-eps] Error:${url}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 创建 eps
|
// 创建 eps
|
||||||
@ -646,6 +652,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createTag(code, id) {
|
||||||
|
if (/\.vue$/.test(id)) {
|
||||||
|
let s;
|
||||||
|
const str = () => s || (s = new magicString(code));
|
||||||
|
const { descriptor } = compilerSfc.parse(code);
|
||||||
|
if (!descriptor.script && descriptor.scriptSetup) {
|
||||||
|
const res = compilerSfc.compileScript(descriptor, { id });
|
||||||
|
const { name, lang } = res.attrs;
|
||||||
|
str().appendLeft(0, `<script lang="${lang}">
|
||||||
|
import { defineComponent } from 'vue'
|
||||||
|
export default defineComponent({
|
||||||
|
name: "${name}"
|
||||||
|
})
|
||||||
|
<\/script>`);
|
||||||
|
return {
|
||||||
|
map: str().generateMap(),
|
||||||
|
code: str().toString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function base() {
|
function base() {
|
||||||
return {
|
return {
|
||||||
name: "vite-cool-base",
|
name: "vite-cool-base",
|
||||||
@ -690,6 +719,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
transform(code, id) {
|
||||||
|
if (config.nameTag) {
|
||||||
|
return createTag(code, id);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,6 +993,8 @@ if (typeof window !== 'undefined') {
|
|||||||
config.type = options.type;
|
config.type = options.type;
|
||||||
// 请求地址
|
// 请求地址
|
||||||
config.reqUrl = getProxyTarget(options.proxy);
|
config.reqUrl = getProxyTarget(options.proxy);
|
||||||
|
// 是否开启名称标签
|
||||||
|
config.nameTag = options.nameTag ?? true;
|
||||||
// Eps
|
// Eps
|
||||||
if (options.eps) {
|
if (options.eps) {
|
||||||
const { dist, mapping, api, enable = true } = options.eps;
|
const { dist, mapping, api, enable = true } = options.eps;
|
||||||
|
|||||||
4
packages/vite-plugin/dist/tag/index.d.ts
vendored
Normal file
4
packages/vite-plugin/dist/tag/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export declare function createTag(code: string, id: string): {
|
||||||
|
map: any;
|
||||||
|
code: any;
|
||||||
|
} | null;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-vue/vite-plugin",
|
"name": "@cool-vue/vite-plugin",
|
||||||
"version": "8.0.1",
|
"version": "8.0.3",
|
||||||
"description": "cool-admin、cool-uni builder",
|
"description": "cool-admin、cool-uni builder",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"main": "/dist/index.js",
|
"main": "/dist/index.js",
|
||||||
@ -33,6 +33,7 @@
|
|||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
"glob": "^10.3.12",
|
"glob": "^10.3.12",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"magic-string": "^0.30.17",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"svgo": "^3.3.2"
|
"svgo": "^3.3.2"
|
||||||
}
|
}
|
||||||
|
|||||||
3
packages/vite-plugin/pnpm-lock.yaml
generated
3
packages/vite-plugin/pnpm-lock.yaml
generated
@ -20,6 +20,9 @@ importers:
|
|||||||
lodash:
|
lodash:
|
||||||
specifier: ^4.17.21
|
specifier: ^4.17.21
|
||||||
version: 4.17.21
|
version: 4.17.21
|
||||||
|
magic-string:
|
||||||
|
specifier: ^0.30.17
|
||||||
|
version: 0.30.17
|
||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.4.2
|
specifier: ^3.4.2
|
||||||
version: 3.5.1
|
version: 3.5.1
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import { parseJson } from "./utils";
|
|||||||
import { updatePlugin } from "./plugin";
|
import { updatePlugin } from "./plugin";
|
||||||
import { updateProxy } from "./proxy";
|
import { updateProxy } from "./proxy";
|
||||||
import { createFile } from "./file";
|
import { createFile } from "./file";
|
||||||
|
import { config } from "./config";
|
||||||
|
import { createTag } from "./tag";
|
||||||
|
|
||||||
export function base(): Plugin {
|
export function base(): Plugin {
|
||||||
return {
|
return {
|
||||||
@ -55,5 +57,12 @@ export function base(): Plugin {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
transform(code, id) {
|
||||||
|
if (config.nameTag) {
|
||||||
|
return createTag(code, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -481,19 +481,26 @@ function createService() {
|
|||||||
|
|
||||||
// 创建 dict
|
// 创建 dict
|
||||||
async function createDict() {
|
async function createDict() {
|
||||||
return axios.get(config.reqUrl + "/" + config.type + "/dict/info/types").then((res) => {
|
const url = config.reqUrl + "/" + config.type + "/dict/info/types";
|
||||||
const { code, data } = res.data as { code: number; data: any[] };
|
|
||||||
|
|
||||||
if (code === 1000) {
|
return axios
|
||||||
let v = "string";
|
.get(url)
|
||||||
|
.then((res) => {
|
||||||
|
const { code, data } = res.data as { code: number; data: any[] };
|
||||||
|
|
||||||
if (!isEmpty(data)) {
|
if (code === 1000) {
|
||||||
v = data.map((e) => `"${e.key}"`).join(" | ");
|
let v = "string";
|
||||||
|
|
||||||
|
if (!isEmpty(data)) {
|
||||||
|
v = data.map((e) => `"${e.key}"`).join(" | ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return `type DictKey = ${v}`;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
return `type DictKey = ${v}`;
|
.catch(() => {
|
||||||
}
|
error(`[cool-eps] Error:${url}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建 eps
|
// 创建 eps
|
||||||
|
|||||||
@ -13,6 +13,9 @@ export function cool(options: Config.Options) {
|
|||||||
// 请求地址
|
// 请求地址
|
||||||
config.reqUrl = getProxyTarget(options.proxy);
|
config.reqUrl = getProxyTarget(options.proxy);
|
||||||
|
|
||||||
|
// 是否开启名称标签
|
||||||
|
config.nameTag = options.nameTag ?? true;
|
||||||
|
|
||||||
// Eps
|
// Eps
|
||||||
if (options.eps) {
|
if (options.eps) {
|
||||||
const { dist, mapping, api, enable = true } = options.eps;
|
const { dist, mapping, api, enable = true } = options.eps;
|
||||||
|
|||||||
32
packages/vite-plugin/src/tag/index.ts
Normal file
32
packages/vite-plugin/src/tag/index.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { parse, compileScript } from "@vue/compiler-sfc";
|
||||||
|
import magicString from "magic-string";
|
||||||
|
|
||||||
|
export function createTag(code: string, id: string) {
|
||||||
|
if (/\.vue$/.test(id)) {
|
||||||
|
let s: any;
|
||||||
|
const str = () => s || (s = new magicString(code));
|
||||||
|
const { descriptor } = parse(code);
|
||||||
|
|
||||||
|
if (!descriptor.script && descriptor.scriptSetup) {
|
||||||
|
const res = compileScript(descriptor, { id });
|
||||||
|
const { name, lang }: any = res.attrs;
|
||||||
|
|
||||||
|
str().appendLeft(
|
||||||
|
0,
|
||||||
|
`<script lang="${lang}">
|
||||||
|
import { defineComponent } from 'vue'
|
||||||
|
export default defineComponent({
|
||||||
|
name: "${name}"
|
||||||
|
})
|
||||||
|
<\/script>`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
map: str().generateMap(),
|
||||||
|
code: str().toString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
1
packages/vite-plugin/types/index.d.ts
vendored
1
packages/vite-plugin/types/index.d.ts
vendored
@ -92,6 +92,7 @@ export declare namespace Config {
|
|||||||
proxy: any;
|
proxy: any;
|
||||||
eps?: Partial<Config.Eps>;
|
eps?: Partial<Config.Eps>;
|
||||||
demo?: boolean;
|
demo?: boolean;
|
||||||
|
nameTag?: boolean;
|
||||||
}
|
}
|
||||||
interface Data {
|
interface Data {
|
||||||
type: Config.Type;
|
type: Config.Type;
|
||||||
|
|||||||
11
pnpm-lock.yaml
generated
11
pnpm-lock.yaml
generated
@ -82,8 +82,8 @@ importers:
|
|||||||
version: 0.18.5
|
version: 0.18.5
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@cool-vue/vite-plugin':
|
'@cool-vue/vite-plugin':
|
||||||
specifier: ^8.0.1
|
specifier: ^8.0.3
|
||||||
version: 8.0.1
|
version: 8.0.3
|
||||||
'@intlify/unplugin-vue-i18n':
|
'@intlify/unplugin-vue-i18n':
|
||||||
specifier: ^6.0.3
|
specifier: ^6.0.3
|
||||||
version: 6.0.3(@vue/compiler-dom@3.5.13)(eslint@9.20.1(jiti@1.21.7))(rollup@4.34.8)(typescript@5.5.4)(vue-i18n@11.1.1(vue@3.5.13(typescript@5.5.4)))(vue@3.5.13(typescript@5.5.4))
|
version: 6.0.3(@vue/compiler-dom@3.5.13)(eslint@9.20.1(jiti@1.21.7))(rollup@4.34.8)(typescript@5.5.4)(vue-i18n@11.1.1(vue@3.5.13(typescript@5.5.4)))(vue@3.5.13(typescript@5.5.4))
|
||||||
@ -334,8 +334,8 @@ packages:
|
|||||||
'@cool-vue/crud@8.0.1':
|
'@cool-vue/crud@8.0.1':
|
||||||
resolution: {integrity: sha512-qITCLcmc5gCiqF2J2I5KsiywqTc/+4Umqy9MBx1dFsYvYfrGcqoRcybcz8cTO4CEDyIv0icymt4PRuKOf01igw==}
|
resolution: {integrity: sha512-qITCLcmc5gCiqF2J2I5KsiywqTc/+4Umqy9MBx1dFsYvYfrGcqoRcybcz8cTO4CEDyIv0icymt4PRuKOf01igw==}
|
||||||
|
|
||||||
'@cool-vue/vite-plugin@8.0.1':
|
'@cool-vue/vite-plugin@8.0.3':
|
||||||
resolution: {integrity: sha512-4vKCUvNnilS3CNVp5xxG+KMuIM5Nx79qZw0lTwgctV4TSYKy4WUdMSf7dJ4+WQltc22Q3DRf3DVRuJMumWhlYA==}
|
resolution: {integrity: sha512-5vxH/EyPXOJvKClllhaTZUeWh9XRJZwZJxyRlHuK2nAuD+pQxTXZ85WB4QPociMrJcOC8uZ/97EdrS4yG2Jv3Q==}
|
||||||
|
|
||||||
'@ctrl/tinycolor@3.6.1':
|
'@ctrl/tinycolor@3.6.1':
|
||||||
resolution: {integrity: sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==}
|
resolution: {integrity: sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==}
|
||||||
@ -3089,12 +3089,13 @@ snapshots:
|
|||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
'@cool-vue/vite-plugin@8.0.1':
|
'@cool-vue/vite-plugin@8.0.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vue/compiler-sfc': 3.5.13
|
'@vue/compiler-sfc': 3.5.13
|
||||||
axios: 1.7.9
|
axios: 1.7.9
|
||||||
glob: 10.4.5
|
glob: 10.4.5
|
||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
|
magic-string: 0.30.17
|
||||||
prettier: 3.5.1
|
prettier: 3.5.1
|
||||||
svgo: 3.3.2
|
svgo: 3.3.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
|||||||
@ -49,7 +49,6 @@ function open() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '年龄',
|
|
||||||
prop: 'age',
|
prop: 'age',
|
||||||
component: {
|
component: {
|
||||||
name: 'el-input-number'
|
name: 'el-input-number'
|
||||||
|
|||||||
@ -554,7 +554,7 @@ defineExpose({
|
|||||||
}
|
}
|
||||||
|
|
||||||
.search {
|
.search {
|
||||||
padding: 10px;
|
padding: 10px 10px 0 10px;
|
||||||
|
|
||||||
:deep(.el-input) {
|
:deep(.el-input) {
|
||||||
.el-input__wrapper {
|
.el-input__wrapper {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user