morghulis 1.0.48 → 1.0.50
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/index.css +1 -1
- package/dist/index.d.ts +31 -3
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/install-deps.cjs +89 -1
- package/package.json +6 -3
- package/types/morghulis.d.ts +146 -0
- package/types/tsconfig.json +24 -0
package/install-deps.cjs
CHANGED
@@ -43,7 +43,42 @@ function ensureElementPlusInstalled() {
|
|
43
43
|
|
44
44
|
// 如果已经安装了element-plus,则不需要再安装
|
45
45
|
if (deps['element-plus'] || devDeps['element-plus']) {
|
46
|
-
console.log('element-plus已经在package.json
|
46
|
+
console.log('element-plus已经在package.json中,现在添加类型声明');
|
47
|
+
|
48
|
+
// 检查是否有tsconfig.json,如果有则添加类型声明配置
|
49
|
+
const tsconfigPath = path.join(rootDir, 'tsconfig.json');
|
50
|
+
if (fs.existsSync(tsconfigPath)) {
|
51
|
+
try {
|
52
|
+
console.log('找到tsconfig.json,添加element-plus类型声明');
|
53
|
+
|
54
|
+
// 读取tsconfig.json
|
55
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
|
56
|
+
|
57
|
+
// 修改compilerOptions.types,确保包含element-plus
|
58
|
+
if (!tsconfig.compilerOptions) {
|
59
|
+
tsconfig.compilerOptions = {};
|
60
|
+
}
|
61
|
+
|
62
|
+
if (!tsconfig.compilerOptions.types) {
|
63
|
+
tsconfig.compilerOptions.types = [];
|
64
|
+
}
|
65
|
+
|
66
|
+
// 如果没有element-plus,添加它
|
67
|
+
if (!tsconfig.compilerOptions.types.includes('element-plus')) {
|
68
|
+
tsconfig.compilerOptions.types.push('element-plus');
|
69
|
+
console.log('向tsconfig.json中添加element-plus类型');
|
70
|
+
|
71
|
+
// 写回文件
|
72
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), 'utf8');
|
73
|
+
console.log('tsconfig.json已更新,添加了element-plus类型声明');
|
74
|
+
} else {
|
75
|
+
console.log('element-plus类型声明已存在于tsconfig.json中');
|
76
|
+
}
|
77
|
+
} catch (error) {
|
78
|
+
console.error('修改tsconfig.json时出错:', error.message);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
47
82
|
return;
|
48
83
|
}
|
49
84
|
|
@@ -60,6 +95,38 @@ function ensureElementPlusInstalled() {
|
|
60
95
|
});
|
61
96
|
|
62
97
|
console.log('element-plus安装成功');
|
98
|
+
|
99
|
+
// 安装成功后,尝试配置tsconfig.json
|
100
|
+
const tsconfigPath = path.join(rootDir, 'tsconfig.json');
|
101
|
+
if (fs.existsSync(tsconfigPath)) {
|
102
|
+
try {
|
103
|
+
console.log('找到tsconfig.json,添加element-plus类型声明');
|
104
|
+
|
105
|
+
// 读取tsconfig.json
|
106
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
|
107
|
+
|
108
|
+
// 修改compilerOptions.types,确保包含element-plus
|
109
|
+
if (!tsconfig.compilerOptions) {
|
110
|
+
tsconfig.compilerOptions = {};
|
111
|
+
}
|
112
|
+
|
113
|
+
if (!tsconfig.compilerOptions.types) {
|
114
|
+
tsconfig.compilerOptions.types = [];
|
115
|
+
}
|
116
|
+
|
117
|
+
// 如果没有element-plus,添加它
|
118
|
+
if (!tsconfig.compilerOptions.types.includes('element-plus')) {
|
119
|
+
tsconfig.compilerOptions.types.push('element-plus');
|
120
|
+
console.log('向tsconfig.json中添加element-plus类型');
|
121
|
+
|
122
|
+
// 写回文件
|
123
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), 'utf8');
|
124
|
+
console.log('tsconfig.json已更新,添加了element-plus类型声明');
|
125
|
+
}
|
126
|
+
} catch (error) {
|
127
|
+
console.error('修改tsconfig.json时出错:', error.message);
|
128
|
+
}
|
129
|
+
}
|
63
130
|
} catch (npmError) {
|
64
131
|
console.error('npm安装失败,尝试使用yarn:', npmError.message);
|
65
132
|
// 如果npm不可用,尝试使用yarn
|
@@ -72,6 +139,27 @@ function ensureElementPlusInstalled() {
|
|
72
139
|
});
|
73
140
|
|
74
141
|
console.log('使用yarn安装element-plus成功');
|
142
|
+
|
143
|
+
// 配置tsconfig.json
|
144
|
+
const tsconfigPath = path.join(rootDir, 'tsconfig.json');
|
145
|
+
if (fs.existsSync(tsconfigPath)) {
|
146
|
+
try {
|
147
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
|
148
|
+
if (!tsconfig.compilerOptions) {
|
149
|
+
tsconfig.compilerOptions = {};
|
150
|
+
}
|
151
|
+
if (!tsconfig.compilerOptions.types) {
|
152
|
+
tsconfig.compilerOptions.types = [];
|
153
|
+
}
|
154
|
+
if (!tsconfig.compilerOptions.types.includes('element-plus')) {
|
155
|
+
tsconfig.compilerOptions.types.push('element-plus');
|
156
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), 'utf8');
|
157
|
+
console.log('tsconfig.json已更新,添加了element-plus类型声明');
|
158
|
+
}
|
159
|
+
} catch (error) {
|
160
|
+
console.error('修改tsconfig.json时出错:', error.message);
|
161
|
+
}
|
162
|
+
}
|
75
163
|
} catch (yarnError) {
|
76
164
|
console.error('yarn安装失败:', yarnError.message);
|
77
165
|
console.error('无法使用npm或yarn安装element-plus');
|
package/package.json
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "morghulis",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.50",
|
4
4
|
"description": "数据库模型",
|
5
5
|
"private": false,
|
6
6
|
"type": "module",
|
7
7
|
"main": "dist/index.js",
|
8
8
|
"module": "dist/index.js",
|
9
|
-
"types": "
|
9
|
+
"types": "types/morghulis.d.ts",
|
10
|
+
"typings": "types/morghulis.d.ts",
|
11
|
+
"style": "dist/index.css",
|
10
12
|
"bin": {
|
11
13
|
"install-element-plus": "install-deps.cjs"
|
12
14
|
},
|
13
15
|
"files": [
|
14
16
|
"dist",
|
15
|
-
"install-deps.cjs"
|
17
|
+
"install-deps.cjs",
|
18
|
+
"types"
|
16
19
|
],
|
17
20
|
"scripts": {
|
18
21
|
"dev": "vite",
|
@@ -0,0 +1,146 @@
|
|
1
|
+
// 这个文件用于声明Morghulis组件库的类型,确保TypeScript能够正确识别组件和API
|
2
|
+
import type { App, Component, DefineComponent } from 'vue';
|
3
|
+
import type { DialogProps } from 'element-plus';
|
4
|
+
|
5
|
+
declare module 'morghulis' {
|
6
|
+
// 组件库配置选项
|
7
|
+
export interface MOptions {
|
8
|
+
baseURL: string;
|
9
|
+
minioURL: string;
|
10
|
+
[key: string]: any;
|
11
|
+
}
|
12
|
+
|
13
|
+
// 对话框配置
|
14
|
+
export interface MDialogConfig {
|
15
|
+
title?: string;
|
16
|
+
subtitle?: string;
|
17
|
+
}
|
18
|
+
|
19
|
+
// 对话框组件属性
|
20
|
+
export interface MDialogProps extends Partial<DialogProps> {
|
21
|
+
// 对话框标题与副标题
|
22
|
+
title?: string;
|
23
|
+
subtitle?: string;
|
24
|
+
|
25
|
+
// 对话框尺寸与位置
|
26
|
+
width?: string | number;
|
27
|
+
top?: string;
|
28
|
+
fullscreen?: boolean;
|
29
|
+
|
30
|
+
// 对话框配置
|
31
|
+
modal?: boolean;
|
32
|
+
modalClass?: string;
|
33
|
+
headerClass?: string;
|
34
|
+
bodyClass?: string;
|
35
|
+
footerClass?: string;
|
36
|
+
appendToBody?: boolean;
|
37
|
+
lockScroll?: boolean;
|
38
|
+
openDelay?: number;
|
39
|
+
closeDelay?: number;
|
40
|
+
closeOnClickModal?: boolean;
|
41
|
+
closeOnPressEscape?: boolean;
|
42
|
+
showClose?: boolean;
|
43
|
+
beforeClose?: (done: () => void) => void;
|
44
|
+
draggable?: boolean;
|
45
|
+
center?: boolean;
|
46
|
+
alignCenter?: boolean;
|
47
|
+
destroyOnClose?: boolean;
|
48
|
+
customClass?: string;
|
49
|
+
|
50
|
+
// MDialog特有属性
|
51
|
+
confirm?: (data: any, done: () => void) => void;
|
52
|
+
cancel?: (data: any, done: () => void) => void;
|
53
|
+
confirmButtonText?: string;
|
54
|
+
cancelButtonText?: string;
|
55
|
+
data?: any;
|
56
|
+
}
|
57
|
+
|
58
|
+
// 对话框头部组件属性
|
59
|
+
export interface MDialogHeaderProps {
|
60
|
+
title?: string;
|
61
|
+
subtitle?: string;
|
62
|
+
config: MDialogConfig;
|
63
|
+
}
|
64
|
+
|
65
|
+
// 组件导出
|
66
|
+
export const MDialog: DefineComponent<MDialogProps, {}, {
|
67
|
+
open: (data?: any, config?: MDialogConfig) => void;
|
68
|
+
close: () => void;
|
69
|
+
}>;
|
70
|
+
|
71
|
+
export const MDialogHeader: DefineComponent<MDialogHeaderProps>;
|
72
|
+
|
73
|
+
// 工具导出
|
74
|
+
export const $message: {
|
75
|
+
info: (content: string) => void;
|
76
|
+
success: (content: string) => void;
|
77
|
+
warning: (content: string) => void;
|
78
|
+
error: (content: string) => void;
|
79
|
+
show: (content: string, type?: "success" | "info" | "warning" | "error") => void;
|
80
|
+
};
|
81
|
+
|
82
|
+
export const $alert: {
|
83
|
+
info: (content: string, title?: string) => Promise<any>;
|
84
|
+
success: (content: string, title?: string) => Promise<any>;
|
85
|
+
warning: (content: string, title?: string) => Promise<any>;
|
86
|
+
error: (content: string, title?: string) => Promise<any>;
|
87
|
+
show: (content: string, title?: string, type?: "success" | "info" | "warning" | "error") => void;
|
88
|
+
};
|
89
|
+
|
90
|
+
export const $confirm: {
|
91
|
+
info: (content: string, title?: string) => Promise<any>;
|
92
|
+
success: (content: string, title?: string) => Promise<any>;
|
93
|
+
warning: (content: string, title?: string) => Promise<any>;
|
94
|
+
error: (content: string, title?: string) => Promise<any>;
|
95
|
+
show: (content: string, title?: string, type?: "success" | "info" | "warning" | "error") => void;
|
96
|
+
};
|
97
|
+
|
98
|
+
// 钩子函数
|
99
|
+
export function useMCookies(): {
|
100
|
+
get: (path: string) => any;
|
101
|
+
set: (path: string, value?: any) => void;
|
102
|
+
load: (key: string, value?: any) => any;
|
103
|
+
remove: (path: string) => void;
|
104
|
+
};
|
105
|
+
|
106
|
+
export function useMAuthorize(): {
|
107
|
+
$client: string;
|
108
|
+
user: () => any;
|
109
|
+
check: (uid?: any) => boolean;
|
110
|
+
login: (uid: any) => void;
|
111
|
+
logout: () => void;
|
112
|
+
bearer: () => string | null;
|
113
|
+
};
|
114
|
+
|
115
|
+
export function useMoRequest(): {
|
116
|
+
getHttpRequest: (auth?: boolean) => any;
|
117
|
+
getMinioRequest: () => any;
|
118
|
+
};
|
119
|
+
|
120
|
+
// 核心系统常量
|
121
|
+
export const SYSTEM_KEY: {
|
122
|
+
CLIENT: string;
|
123
|
+
USER: string;
|
124
|
+
AUTH: string;
|
125
|
+
};
|
126
|
+
|
127
|
+
// 创建实例函数
|
128
|
+
export function createMorghulis(options?: MOptions): {
|
129
|
+
install: (app: App) => void;
|
130
|
+
};
|
131
|
+
|
132
|
+
// 默认导出
|
133
|
+
export default createMorghulis;
|
134
|
+
}
|
135
|
+
|
136
|
+
// 为Vue全局组件扩展类型
|
137
|
+
declare module '@vue/runtime-core' {
|
138
|
+
interface GlobalComponents {
|
139
|
+
// Morghulis组件
|
140
|
+
MDialog: DefineComponent<import('morghulis').MDialogProps, {}, {
|
141
|
+
open: (data?: any, config?: import('morghulis').MDialogConfig) => void;
|
142
|
+
close: () => void;
|
143
|
+
}>;
|
144
|
+
MDialogHeader: DefineComponent<import('morghulis').MDialogHeaderProps, {}, {}>;
|
145
|
+
}
|
146
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2020",
|
4
|
+
"module": "ESNext",
|
5
|
+
"moduleResolution": "Node",
|
6
|
+
"declaration": true,
|
7
|
+
"strict": true,
|
8
|
+
"noImplicitAny": true,
|
9
|
+
"strictNullChecks": true,
|
10
|
+
"strictFunctionTypes": true,
|
11
|
+
"strictBindCallApply": true,
|
12
|
+
"strictPropertyInitialization": true,
|
13
|
+
"noImplicitThis": true,
|
14
|
+
"alwaysStrict": true,
|
15
|
+
"noUnusedLocals": true,
|
16
|
+
"noUnusedParameters": true,
|
17
|
+
"noImplicitReturns": true,
|
18
|
+
"noFallthroughCasesInSwitch": true,
|
19
|
+
"esModuleInterop": true,
|
20
|
+
"skipLibCheck": true,
|
21
|
+
"forceConsistentCasingInFileNames": true
|
22
|
+
},
|
23
|
+
"include": ["*.d.ts"]
|
24
|
+
}
|