Skip to content

Commit e56fff1

Browse files
author
weilei
committed
refactor(docs): 更新文档中的依赖名称为 vue-element-ui-x
1 parent e5b7149 commit e56fff1

File tree

5 files changed

+99
-130
lines changed

5 files changed

+99
-130
lines changed

docs/src/community/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Element-UI-X 是一个开源组件库,我们欢迎所有开发者加入我们
1616

1717
我们的组件库通过 NPM 发布:
1818

19-
- [@element-x/core](https://www.npmjs.com/package/@element-x/core)
19+
- [vue-element-ui-x](https://www.npmjs.com/package/vue-element-ui-x)
2020

2121
## 加入我们
2222

docs/src/guide/components.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Element-UI-X 提供了一系列专为 AI 交互设计的 Vue 组件,让你能
1010

1111
```bash
1212
# npm
13-
npm install @element-x/core
13+
npm install vue-element-ui-x
1414

1515
# 或者使用 yarn
16-
yarn add @element-x/core
16+
yarn add vue-element-ui-x
1717
```
1818

1919
然后在你的入口文件中引入组件库:
@@ -22,7 +22,7 @@ yarn add @element-x/core
2222
import Vue from 'vue';
2323
import ElementUI from 'element-ui';
2424
import 'element-ui/lib/theme-chalk/index.css';
25-
import ElementX from '@element-x/core';
25+
import ElementX from 'vue-element-ui-x';
2626

2727
Vue.use(ElementUI);
2828
Vue.use(ElementX);

docs/src/guide/installation.md

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ new Vue({
6262

6363
```js
6464
import Vue from 'vue';
65-
import { ElXTypewriter } from '@element-x/core';
65+
import { ElXTypewriter } from 'vue-element-ui-x';
6666

6767
// 注册组件
6868
Vue.component(ElXTypewriter.name, ElXTypewriter);
@@ -91,7 +91,7 @@ npm install babel-plugin-component -D
9191
[
9292
"component",
9393
{
94-
"libraryName": "@element-x/core",
94+
"libraryName": "vue-element-ui-x",
9595
"style": false
9696
},
9797
"element-x"
@@ -105,68 +105,13 @@ npm install babel-plugin-component -D
105105
```js
106106
import Vue from 'vue';
107107
import { Button, Select } from 'element-ui';
108-
import { ElXTypewriter } from '@element-x/core';
108+
import { ElXTypewriter } from 'vue-element-ui-x';
109109

110110
Vue.component(Button.name, Button);
111111
Vue.component(Select.name, Select);
112112
Vue.component(ElXTypewriter.name, ElXTypewriter);
113113
```
114114

115-
## 引入样式
116-
117-
Element-UI-X 的样式依赖于 Element UI 的主题系统。你需要在项目中引入样式文件:
118-
119-
### 完整引入样式
120-
121-
```js
122-
// 在 main.js 中
123-
import 'element-ui/lib/theme-chalk/index.css';
124-
import '@element-x/core/lib/theme/index.css';
125-
```
126-
127-
### 使用 SCSS
128-
129-
如果你使用 SCSS,可以在样式文件中引入:
130-
131-
```scss
132-
/* 引入 Element UI 变量 */
133-
@import '~element-ui/packages/theme-chalk/src/common/var';
134-
135-
/* 引入 Element-UI-X 变量 */
136-
@import '~@element-x/core/src/theme/common/var';
137-
138-
/* 自定义变量 */
139-
$--color-ai-bubble-user: #e8f4ff;
140-
$--color-ai-bubble-bot: #f7f7f7;
141-
142-
/* 引入组件样式 */
143-
@import '~element-ui/packages/theme-chalk/src/index';
144-
@import '~@element-x/core/src/theme/index';
145-
```
146-
147-
## CDN 引入
148-
149-
你也可以通过 CDN 引入 Element-UI-X(暂未提供):
150-
151-
```html
152-
<!-- 引入 Vue -->
153-
<script src="https://unpkg.com/vue@2.6.14/dist/vue.js"></script>
154-
155-
<!-- 引入 Element UI -->
156-
<link
157-
rel="stylesheet"
158-
href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"
159-
/>
160-
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
161-
162-
<!-- 引入 Element-UI-X(未来将提供) -->
163-
<link
164-
rel="stylesheet"
165-
href="https://unpkg.com/@element-x/core/lib/theme/index.css"
166-
/>
167-
<script src="https://unpkg.com/@element-x/core/lib/index.js"></script>
168-
```
169-
170115
## 验证安装
171116

172117
安装完成后,你可以在组件中使用 Element-UI-X 的组件:
@@ -175,7 +120,7 @@ $--color-ai-bubble-bot: #f7f7f7;
175120
<template>
176121
<div>
177122
<el-button>Element UI 按钮</el-button>
178-
<el-x-typewriter text="这是一个打字机效果组件"></el-x-typewriter>
123+
<el-x-typewriter content="这是一个打字机效果组件"></el-x-typewriter>
179124
</div>
180125
</template>
181126
```

docs/src/guide/quickstart.md

Lines changed: 88 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
在成功 [安装](./installation.md) Element-UI-X 之后,你可以开始使用组件库中的组件。以下是一个简单的示例,展示如何使用打字机组件:
88

9+
:::demo
10+
911
```html
1012
<template>
1113
<div class="demo-container">
@@ -21,9 +23,9 @@
2123
<div class="avatar">AI</div>
2224
<div class="content">
2325
<el-x-typewriter
24-
:text="aiResponse"
25-
:type-speed="30"
26-
@typing-complete="onTypingComplete"
26+
:content="aiResponse"
27+
:typing="{ interval: 30, step: 1 }"
28+
@finish="onTypingComplete"
2729
ref="typewriter"
2830
/>
2931
</div>
@@ -52,19 +54,16 @@
5254
mounted() {
5355
// 页面加载后自动开始打字效果
5456
this.$nextTick(() => {
55-
this.$refs.typewriter.startTyping();
57+
this.$refs.typewriter.restart();
5658
});
5759
},
5860
methods: {
59-
onTypingComplete(text) {
60-
console.log('打字效果完成:', text);
61+
onTypingComplete(instance) {
62+
console.log('打字效果完成:', instance);
6163
},
6264
regenerateResponse() {
6365
// 模拟重新生成回复
64-
this.$refs.typewriter.eraseAll();
65-
setTimeout(() => {
66-
this.$refs.typewriter.startTyping();
67-
}, 300);
66+
this.$refs.typewriter.restart();
6867
},
6968
},
7069
};
@@ -131,28 +130,41 @@
131130
</style>
132131
```
133132

133+
:::
134+
134135
## 使用多个组件
135136

136137
Element-UI-X 提供了多个组件,你可以组合使用它们来构建完整的 AI 交互界面。以下是一个简化的示例:
137138

139+
:::demo
140+
138141
```html
139142
<template>
140143
<div class="ai-chat">
141144
<!-- 思考动画组件 -->
142-
<el-x-thinking v-if="isThinking" />
145+
<el-x-thinking
146+
v-if="isThinking"
147+
status="thinking"
148+
content="AI正在思考中..."
149+
/>
143150

144151
<!-- 打字机组件 -->
145152
<el-x-typewriter
146153
v-else-if="aiResponse"
147-
:text="aiResponse"
154+
:content="aiResponse"
155+
:typing="{ interval: 40, step: 1 }"
148156
ref="typewriter"
149157
/>
150-
158+
<br />
151159
<!-- 发送框组件 -->
152160
<el-x-sender
153161
v-model="userInput"
154-
@send="sendMessage"
162+
@submit="sendMessage"
155163
:disabled="isThinking"
164+
:loading="senderLoading"
165+
ref="sender"
166+
clearable
167+
@cancel="handleCancel"
156168
/>
157169
</div>
158170
</template>
@@ -164,71 +176,78 @@ Element-UI-X 提供了多个组件,你可以组合使用它们来构建完整
164176
userInput: '',
165177
aiResponse: '',
166178
isThinking: false,
179+
senderLoading: false,
180+
timeoutId: null,
167181
};
168182
},
169183
methods: {
170-
sendMessage() {
171-
if (!this.userInput.trim()) return;
184+
sendMessage(message) {
185+
if (!message.trim()) return;
172186
173-
const userMessage = this.userInput;
174-
this.userInput = '';
175-
this.isThinking = true;
187+
const userMessage = message;
188+
this.senderLoading = true;
176189
177190
// 模拟AI响应
178-
setTimeout(() => {
179-
this.isThinking = false;
180-
this.aiResponse = `你发送的消息是: "${userMessage}"。这是一个AI响应示例。`;
181-
182-
this.$nextTick(() => {
183-
this.$refs.typewriter.startTyping();
184-
});
185-
}, 1500);
191+
this.timeoutId = setTimeout(() => {
192+
this.isThinking = true;
193+
this.senderLoading = false;
194+
195+
setTimeout(() => {
196+
this.isThinking = false;
197+
this.aiResponse = `你发送的消息是: "${userMessage}"。这是一个AI响应示例。`;
198+
199+
this.$nextTick(() => {
200+
this.$refs.typewriter.restart();
201+
});
202+
}, 1500);
203+
}, 500);
204+
},
205+
handleCancel() {
206+
this.senderLoading = false;
207+
if (this.timeoutId) {
208+
clearTimeout(this.timeoutId);
209+
this.timeoutId = null;
210+
}
211+
this.$message.info('取消发送');
186212
},
187213
},
188214
};
189215
</script>
190-
```
191-
192-
## 主题定制
193216

194-
Element-UI-X 的组件样式继承自 Element UI 的主题系统,你可以通过修改主题变量来定制组件的外观:
195-
196-
```scss
197-
/* 在你的样式文件中 */
198-
@import '~element-ui/packages/theme-chalk/src/common/var';
199-
200-
/* 自定义 Element UI 主题变量 */
201-
$--color-primary: #6b46c1;
202-
$--color-success: #38a169;
203-
$--color-warning: #d69e2e;
204-
$--color-danger: #e53e3e;
205-
$--color-info: #4299e1;
206-
207-
/* 自定义 Element-UI-X 主题变量 */
208-
$--color-ai-bubble-user: lighten($--color-primary, 40%);
209-
$--color-ai-bubble-bot: lighten($--color-info, 40%);
210-
$--color-ai-cursor: $--color-primary;
211-
212-
/* 引入组件样式 */
213-
@import '~element-ui/packages/theme-chalk/src/index';
214-
@import '~@element-x/core/src/theme/index';
217+
<style>
218+
.ai-chat {
219+
max-width: 800px;
220+
margin: 0 auto;
221+
padding: 20px;
222+
border: 1px solid #ebeef5;
223+
border-radius: 4px;
224+
}
225+
</style>
215226
```
216227

228+
:::
229+
217230
## 组件引用和方法调用
218231

219232
Element-UI-X 的组件支持通过 ref 引用来调用组件方法:
220233

234+
:::demo
235+
221236
```html
222237
<template>
223238
<div>
224239
<el-x-typewriter
225240
ref="typewriter"
226-
:text="text"
241+
:content="text"
242+
:typing="{ interval: 40, step: 1 }"
227243
/>
228244

229-
<el-button @click="startTyping">开始打字</el-button>
230-
<el-button @click="typeAll">立即完成</el-button>
231-
<el-button @click="eraseAll">清空</el-button>
245+
<div class="demo-controls">
246+
<el-button-group>
247+
<el-button @click="finishTyping">立即完成</el-button>
248+
<el-button @click="restart">重新开始</el-button>
249+
</el-button-group>
250+
</div>
232251
</div>
233252
</template>
234253

@@ -240,24 +259,29 @@ Element-UI-X 的组件支持通过 ref 引用来调用组件方法:
240259
};
241260
},
242261
methods: {
243-
startTyping() {
244-
this.$refs.typewriter.startTyping();
245-
},
246-
typeAll() {
247-
this.$refs.typewriter.typeAll();
262+
finishTyping() {
263+
this.$refs.typewriter.finishTyping();
248264
},
249-
eraseAll() {
250-
this.$refs.typewriter.eraseAll();
265+
restart() {
266+
this.$refs.typewriter.restart();
251267
},
252268
},
253269
};
254270
</script>
271+
272+
<style>
273+
.demo-controls {
274+
margin-top: 15px;
275+
}
276+
</style>
255277
```
256278

279+
:::
280+
257281
## 下一步
258282

259283
现在你已经了解了 Element-UI-X 的基本用法,可以:
260284

261285
- 查看 [组件](../components/) 文档了解每个组件的详细用法
262-
- 查看 [示例](../examples/) 了解更多实际应用场景
263-
- 参考 [主题](./theme.md) 文档学习如何定制组件样式
286+
<!-- - 查看 [示例](../examples/) 了解更多实际应用场景
287+
- 参考 [主题](./theme.md) 文档学习如何定制组件样式 -->

0 commit comments

Comments
 (0)