element-ui-x-zzz 1.0.0
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/build/build-components.js +68 -0
- package/build/build-locale.js +176 -0
- package/build/webpack.common.conf.js +118 -0
- package/build/webpack.component.conf.js +85 -0
- package/build/webpack.esm.conf.js +90 -0
- package/build/webpack.umd.conf.js +72 -0
- package/components.json +13 -0
- package/package.json +12 -0
- package/src/components/Attachments/index.js +8 -0
- package/src/components/Attachments/src/main.vue +529 -0
- package/src/components/Bubble/index.js +6 -0
- package/src/components/Bubble/src/main.vue +288 -0
- package/src/components/BubbleList/index.js +8 -0
- package/src/components/BubbleList/src/loading.vue +75 -0
- package/src/components/BubbleList/src/main.vue +444 -0
- package/src/components/Conversations/index.js +8 -0
- package/src/components/Conversations/src/components/item.vue +350 -0
- package/src/components/Conversations/src/main.vue +587 -0
- package/src/components/EditorSender/index.js +8 -0
- package/src/components/EditorSender/src/components/ClearButton.vue +35 -0
- package/src/components/EditorSender/src/components/Loading.vue +53 -0
- package/src/components/EditorSender/src/components/LoadingButton.vue +37 -0
- package/src/components/EditorSender/src/components/SendButton.vue +26 -0
- package/src/components/EditorSender/src/main.vue +589 -0
- package/src/components/FilesCard/index.js +8 -0
- package/src/components/FilesCard/src/fileSvg/audio.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/changeFileName.bat +18 -0
- package/src/components/FilesCard/src/fileSvg/code.vue +35 -0
- package/src/components/FilesCard/src/fileSvg/database.vue +94 -0
- package/src/components/FilesCard/src/fileSvg/excel.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/file.vue +40 -0
- package/src/components/FilesCard/src/fileSvg/image.vue +40 -0
- package/src/components/FilesCard/src/fileSvg/index.js +46 -0
- package/src/components/FilesCard/src/fileSvg/link.vue +54 -0
- package/src/components/FilesCard/src/fileSvg/mark.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/pdf.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/ppt.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/three.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/txt.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/unknown.vue +54 -0
- package/src/components/FilesCard/src/fileSvg/video.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/word.vue +38 -0
- package/src/components/FilesCard/src/fileSvg/zip.vue +38 -0
- package/src/components/FilesCard/src/main.vue +403 -0
- package/src/components/FilesCard/src/options.js +18 -0
- package/src/components/Prompts/index.js +8 -0
- package/src/components/Prompts/src/main.vue +248 -0
- package/src/components/Sender/index.js +8 -0
- package/src/components/Sender/src/components/ClearButton.vue +28 -0
- package/src/components/Sender/src/components/Loading.vue +53 -0
- package/src/components/Sender/src/components/LoadingButton.vue +37 -0
- package/src/components/Sender/src/components/SendButton.vue +26 -0
- package/src/components/Sender/src/components/SpeechButton.vue +24 -0
- package/src/components/Sender/src/components/SpeechLoading.vue +87 -0
- package/src/components/Sender/src/components/SpeechLoadingButton.vue +41 -0
- package/src/components/Sender/src/main.vue +803 -0
- package/src/components/Thinking/index.js +8 -0
- package/src/components/Thinking/src/main.vue +199 -0
- package/src/components/ThoughtChain/index.js +8 -0
- package/src/components/ThoughtChain/src/main.vue +291 -0
- package/src/components/Typewriter/index.js +8 -0
- package/src/components/Typewriter/src/main.vue +255 -0
- package/src/components/Welcome/index.js +8 -0
- package/src/components/Welcome/src/main.vue +151 -0
- package/src/index.js +107 -0
- package/src/locale/index.js +97 -0
- package/src/locale/lang/ar.js +18 -0
- package/src/locale/lang/de.js +18 -0
- package/src/locale/lang/en.js +18 -0
- package/src/locale/lang/es.js +18 -0
- package/src/locale/lang/fr.js +18 -0
- package/src/locale/lang/index.js +62 -0
- package/src/locale/lang/it.js +18 -0
- package/src/locale/lang/ja.js +18 -0
- package/src/locale/lang/ko.js +18 -0
- package/src/locale/lang/pt-br.js +18 -0
- package/src/locale/lang/ru-RU.js +18 -0
- package/src/locale/lang/zh-CN.js +18 -0
- package/src/locale/lang/zh-TW.js +18 -0
- package/src/locale/mixin.js +9 -0
- package/src/mixins/index.js +49 -0
- package/src/mixins/recordMixin.js +117 -0
- package/src/mixins/sendMixin.js +448 -0
- package/src/mixins/streamMixin.js +497 -0
- package/src/styles/Attachments.scss +236 -0
- package/src/styles/Bubble.scss +158 -0
- package/src/styles/BubbleList.scss +148 -0
- package/src/styles/Conversations.scss +283 -0
- package/src/styles/EditorSender.scss +183 -0
- package/src/styles/FilesCard.scss +222 -0
- package/src/styles/Prompts.scss +197 -0
- package/src/styles/Sender.scss +211 -0
- package/src/styles/Thinking.scss +142 -0
- package/src/styles/ThoughtChain.scss +113 -0
- package/src/styles/Typewriter.scss +66 -0
- package/src/styles/Welcome.scss +283 -0
- package/src/theme/var.scss +183 -0
- package/src/utils/index.js +199 -0
- package/src/utils/scrollDetector.js +34 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const webpack = require('webpack');
|
|
2
|
+
const config = require('./webpack.component.conf');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
console.log('开始构建组件级别的包...\n');
|
|
7
|
+
|
|
8
|
+
// 确保lib目录存在
|
|
9
|
+
const libDir = path.join(__dirname, '../lib');
|
|
10
|
+
if (!fs.existsSync(libDir)) {
|
|
11
|
+
fs.mkdirSync(libDir);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 确保 components 和 mixins 目录存在
|
|
15
|
+
const componentsDir = path.join(libDir, 'components');
|
|
16
|
+
if (!fs.existsSync(componentsDir)) {
|
|
17
|
+
fs.mkdirSync(componentsDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const mixinsDir = path.join(libDir, 'mixins');
|
|
21
|
+
if (!fs.existsSync(mixinsDir)) {
|
|
22
|
+
fs.mkdirSync(mixinsDir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 获取所有组件目录
|
|
26
|
+
const srcComponentsDir = path.join(__dirname, '../src/components');
|
|
27
|
+
const components = fs.readdirSync(srcComponentsDir);
|
|
28
|
+
|
|
29
|
+
webpack(config, (err, stats) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.error('构建过程中发生错误:', err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (stats.hasErrors()) {
|
|
36
|
+
console.error('构建失败:', stats.toString('errors-only'));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log('✅ 组件级别构建成功!\n');
|
|
41
|
+
|
|
42
|
+
// 显示构建结果
|
|
43
|
+
const info = stats.toJson();
|
|
44
|
+
console.log('💶 构建的文件:');
|
|
45
|
+
|
|
46
|
+
// 按目录分组显示文件
|
|
47
|
+
const componentFiles = [];
|
|
48
|
+
const otherFiles = [];
|
|
49
|
+
|
|
50
|
+
info.assets.forEach(asset => {
|
|
51
|
+
if (asset.name.startsWith('components/')) {
|
|
52
|
+
componentFiles.push(asset);
|
|
53
|
+
} else {
|
|
54
|
+
otherFiles.push(asset);
|
|
55
|
+
}
|
|
56
|
+
console.log(` - ${asset.name} (${(asset.size / 1024).toFixed(1)}KB)`);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// 生成组件列表
|
|
60
|
+
let componentList = '';
|
|
61
|
+
components.forEach(component => {
|
|
62
|
+
componentList += `ElX${component}, `;
|
|
63
|
+
});
|
|
64
|
+
componentList = componentList.replace(/, $/, '');
|
|
65
|
+
|
|
66
|
+
console.log('\n📚 完整组件列表:');
|
|
67
|
+
console.log(` import { ${componentList} } from "vue-element-ui-x";`);
|
|
68
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
console.log('开始构建国际化语言包...\n');
|
|
5
|
+
|
|
6
|
+
// 确保目标目录存在
|
|
7
|
+
const libDir = path.join(__dirname, '../lib');
|
|
8
|
+
const localeDir = path.join(libDir, 'locale');
|
|
9
|
+
const langDir = path.join(localeDir, 'lang');
|
|
10
|
+
|
|
11
|
+
// 创建目录
|
|
12
|
+
[libDir, localeDir, langDir].forEach(dir => {
|
|
13
|
+
if (!fs.existsSync(dir)) {
|
|
14
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// 源目录
|
|
19
|
+
const srcLocaleDir = path.join(__dirname, '../src/locale');
|
|
20
|
+
const srcLangDir = path.join(srcLocaleDir, 'lang');
|
|
21
|
+
|
|
22
|
+
// 将 ES6 模块转换为 CommonJS
|
|
23
|
+
function transformToCommonJS(code) {
|
|
24
|
+
return code
|
|
25
|
+
.replace(/export default\s+/, 'module.exports = ')
|
|
26
|
+
.replace(/import\s+(.+?)\s+from\s+['"](.+?)['"];?/g, 'const $1 = require("$2");');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 构建单个文件
|
|
30
|
+
function buildFile(srcPath, destPath) {
|
|
31
|
+
try {
|
|
32
|
+
const code = fs.readFileSync(srcPath, 'utf8');
|
|
33
|
+
const transformedCode = transformToCommonJS(code);
|
|
34
|
+
|
|
35
|
+
fs.writeFileSync(destPath, transformedCode);
|
|
36
|
+
// console.log(`✅ 构建成功: ${path.relative(process.cwd(), destPath)}`);
|
|
37
|
+
return true;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(`❌ 构建失败: ${path.relative(process.cwd(), srcPath)}`);
|
|
40
|
+
console.error(error.message);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 构建主 locale/index.js
|
|
46
|
+
const localeIndexSrc = path.join(srcLocaleDir, 'index.js');
|
|
47
|
+
const localeIndexDest = path.join(localeDir, 'index.js');
|
|
48
|
+
if (fs.existsSync(localeIndexSrc)) {
|
|
49
|
+
buildFile(localeIndexSrc, localeIndexDest);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 构建 locale/mixin.js
|
|
53
|
+
const mixinSrc = path.join(srcLocaleDir, 'mixin.js');
|
|
54
|
+
const mixinDest = path.join(localeDir, 'mixin.js');
|
|
55
|
+
if (fs.existsSync(mixinSrc)) {
|
|
56
|
+
buildFile(mixinSrc, mixinDest);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 构建所有语言包
|
|
60
|
+
if (fs.existsSync(srcLangDir)) {
|
|
61
|
+
const langFiles = fs.readdirSync(srcLangDir);
|
|
62
|
+
|
|
63
|
+
langFiles.forEach(file => {
|
|
64
|
+
if (file.endsWith('.js')) {
|
|
65
|
+
const srcPath = path.join(srcLangDir, file);
|
|
66
|
+
const destPath = path.join(langDir, file);
|
|
67
|
+
buildFile(srcPath, destPath);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 创建语言包入口文件 lib/locale/lang/index.js
|
|
73
|
+
const langIndexContent = `// 语言包入口文件
|
|
74
|
+
module.exports = {
|
|
75
|
+
// 中文
|
|
76
|
+
'zh-CN': require('./zh-CN'),
|
|
77
|
+
'zh-cn': require('./zh-CN'),
|
|
78
|
+
'zh-TW': require('./zh-TW'),
|
|
79
|
+
'zh-tw': require('./zh-TW'),
|
|
80
|
+
|
|
81
|
+
// 英文
|
|
82
|
+
'en': require('./en'),
|
|
83
|
+
'en-US': require('./en'),
|
|
84
|
+
'en-GB': require('./en'),
|
|
85
|
+
|
|
86
|
+
// 日语
|
|
87
|
+
'ja-JP': require('./ja'),
|
|
88
|
+
'ja': require('./ja'),
|
|
89
|
+
|
|
90
|
+
// 韩语
|
|
91
|
+
'ko-KR': require('./ko'),
|
|
92
|
+
'ko': require('./ko'),
|
|
93
|
+
|
|
94
|
+
// 法语
|
|
95
|
+
'fr-FR': require('./fr'),
|
|
96
|
+
'fr': require('./fr'),
|
|
97
|
+
|
|
98
|
+
// 德语
|
|
99
|
+
'de-DE': require('./de'),
|
|
100
|
+
'de': require('./de'),
|
|
101
|
+
|
|
102
|
+
// 西班牙语
|
|
103
|
+
'es-ES': require('./es'),
|
|
104
|
+
'es': require('./es'),
|
|
105
|
+
|
|
106
|
+
// 俄语
|
|
107
|
+
'ru-RU': require('./ru-RU'),
|
|
108
|
+
'ru': require('./ru-RU'),
|
|
109
|
+
|
|
110
|
+
// 葡萄牙语
|
|
111
|
+
'pt-BR': require('./pt-br'),
|
|
112
|
+
'pt-br': require('./pt-br'),
|
|
113
|
+
'pt': require('./pt-br'),
|
|
114
|
+
|
|
115
|
+
// 意大利语
|
|
116
|
+
'it-IT': require('./it'),
|
|
117
|
+
'it': require('./it'),
|
|
118
|
+
|
|
119
|
+
// 阿拉伯语
|
|
120
|
+
'ar-SA': require('./ar'),
|
|
121
|
+
'ar': require('./ar')
|
|
122
|
+
};
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
fs.writeFileSync(path.join(langDir, 'index.js'), langIndexContent);
|
|
126
|
+
// console.log(`✅ 构建成功: lib/locale/lang/index.js`);
|
|
127
|
+
|
|
128
|
+
// 创建便于 CDN 使用的 UMD 格式语言包
|
|
129
|
+
const createUMDLang = (langName, langCode) => {
|
|
130
|
+
const srcPath = path.join(srcLangDir, `${langCode}.js`);
|
|
131
|
+
if (fs.existsSync(srcPath)) {
|
|
132
|
+
const langContent = fs.readFileSync(srcPath, 'utf8');
|
|
133
|
+
// 提取语言数据对象
|
|
134
|
+
const langDataMatch = langContent.match(/export default\s+(\{[\s\S]*\});?\s*$/);
|
|
135
|
+
if (langDataMatch) {
|
|
136
|
+
const langData = langDataMatch[1];
|
|
137
|
+
|
|
138
|
+
const umdContent = `(function (global, factory) {
|
|
139
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
140
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
141
|
+
(global = global || self, (global.ELEMENT_UI_X = global.ELEMENT_UI_X || {}, global.ELEMENT_UI_X.lang = global.ELEMENT_UI_X.lang || {}, global.ELEMENT_UI_X.lang.${langName} = factory()));
|
|
142
|
+
}(this, function () { 'use strict';
|
|
143
|
+
|
|
144
|
+
return ${langData};
|
|
145
|
+
|
|
146
|
+
}));
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
const umdPath = path.join(langDir, `${langCode}.umd.js`);
|
|
150
|
+
fs.writeFileSync(umdPath, umdContent);
|
|
151
|
+
// console.log(`✅ 构建成功: lib/locale/lang/${langCode}.umd.js (UMD格式)`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// 构建 UMD 格式的语言包
|
|
157
|
+
const umdLanguages = [
|
|
158
|
+
{ name: 'zhCN', code: 'zh-CN' },
|
|
159
|
+
{ name: 'zhTW', code: 'zh-TW' },
|
|
160
|
+
{ name: 'en', code: 'en' },
|
|
161
|
+
{ name: 'ja', code: 'ja' },
|
|
162
|
+
{ name: 'ko', code: 'ko' },
|
|
163
|
+
{ name: 'fr', code: 'fr' },
|
|
164
|
+
{ name: 'de', code: 'de' },
|
|
165
|
+
{ name: 'es', code: 'es' },
|
|
166
|
+
{ name: 'ru', code: 'ru-RU' },
|
|
167
|
+
{ name: 'ptBr', code: 'pt-br' },
|
|
168
|
+
{ name: 'it', code: 'it' },
|
|
169
|
+
{ name: 'ar', code: 'ar' },
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
umdLanguages.forEach(({ name, code }) => {
|
|
173
|
+
createUMDLang(name, code);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
console.log('\n🎉 国际化语言包构建完成!');
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { VueLoaderPlugin } = require('vue-loader');
|
|
3
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
4
|
+
const webpack = require('webpack');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: 'production',
|
|
8
|
+
entry: path.join(__dirname, '../src/index.js'),
|
|
9
|
+
output: {
|
|
10
|
+
path: path.join(__dirname, '../lib'),
|
|
11
|
+
filename: 'index.common.js',
|
|
12
|
+
library: 'ElementUIX',
|
|
13
|
+
libraryTarget: 'commonjs2',
|
|
14
|
+
},
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
17
|
+
{
|
|
18
|
+
test: /\.vue$/,
|
|
19
|
+
loader: 'vue-loader',
|
|
20
|
+
options: { compilerOptions: { preserveWhitespace: false } },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
test: /\.js$/,
|
|
24
|
+
loader: 'babel-loader',
|
|
25
|
+
exclude: /node_modules/,
|
|
26
|
+
options: {
|
|
27
|
+
presets: [
|
|
28
|
+
[
|
|
29
|
+
'@babel/preset-env',
|
|
30
|
+
{
|
|
31
|
+
targets: { browsers: ['> 1%', 'last 2 versions', 'ie >= 9'] },
|
|
32
|
+
modules: 'commonjs',
|
|
33
|
+
loose: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
],
|
|
37
|
+
plugins: [
|
|
38
|
+
'@babel/plugin-transform-arrow-functions',
|
|
39
|
+
'@babel/plugin-transform-block-scoping',
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
test: /\.css$/,
|
|
45
|
+
exclude: /node_modules/,
|
|
46
|
+
use: ['style-loader', 'css-loader'],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
test: /\.css$/,
|
|
50
|
+
include: /node_modules/,
|
|
51
|
+
use: ['css-loader'],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
test: /\.scss$/,
|
|
55
|
+
use: [
|
|
56
|
+
'style-loader',
|
|
57
|
+
'css-loader',
|
|
58
|
+
{
|
|
59
|
+
loader: 'sass-loader',
|
|
60
|
+
options: {
|
|
61
|
+
sassOptions: {
|
|
62
|
+
outputStyle: 'compressed',
|
|
63
|
+
silenceDeprecations: ['legacy-js-api', 'import'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
plugins: [
|
|
72
|
+
new VueLoaderPlugin(),
|
|
73
|
+
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
|
|
74
|
+
new webpack.IgnorePlugin({
|
|
75
|
+
resourceRegExp: /^\.\/(locale)$/,
|
|
76
|
+
contextRegExp: /moment$/,
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
externals: {
|
|
80
|
+
vue: 'vue',
|
|
81
|
+
'element-ui': 'element-ui',
|
|
82
|
+
// 'markdown-it': 'markdown-it',
|
|
83
|
+
// dompurify: 'DOMPurify',
|
|
84
|
+
// prismjs: 'Prism',
|
|
85
|
+
// lodash: '_',
|
|
86
|
+
},
|
|
87
|
+
optimization: {
|
|
88
|
+
usedExports: true,
|
|
89
|
+
minimize: true,
|
|
90
|
+
minimizer: [
|
|
91
|
+
new TerserPlugin({
|
|
92
|
+
terserOptions: {
|
|
93
|
+
compress: {
|
|
94
|
+
drop_console: true,
|
|
95
|
+
drop_debugger: true,
|
|
96
|
+
pure_funcs: ['console.log'],
|
|
97
|
+
unused: true,
|
|
98
|
+
dead_code: true,
|
|
99
|
+
sequences: true,
|
|
100
|
+
conditionals: true,
|
|
101
|
+
},
|
|
102
|
+
mangle: true,
|
|
103
|
+
output: {
|
|
104
|
+
comments: false,
|
|
105
|
+
beautify: false,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
extractComments: false,
|
|
109
|
+
parallel: true,
|
|
110
|
+
}),
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
performance: {
|
|
114
|
+
hints: 'warning',
|
|
115
|
+
maxAssetSize: 250 * 1024,
|
|
116
|
+
maxEntrypointSize: 250 * 1024,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { VueLoaderPlugin } = require('vue-loader');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
// 获取所有组件目录
|
|
6
|
+
const componentsDir = path.join(__dirname, '../src/components');
|
|
7
|
+
const components = fs.readdirSync(componentsDir);
|
|
8
|
+
|
|
9
|
+
// 构建多入口配置
|
|
10
|
+
const entry = {};
|
|
11
|
+
components.forEach(component => {
|
|
12
|
+
const componentPath = path.join(componentsDir, component, 'index.js');
|
|
13
|
+
if (fs.existsSync(componentPath)) {
|
|
14
|
+
// 保持原始组件目录结构
|
|
15
|
+
entry[`components/${component}/index`] = componentPath;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// 添加主入口和mixins入口
|
|
20
|
+
entry['index'] = path.join(__dirname, '../src/index.js');
|
|
21
|
+
entry['mixins/index'] = path.join(__dirname, '../src/mixins/index.js');
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
mode: 'production',
|
|
25
|
+
entry,
|
|
26
|
+
output: {
|
|
27
|
+
path: path.join(__dirname, '../lib'),
|
|
28
|
+
filename: '[name].js',
|
|
29
|
+
libraryTarget: 'commonjs2',
|
|
30
|
+
},
|
|
31
|
+
module: {
|
|
32
|
+
rules: [
|
|
33
|
+
{
|
|
34
|
+
test: /\.vue$/,
|
|
35
|
+
loader: 'vue-loader',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
test: /\.js$/,
|
|
39
|
+
loader: 'babel-loader',
|
|
40
|
+
exclude: /node_modules/,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
test: /\.scss$/,
|
|
44
|
+
use: [
|
|
45
|
+
'style-loader',
|
|
46
|
+
'css-loader',
|
|
47
|
+
{
|
|
48
|
+
loader: 'sass-loader',
|
|
49
|
+
options: { sassOptions: { silenceDeprecations: ['legacy-js-api', 'import'] } },
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
test: /\.css$/,
|
|
55
|
+
exclude: /node_modules/,
|
|
56
|
+
use: ['style-loader', 'css-loader'],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
test: /\.css$/,
|
|
60
|
+
include: /node_modules/,
|
|
61
|
+
use: ['css-loader'],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
plugins: [new VueLoaderPlugin()],
|
|
66
|
+
externals: {
|
|
67
|
+
vue: 'vue',
|
|
68
|
+
'element-ui': 'element-ui',
|
|
69
|
+
},
|
|
70
|
+
// 优化配置
|
|
71
|
+
optimization: {
|
|
72
|
+
// 不要压缩,保持可读性
|
|
73
|
+
minimize: false,
|
|
74
|
+
// 不要分包,每个组件保持独立
|
|
75
|
+
splitChunks: false,
|
|
76
|
+
},
|
|
77
|
+
// 确保每个模块都有正确的路径解析
|
|
78
|
+
resolve: {
|
|
79
|
+
extensions: ['.js', '.vue', '.json'],
|
|
80
|
+
alias: {
|
|
81
|
+
'@': path.join(__dirname, '../src'),
|
|
82
|
+
vue$: 'vue/dist/vue.esm.js',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const commonConfig = require('./webpack.common.conf');
|
|
2
|
+
const { merge } = require('webpack-merge');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
5
|
+
const webpack = require('webpack');
|
|
6
|
+
|
|
7
|
+
module.exports = merge(commonConfig, {
|
|
8
|
+
output: {
|
|
9
|
+
path: path.join(__dirname, '../lib'),
|
|
10
|
+
filename: 'index.esm.js',
|
|
11
|
+
library: { type: 'module' },
|
|
12
|
+
environment: { module: true },
|
|
13
|
+
},
|
|
14
|
+
experiments: { outputModule: true },
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
17
|
+
{
|
|
18
|
+
test: /\.js$/,
|
|
19
|
+
loader: 'babel-loader',
|
|
20
|
+
exclude: /node_modules/,
|
|
21
|
+
options: {
|
|
22
|
+
presets: [
|
|
23
|
+
[
|
|
24
|
+
'@babel/preset-env',
|
|
25
|
+
{
|
|
26
|
+
targets: { browsers: ['> 1%', 'last 2 versions', 'not ie <= 11'] },
|
|
27
|
+
modules: false,
|
|
28
|
+
loose: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
// 外部化依赖,不打包进组件库
|
|
37
|
+
externals: {
|
|
38
|
+
vue: {
|
|
39
|
+
commonjs: 'vue',
|
|
40
|
+
commonjs2: 'vue',
|
|
41
|
+
amd: 'vue',
|
|
42
|
+
root: 'Vue',
|
|
43
|
+
},
|
|
44
|
+
'element-ui': {
|
|
45
|
+
commonjs: 'element-ui',
|
|
46
|
+
commonjs2: 'element-ui',
|
|
47
|
+
amd: 'element-ui',
|
|
48
|
+
root: 'ELEMENT',
|
|
49
|
+
},
|
|
50
|
+
// 'markdown-it': 'markdown-it',
|
|
51
|
+
// dompurify: 'DOMPurify',
|
|
52
|
+
// prismjs: 'Prism',
|
|
53
|
+
// lodash: '_',
|
|
54
|
+
},
|
|
55
|
+
// 生产模式优化
|
|
56
|
+
mode: 'production',
|
|
57
|
+
optimization: {
|
|
58
|
+
usedExports: true, // 启用 Tree Shaking
|
|
59
|
+
minimize: true, // 启用代码压缩
|
|
60
|
+
minimizer: [
|
|
61
|
+
new TerserPlugin({
|
|
62
|
+
terserOptions: {
|
|
63
|
+
compress: {
|
|
64
|
+
drop_console: true, // 移除 console
|
|
65
|
+
drop_debugger: true, // 移除 debugger
|
|
66
|
+
pure_funcs: ['console.log'], // 移除 console.log
|
|
67
|
+
unused: true, // 删除未使用的变量和函数
|
|
68
|
+
dead_code: true, // 删除不可达代码
|
|
69
|
+
},
|
|
70
|
+
mangle: true, // 混淆变量名
|
|
71
|
+
output: {
|
|
72
|
+
comments: false, // 移除注释
|
|
73
|
+
beautify: false, // 不美化输出
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
extractComments: false,
|
|
77
|
+
parallel: true,
|
|
78
|
+
}),
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
plugins: [
|
|
82
|
+
// 定义环境变量
|
|
83
|
+
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
|
|
84
|
+
// 忽略特定的模块
|
|
85
|
+
new webpack.IgnorePlugin({
|
|
86
|
+
resourceRegExp: /^\.\/locale$/,
|
|
87
|
+
contextRegExp: /moment$/,
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const commonConfig = require('./webpack.common.conf');
|
|
2
|
+
const { merge } = require('webpack-merge');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
5
|
+
const webpack = require('webpack');
|
|
6
|
+
|
|
7
|
+
module.exports = merge(commonConfig, {
|
|
8
|
+
output: {
|
|
9
|
+
path: path.join(__dirname, '../lib'),
|
|
10
|
+
filename: 'index.umd.js',
|
|
11
|
+
library: 'ElementUIX',
|
|
12
|
+
libraryTarget: 'umd',
|
|
13
|
+
globalObject: 'this',
|
|
14
|
+
umdNamedDefine: true,
|
|
15
|
+
},
|
|
16
|
+
// 外部化依赖,不打包进组件库
|
|
17
|
+
externals: {
|
|
18
|
+
// vue: 'Vue',
|
|
19
|
+
// 'element-ui': 'ELEMENT',
|
|
20
|
+
vue: {
|
|
21
|
+
commonjs: 'vue',
|
|
22
|
+
commonjs2: 'vue',
|
|
23
|
+
amd: 'vue',
|
|
24
|
+
root: 'Vue',
|
|
25
|
+
},
|
|
26
|
+
'element-ui': {
|
|
27
|
+
commonjs: 'element-ui',
|
|
28
|
+
commonjs2: 'element-ui',
|
|
29
|
+
amd: 'element-ui',
|
|
30
|
+
root: 'ELEMENT',
|
|
31
|
+
},
|
|
32
|
+
// 'markdown-it': 'markdown-it',
|
|
33
|
+
// dompurify: 'DOMPurify',
|
|
34
|
+
// prismjs: 'Prism',
|
|
35
|
+
// lodash: '_',
|
|
36
|
+
},
|
|
37
|
+
// 生产模式优化
|
|
38
|
+
mode: 'production',
|
|
39
|
+
optimization: {
|
|
40
|
+
usedExports: true, // 启用 Tree Shaking
|
|
41
|
+
minimize: true, // 启用代码压缩
|
|
42
|
+
minimizer: [
|
|
43
|
+
new TerserPlugin({
|
|
44
|
+
terserOptions: {
|
|
45
|
+
compress: {
|
|
46
|
+
drop_console: true, // 移除 console
|
|
47
|
+
drop_debugger: true, // 移除 debugger
|
|
48
|
+
pure_funcs: ['console.log'], // 移除 console.log
|
|
49
|
+
unused: true, // 删除未使用的变量和函数
|
|
50
|
+
dead_code: true, // 删除不可达代码
|
|
51
|
+
},
|
|
52
|
+
mangle: true, // 混淆变量名
|
|
53
|
+
output: {
|
|
54
|
+
comments: false, // 移除注释
|
|
55
|
+
beautify: false, // 不美化输出
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
extractComments: false,
|
|
59
|
+
parallel: true,
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
plugins: [
|
|
64
|
+
// 定义环境变量
|
|
65
|
+
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
|
|
66
|
+
// 忽略特定的模块
|
|
67
|
+
new webpack.IgnorePlugin({
|
|
68
|
+
resourceRegExp: /^\.\/(locale)$/,
|
|
69
|
+
contextRegExp: /moment$/,
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
});
|
package/components.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"typewriter": "./lib/components/Typewriter/index.js",
|
|
3
|
+
"bubble": "./lib/components/Bubble/index.js",
|
|
4
|
+
"bubble-list": "./lib/components/BubbleList/index.js",
|
|
5
|
+
"conversations": "./lib/components/Conversations/index.js",
|
|
6
|
+
"files-card": "./lib/components/FilesCard/index.js",
|
|
7
|
+
"prompts": "./lib/components/Prompts/index.js",
|
|
8
|
+
"sender": "./lib/components/Sender/index.js",
|
|
9
|
+
"thinking": "./lib/components/Thinking/index.js",
|
|
10
|
+
"thought-chain": "./lib/components/ThoughtChain/index.js",
|
|
11
|
+
"welcome": "./lib/components/Welcome/index.js",
|
|
12
|
+
"attachments": "./lib/components/Attachments/index.js"
|
|
13
|
+
}
|
package/package.json
ADDED