-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from GuoXiCheng/dev-c
update files
- Loading branch information
Showing
9 changed files
with
165 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.