Skip to content

Commit

Permalink
perf(share & default): add share func for request feature & fix some …
Browse files Browse the repository at this point in the history
…default of hooks
  • Loading branch information
innocces committed Oct 14, 2021
1 parent 28b96f8 commit 879ca4b
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 15 deletions.
28 changes: 26 additions & 2 deletions packages/app/project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,39 @@
"setting": {
"urlCheck": true,
"es6": false,
"enhance": true,
"postcss": false,
"preloadBackgroundData": false,
"minified": false,
"newFeature": true,
"autoAudits": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": false,
"scopeDataCheck": false,
"useCompilerModule": false
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false
},
"compileType": "miniprogram",
"simulatorType": "wechat",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/useAccountInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DocPage from '@components/DocPage';
import { useAccountInfo } from 'taro-hooks';

export default () => {
const { miniProgram = {}, plugin = {} } = useAccountInfo();
const { miniProgram = {}, plugin = {} } = useAccountInfo() || {};

return (
<>
Expand Down
13 changes: 4 additions & 9 deletions packages/app/src/pages/useLaunchOptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ import { SceneEnum } from '../../constant';
const MOCK = '1';

const transferOptions = (launchOptions: General.LaunchOptionsApp) =>
Object.keys(launchOptions).map((key: any) => {
let desc = JSON.stringify(
launchOptions[key as keyof General.LaunchOptionsApp] || '',
);
Object.entries(launchOptions).map(([key, value]) => {
let desc = JSON.stringify(value || '');

if (key === 'scene') {
desc =
desc +
':' +
(SceneEnum[launchOptions[key as keyof General.LaunchOptionsApp]] || '');
desc = desc + ':' + (SceneEnum[value] || '');
}
return {
label: key + ':',
Expand All @@ -31,7 +26,7 @@ const transferOptions = (launchOptions: General.LaunchOptionsApp) =>
});

export default () => {
const launchOptions = useLaunchOptions();
const launchOptions = useLaunchOptions() || {};
const env = useEnv();
return (
<>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/axios/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest requstMethod',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/cacheKey/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 缓存 & SWR',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 并行请求',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/debounce/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 防抖',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 默认用法',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/fetch/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 默认请求库',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/loadMore/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 加载更多基本用法',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 上拉加载更多',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest Loading Delay',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/manual/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 手动触发',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/mutate/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 突变',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 普通分页',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 带缓存的分页',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/polling/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 轮询',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/preload/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 预加载',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/ready/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 依赖请求',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest refreshDeps',
enableShareAppMessage: true,
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 屏幕聚焦重新请求',
enableShareAppMessage: true,
};
1 change: 1 addition & 0 deletions packages/app/src/pages/useRequest/throttle/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
navigationBarTitleText: 'useRequest 节流',
enableShareAppMessage: true,
};
2 changes: 1 addition & 1 deletion packages/app/src/pages/useUserInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const transferOptions = (userInfo: UserInfo) =>
}));

export default () => {
const [userInfo, { getUserInfo, getUserProfile }] = useUserInfo();
const [userInfo = {}, { getUserInfo, getUserProfile }] = useUserInfo();
const [login] = useLogin();

const handleGetUserInfo = useCallback(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/src/useAccountInfo/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getAccountInfoSync } from '@tarojs/taro';
import { useCallback, useEffect, useState } from 'react';

export type Result = getAccountInfoSync.AccountInfo | {};
export type Result = getAccountInfoSync.AccountInfo | undefined;

function useAccountInfo(): Result {
const [accountInfo, setAccountInfo] = useState<Result>({});
const [accountInfo, setAccountInfo] = useState<Result>();

useEffect(() => {
getAccountInfo();
Expand Down

2 comments on commit 879ca4b

@vercel
Copy link

@vercel vercel bot commented on 879ca4b Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

taro-hooks – ./

taro-hooks-innocces.vercel.app
taro-hooks-git-main-innocces.vercel.app
taro-hooks-theta.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 879ca4b Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

taro-hooks-h5 – ./

taro-hooks-h5-green.vercel.app
taro-hooks-h5-git-main-innocces.vercel.app
taro-hooks-h5-innocces.vercel.app

Please sign in to comment.