Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add 2.7 infra #2497

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: MAIN_PULL_REQUEST

on:
pull_request:
branches: [develop, main, feature]
branches: [develop, main, feature, feat/2.7]
types: [opened, synchronize, reopened]

jobs:
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@
</a>
</p>

English | [简体中文](./README-zh_CN.md)
English | [简体中文](./README-zh_CN.md)

TDesign Vue is a UI component library for Vue 2 and desktop application.

# 🎉 Features

- Desktop application interaction
- High quality UI components for Vue 2.x (< Vue 2.7)
- High quality UI components for Vue 2.x
- Consistent API and UI with TDesign component libraries for other frameworks
- Dark mode and customizable theme
- Support tree-shaking

# 📦 Installation

```shell
npm i tdesign-vue
npm i tdesign-vue // for vue 2.6
npm i tdesign-vue@naruto // for vue 2.7

```

# 🔨 Usage
Expand All @@ -57,9 +59,8 @@ Visit [TDesign Starter](https://tdesign.tencent.com/starter/vue/) to experience
# Browser Support

| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br/> IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br/>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br/>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br/>Safari |
| --- | --- | --- | --- |
| Edge >=91 | Firefox >=83 | Chrome >=91 | Safari >=14.1 |

| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Edge >=91 | Firefox >=83 | Chrome >=91 | Safari >=14.1 |

Read our [browser compatibility](https://github.com/Tencent/tdesign/wiki/Browser-Compatibility) for more details.

Expand All @@ -77,4 +78,4 @@ Contributing is welcome. Read [guidelines for contributing](https://github.com/T

# License

The MIT License. Please see [the license file](./LICENSE) for more information.
The MIT License. Please see [the license file](./LICENSE) for more information.
25 changes: 12 additions & 13 deletions site/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ spline: explain
---

<div style="background: var(--td-warning-color-2); padding: 14px 24px; border-radius: 3px; color: #555a65; line-height: 22px">
<p>tdesign-vue 在 1.4.0 版本之后支持在 vue2.7 中使用</p>
<p>如果您需要在vue2.7中使用tdesign-vue 请安装 tdesign-vue@naruto 或在具体指定版本后加-naruto的标识 我们在1.4版本起的每个版本都同步构建了一份在vue2.7中使用的版本
<p>如[email protected] 适用于 vue 2.6 [email protected] 适用于 vue 2.7</p>
<p>tdesign-vue 在 1.4.0 版本之后开始同步支持在 Vue 2.7 中使用</p>
<p>如果您需要在 Vue2.7 中使用 tdesign-vue 请安装 tdesign-vue@naruto 或在具体指定版本后加-naruto的标识
<p>如[email protected] 适用于 Vue 2.6 [email protected] 适用于 Vue 2.7</p>
</div>

## 安装
Expand All @@ -17,13 +17,13 @@ spline: explain
推荐使用 npm 方式进行开发

```shell
npm i tdesign-vue // 在vue 2.6及以下使用
npm i tdesign-vue@naruto // 在vue 2.7使用
npm i tdesign-vue // 在 Vue 2.6 及以下使用
npm i tdesign-vue@naruto // 在 Vue 2.7 使用
```

### 通过 浏览器引入 安装

目前可以通过 [unpkg.com/tdesign-vue](https://unpkg.com/tdesign-vue) 获取到最新版本的资源,在页面上引入 js 和 css 文件即可开始使用。由于部分组件依赖了`@vue/composition-api`,除了像其他 vue2 版本的组件库一样需要引入`vue`,还需要额外手动引入`@vue/composition-api`。
目前可以通过 [unpkg.com/tdesign-vue](https://unpkg.com/tdesign-vue) 获取到最新版本的资源,在页面上引入 js 和 css 文件即可开始使用。由于部分组件依赖了`@vue/composition-api`,除了像其他 Vue2 版本的组件库一样需要引入`vue`,还需要额外手动引入`@vue/composition-api`。

```html
<link rel="stylesheet" href="https://unpkg.com/tdesign-vue/dist/tdesign.min.css" />
Expand Down Expand Up @@ -75,9 +75,9 @@ Vue.use(TButton);

除此之外,也可以使用 `unplugin-vue-components` 和 `unplugin-auto-import` 来实现自动导入:

如果是在 vue2.6 版本中使用 您仍需在项目引入组件库的少量全局样式变量及`@vue/composition-api`
如果是在 Vue 2.6 版本中使用 您仍需在项目引入组件库的少量全局样式变量及`@vue/composition-api`

如果是在 vue2.7 版本中使用 您不再需要在项目引入`@vue/composition-api`
如果是在 Vue 2.7 版本中使用 您不再需要在项目引入`@vue/composition-api`

```js
import VueCompositionAPI from '@vue/composition-api';
Expand Down Expand Up @@ -182,15 +182,14 @@ A: `0.43.0` 版本开始我们不再引入 `reset.less`,影响最大的是移
import 'tdesign-vue/dist/reset.css';
```

Q: 如何在 vue 2.7 中使用?
Q: 如何在 Vue 2.7 中使用?

A: tdesign-vue 在 `1.4.0` 版本之后支持在 vue2.7 中使用。如果您需要在 vue2.7 中使用 tdesign-vue 请安装 tdesign-vue@naruto 或在具体指定版本后加-naruto 的标识 我们在 1.4 版本起的每个版本都同步构建了一份在 vue2.7 中使用的版本
A: tdesign-vue 在 `1.4.0` 版本之后支持在 Vue2.7 中使用。如果您需要在 Vue2.7 中使用 tdesign-vue 请安装 tdesign-vue@naruto 或在具体指定版本后加-naruto 的标识 我们在 1.4.0 版本起的每个版本都同步构建了一份在 Vue2.7 中使用的版本

如`[email protected]` 适用于 `vue 2.6` `[email protected]` 适用于 `vue 2.7`
如`[email protected]` 适用于 `Vue 2.6` `[email protected]` 适用于 `Vue 2.7`

Q: 为什么使用有些组件的时候会出现一些奇怪的错误?

A: 使用组件的时候看到这类错误 `vue.runtime.esm.js:4605 [Vue warn]: inject() can only be used inside setup() or functional components.` 说明虽然 `package.json` 中设置的版本号为 `^2.6.14`,但实际上安装了 Vue2.7 的版本,可以在 `node_modules` 目录中检查实际安装的版本号。

由于 Vue2.7 和 Vue2.6 不兼容,请务必确保自己安装的版本号是 Vue2.6.x。
如果您确实需要使用 vue2.7 请安装 `tdesign-vue@naruto`
由于 Vue2.7 和 Vue2.6 不兼容,请务必确保自己安装的版本号是 Vue2.6.x。如果您确实需要使用 Vue2.7 请安装 `tdesign-vue@naruto`
28 changes: 15 additions & 13 deletions src/back-top/back-top.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,22 @@ export default defineComponent({
return;
}
let scrollDOM: HTMLElement;
if (containerRef.value.scrollTop === undefined) {
scrollDOM = document.documentElement;
} else {
scrollDOM = containerRef.value;
}
containerRef.value.onscroll = () => {
const { scrollTop } = scrollDOM;
if (scrollTop >= visibleHeight) {
visible.value = true;
if (containerRef.value) {
if (containerRef.value.scrollTop === undefined) {
scrollDOM = document.documentElement;
} else {
scrollDOM = containerRef.value;
}
if (scrollTop < visibleHeight && visible.value) {
visible.value = false;
}
};
containerRef.value.onscroll = () => {
const { scrollTop } = scrollDOM;
if (scrollTop >= visibleHeight) {
visible.value = true;
}
if (scrollTop < visibleHeight && visible.value) {
visible.value = false;
}
};
}
});

onBeforeUnmount(() => {
Expand Down