Skip to content

Commit 80f46af

Browse files
committed
fix: 解决无效token的报错问题!
1 parent 828102e commit 80f46af

File tree

7 files changed

+33
-23
lines changed

7 files changed

+33
-23
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# vue-turn-clock [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/limintao/vue-turn-clock/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/vue-turn-clock.svg?style=flat)](https://www.npmjs.com/package/vue-turn-clock) [![npm](https://img.shields.io/npm/v/vue-turn-clock.svg)](https://www.npmjs.com/package/vue-turn-clock) [![npm](https://img.shields.io/npm/dt/vue-turn-clock.svg)](https://www.npmjs.com/package/vue-turn-clock)
1+
# vue-turn-clock [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/limintao/vue-turn-clock/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/vue-turn-clock.svg?style=flat)](https://www.npmjs.com/package/vue-turn-clock) [![npm](https://img.shields.io/npm/dt/vue-turn-clock.svg)](https://www.npmjs.com/package/vue-turn-clock)
22

33
这是一个简单的翻页倒计时组件,也可以是展示当前时间!
44

5-
- 💪 Vue 3 组合式 API
5+
- 💪 支持 Vue 3 组合式 API
66
- 🔥 使用 TypeScript 编写
77

88
### 安装

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-turn-clock",
33
"private": false,
4-
"version": "1.0.0",
4+
"version": "1.0.2",
55
"author": "li min tao<https://github.com/limintao>",
66
"license": "MIT",
77
"type": "module",

packages/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* @Author: limit
33
* @Date: 2023-06-18 17:40:29
4-
* @LastEditTime: 2023-08-01 16:32:19
4+
* @LastEditTime: 2024-03-18 16:15:19
55
* @LastEditors: limit
66
* @FilePath: /vue-turn-clock/packages/index.ts
77
* @Description: 由limit创建!
88
*/
9-
import { withInstall } from './utils/install';
9+
import { withInstall, type WithInstallType } from './utils/install';
1010
import CountClock from './count-clock/countClock';
1111

12-
export default withInstall(CountClock);
12+
export default withInstall(CountClock) as WithInstallType<typeof CountClock>;

packages/utils/install.ts

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
import type { Plugin } from 'vue';
1+
/*
2+
* @Author: limit
3+
* @Date: 2023-06-18 17:40:29
4+
* @LastEditTime: 2024-03-18 15:51:51
5+
* @LastEditors: limit
6+
* @FilePath: /vue-turn-clock/packages/utils/install.ts
7+
* @Description: 由limit创建!
8+
*/
9+
import type { Plugin, App } from 'vue';
10+
11+
export type WithInstallType<T> = T & Plugin;
212

313
export const withInstall = <T, E extends Record<string, any>>(
4-
main: T,
5-
extra?: E
14+
main: T,
15+
extra?: E
616
) => {
7-
(main as T & Plugin).install = (app): void => {
8-
for (const comp of [main, ...Object.values(extra ?? {})]) {
9-
app.component(comp.name, comp);
10-
}
11-
};
17+
(main as WithInstallType<T>).install = (app: App): void => {
18+
for (const comp of [main, ...Object.values(extra ?? {})]) {
19+
app.component(comp.name, comp);
20+
}
21+
};
1222

13-
if (extra) {
14-
for (const [key, comp] of Object.entries(extra)) {
15-
(main as any)[key] = comp;
16-
}
23+
if (extra) {
24+
for (const [key, comp] of Object.entries(extra)) {
25+
(main as any)[key] = comp;
1726
}
18-
return main as T & Plugin & E;
27+
}
28+
return main as WithInstallType<T> & E;
1929
};

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
3+
"target": "ES2016",
44
"useDefineForClassFields": true,
55
"module": "ESNext",
6-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
"lib": ["ES2016", "DOM", "DOM.Iterable"],
77
"skipLibCheck": true,
88

99
/* Bundler mode */

tsconfig.node.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"composite": true,
44
"skipLibCheck": true,
5-
"module": "ESNext",
5+
"module": "ES6",
66
"moduleResolution": "bundler",
77
"allowSyntheticDefaultImports": true
88
},

vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export default defineConfig({
1515
resolve: { dedupe: ['vue'] },
1616
build: {
1717
outDir: 'lib',
18+
target: 'es6',
1819
lib: {
1920
name: 'index',
2021
entry: resolve(__dirname, 'packages/index.ts'),
21-
formats: ['es', 'umd', 'cjs'],
2222
fileName: format => `index.${format}.js`,
2323
},
2424
cssCodeSplit: true,

0 commit comments

Comments
 (0)