@peng_kai/kit 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ async function getRoutes() {
16
16
  for (const name in routeFiles) {
17
17
  const module: any = await routeFiles[name]();
18
18
 
19
- if (Object.hasOwn(module?.default ?? {}, RouteSymbol))
19
+ if (module?.default?.[RouteSymbol])
20
20
  Array.prototype.push.apply(routes, module.default());
21
21
  }
22
22
 
@@ -16,7 +16,7 @@ export async function getRouteGuards() {
16
16
  for (const name in routeGuardFiles) {
17
17
  const module: any = await routeGuardFiles[name]();
18
18
 
19
- if (Object.hasOwn(module?.default ?? {}, RouteGuardSymbol)) {
19
+ if (module?.default?.[RouteGuardSymbol]) {
20
20
  const guard = module.default;
21
21
 
22
22
  routeGuards.push(guard);
@@ -11,7 +11,7 @@ export async function getStartups() {
11
11
  const module: any = await moduleLoader();
12
12
  const plugin: StartupFn = module?.default ?? {};
13
13
 
14
- if (!Object.hasOwn(plugin, StartupSymbol))
14
+ if (!plugin?.[StartupSymbol])
15
15
  continue;
16
16
 
17
17
  startupPaths.push(path);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",
@@ -1,4 +1,5 @@
1
1
  import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import { isSSR } from '../utils';
2
3
 
3
4
  export { createRequest };
4
5
 
@@ -17,6 +18,9 @@ function createRequest<Req, OResp, Resp = Api.TransformPageResult<OResp>>(
17
18
  // 返回 API 数据中的 data 字段值,默认
18
19
  async function request(reqData: Req, config?: ReqConfig): Promise<Api.GetDataField<Resp>>;
19
20
  async function request(reqData: Req, config?: ReqConfig): Promise<any> {
21
+ // if (isSSR())
22
+ // return null;
23
+
20
24
  const params = paramBuilder(reqData);
21
25
  const serviceName = params.headers?.['Service-Name'] ?? '';
22
26
  const service = createRequest.services[serviceName]?.server;
package/request/type.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  declare namespace Api {
2
- type Request = ((reqData: any, options?: Options) => Promise<any>) & { id: string };
2
+ type Request = ((reqData: any, options?: Options) => Promise<any>) & {
3
+ id: string
4
+ setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
5
+ };
3
6
  // type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
4
7
  interface PageParam {
5
8
  page: number
package/utils/index.ts CHANGED
@@ -30,6 +30,10 @@ export function hasToken() {
30
30
  return document.cookie.includes('has_token=1');
31
31
  }
32
32
 
33
+ export function isSSR() {
34
+ return typeof window === 'undefined';
35
+ }
36
+
33
37
  export function fixed() {
34
38
 
35
39
  // return (12).toFixed
@@ -90,6 +94,10 @@ export function getScanBrowser(chain: string, hash: string, type: 'transaction'
90
94
  return `https://suiexplorer.com/${_type}/${hash}`;
91
95
  },
92
96
  ZKSYNC: () => `https://explorer.zksync.io/${evmType()}/${hash}`,
97
+ SOLANA: () => {
98
+ const _type = (<TypeMap>{ address: 'account' })[type] ?? type;
99
+ return `https://solscan.io/${_type}/${hash}`;
100
+ },
93
101
  }[_chain] ?? (() => '');
94
102
 
95
103
  return urlFn();