Skip to content

Commit

Permalink
Merge pull request #17 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
update files
  • Loading branch information
GuoXiCheng authored Nov 29, 2023
2 parents 0c927c4 + 6874fb7 commit 2578282
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 119 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
collectCoverageFrom: [
"src/**/*.ts", // 包括 src 目录下所有的 TypeScript 文件
"!src/**/*.d.ts", // 排除 TypeScript 声明文件
"!src/__test__/**/*.ts"
"!src/__tests__/**/*.ts"
],
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "tiny-crud",
"version": "1.0.10",
"description": "",
"main": "dist/tiny-crud.cjs.js",
"module": "dist/tiny-crud.esm.js",
"main": "dist/bundle.cjs.js",
"module": "dist/bundle.esm.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "jest --coverage",
"prebuild": "rimraf ./dist",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export default {
input: 'src/index.ts',
output: [
{
file: 'dist/tiny-crud.cjs.js', // CommonJS 输出文件
file: 'dist/bundle.cjs.js', // CommonJS 输出文件
format: 'cjs',
},
{
file: 'dist/tiny-crud.esm.js', // ES Module 输出文件
file: 'dist/bundle.esm.js', // ES Module 输出文件
format: 'esm',
},
],
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions src/enum.ts

This file was deleted.

14 changes: 13 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
export {StoragePlatformType, RequestLibType} from './type';
export enum StoragePlatform {
gitee = "gitee",
github = "github",
gitlab = "gitlab"
}

export enum RequestLib {
axios = "axios",
wx = "wx"
}

export type StoragePlatformType = keyof typeof StoragePlatform;
export type RequestLibType = keyof typeof RequestLib;
// export type TinyCRUDConfig = {
// base_url: string;
// owner: string;
Expand Down
45 changes: 45 additions & 0 deletions src/tiny-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { RequestLib, RequestLibType } from ".";

interface TinyRequest {
get(): void;
post(): void;
};

class AxiosRequest implements TinyRequest {
constructor() {}
get() { }
post() { }
}

class WxRequest implements TinyRequest {
get() { }
post() { }
}

abstract class TinyRequestFactory {
abstract createRequest(): TinyRequest;
}

class AxiosRequestFactory extends TinyRequestFactory {
createRequest() {
return new AxiosRequest();
}
}

class WxRequestFactory extends TinyRequestFactory {
createRequest() {
return new WxRequest();
}
}

function clientNode(requestLibType: RequestLibType, requestInstance: any) {
switch(requestLibType) {
case RequestLib.axios:
return new AxiosRequestFactory().createRequest();
case RequestLib.wx:
return new WxRequestFactory().createRequest();
default:
throw new Error("request lib not support");
}
}

4 changes: 0 additions & 4 deletions src/type.ts

This file was deleted.

200 changes: 101 additions & 99 deletions tsconfig.json

Large diffs are not rendered by default.

0 comments on commit 2578282

Please sign in to comment.