Skip to content

Commit

Permalink
fix: 解决无效token的报错问题!
Browse files Browse the repository at this point in the history
  • Loading branch information
limintao committed Mar 18, 2024
1 parent 828102e commit 80f46af
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 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)
# 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)

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

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

### 安装
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-turn-clock",
"private": false,
"version": "1.0.0",
"version": "1.0.2",
"author": "li min tao<https://github.com/limintao>",
"license": "MIT",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions packages/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* @Author: limit
* @Date: 2023-06-18 17:40:29
* @LastEditTime: 2023-08-01 16:32:19
* @LastEditTime: 2024-03-18 16:15:19
* @LastEditors: limit
* @FilePath: /vue-turn-clock/packages/index.ts
* @Description: 由limit创建!
*/
import { withInstall } from './utils/install';
import { withInstall, type WithInstallType } from './utils/install';
import CountClock from './count-clock/countClock';

export default withInstall(CountClock);
export default withInstall(CountClock) as WithInstallType<typeof CountClock>;
36 changes: 23 additions & 13 deletions packages/utils/install.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import type { Plugin } from 'vue';
/*
* @Author: limit
* @Date: 2023-06-18 17:40:29
* @LastEditTime: 2024-03-18 15:51:51
* @LastEditors: limit
* @FilePath: /vue-turn-clock/packages/utils/install.ts
* @Description: 由limit创建!
*/
import type { Plugin, App } from 'vue';

export type WithInstallType<T> = T & Plugin;

export const withInstall = <T, E extends Record<string, any>>(
main: T,
extra?: E
main: T,
extra?: E
) => {
(main as T & Plugin).install = (app): void => {
for (const comp of [main, ...Object.values(extra ?? {})]) {
app.component(comp.name, comp);
}
};
(main as WithInstallType<T>).install = (app: App): void => {
for (const comp of [main, ...Object.values(extra ?? {})]) {
app.component(comp.name, comp);
}
};

if (extra) {
for (const [key, comp] of Object.entries(extra)) {
(main as any)[key] = comp;
}
if (extra) {
for (const [key, comp] of Object.entries(extra)) {
(main as any)[key] = comp;
}
return main as T & Plugin & E;
}
return main as WithInstallType<T> & E;
};
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2016",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": ["ES2016", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"module": "ES6",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export default defineConfig({
resolve: { dedupe: ['vue'] },
build: {
outDir: 'lib',
target: 'es6',
lib: {
name: 'index',
entry: resolve(__dirname, 'packages/index.ts'),
formats: ['es', 'umd', 'cjs'],
fileName: format => `index.${format}.js`,
},
cssCodeSplit: true,
Expand Down

0 comments on commit 80f46af

Please sign in to comment.