Browse Source

'调整isClient字段的位置'

main
郑州 3 years ago
parent
commit
2194b5a8e8
9 changed files with 27 additions and 11 deletions
  1. +2
    -1
      src/components/AppHeader/AppHeader.tsx
  2. +1
    -1
      src/components/AppHeader/components/userCenter/UserCenter.tsx
  3. +6
    -2
      src/pages/login/index.tsx
  4. +2
    -1
      src/services/system.ts
  5. +1
    -1
      src/services/user.ts
  6. +1
    -1
      src/utils/hooks.ts
  7. +6
    -2
      src/utils/request.ts
  8. +4
    -2
      src/utils/storage.ts
  9. +4
    -0
      src/utils/tool.ts

+ 2
- 1
src/components/AppHeader/AppHeader.tsx View File

@@ -7,7 +7,7 @@ import ZoomIcon from './components/zoom';
import logoImg from './assets/logo.png';
import { useModel } from 'umi';
import UserCenter from './components/userCenter';
import system, { isClient } from '@/services/system';
import system from '@/services/system';
import SvgIcon from '../SvgIcon';
import classNames from 'classnames';
import { CloudDownloadOutlined } from '@ant-design/icons';
@@ -15,6 +15,7 @@ import ATooltip from '../Tooltip';
import SyncModal from '../SyncModal';
import { useState } from 'react';
import storage from '@/utils/storage';
import { isClient } from '@/utils/tool';

export default function AppHeader(props) {
const { className, style } = props;


+ 1
- 1
src/components/AppHeader/components/userCenter/UserCenter.tsx View File

@@ -12,8 +12,8 @@ import { useState } from 'react';
import styles from './UserCenter.less';
import defaultAvatorImg from '@/assets/avator_default.svg';
import FolderSetModal from './FolderSetModal';
import { isClient } from '@/services/system';
import storage from '@/utils/storage';
import { isClient } from '@/utils/tool';

interface UserCenterProps {
className?: string;


+ 6
- 2
src/pages/login/index.tsx View File

@@ -6,13 +6,17 @@ import { MobileFilled, LockFilled } from '@ant-design/icons';
import { useCallback } from 'react';
import { useEffect } from 'react';
import { login } from '@/services/user';
import { firstCharToUpperCase, handleRequest, passwordReg } from '@/utils/tool';
import {
firstCharToUpperCase,
handleRequest,
isClient,
passwordReg,
} from '@/utils/tool';
import { useForm } from 'antd/lib/form/Form';
import classNames from 'classnames';
import SmsInputer from './SmsInputer';
import { memoize } from 'lodash';
import { Rule } from 'antd/lib/form';
import { isClient } from '@/services/system';
import storage from '@/utils/storage';
import { useRef } from 'react';
import { useLayoutEffect } from 'react';


+ 2
- 1
src/services/system.ts View File

@@ -1,8 +1,9 @@
import { fetchLocalApi } from '@/utils/request';
import { isClient } from '@/utils/tool';
import { DATA } from './API';
import { sendSocketMessage } from './socket';

export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT;
console.log('system initial: ????');

const noop = () => {};
const safeCall = <T>(f: T, repalceF = noop) => (isClient ? f : repalceF);


+ 1
- 1
src/services/user.ts View File

@@ -3,7 +3,7 @@ import { fetchApi } from '@/utils/request';
import storage from '@/utils/storage';
import { errorReponse, firstCharToLowerCase, isReqSuccess } from '@/utils/tool';
import { propertyOf } from 'lodash';
import system, { isClient } from './system';
import system from './system';
import { DATA } from './API';

export async function queryCurrent() {


+ 1
- 1
src/utils/hooks.ts View File

@@ -2,11 +2,11 @@ import { useCallback, useEffect, useState } from 'react';
import {
firstCharToLowerCase,
firstCharToUpperCase,
isClient,
Subject,
} from '@/utils/tool';
import { API, DATA } from '@/services/API';
import dayjs from 'dayjs';
import { isClient } from '@/services/system';
import { throttle } from 'lodash';
import { fetchApi } from './request';
import storage from './storage';


+ 6
- 2
src/utils/request.ts View File

@@ -1,9 +1,13 @@
import { API } from '@/services/API';
import { isClient } from '@/services/system';
import { message } from 'antd';
import { request } from 'umi';
import { parseRequest } from './request.config';
import { errorReponse, firstCharToLowerCase, handleRequest } from './tool';
import {
errorReponse,
firstCharToLowerCase,
handleRequest,
isClient,
} from './tool';

const remoteUrl = window.systemConfig?.remoteUrl || '';
const gatewayPort = window.systemConfig?.gatewayPort || 7888;


+ 4
- 2
src/utils/storage.ts View File

@@ -1,5 +1,6 @@
import system, { isClient } from '@/services/system';
import system from '@/services/system';
import { identity } from 'lodash';
import { isClient } from './tool';

const keepSaveKeyMap = new Map();

@@ -35,12 +36,13 @@ const storage = {
};

if (isClient && window.addIpcRendererListener) {
console.log('try to reload local data');
storage.clear();
window.addIpcRendererListener(
'initialStorageData',
(_, hash: { keyList?: string[]; [key: string]: any }) => {
const kList = hash.keyList || [];
console.log('reload data:', hash);
kList.forEach((key: string) => {
keepSaveKeyMap.set(key, true);
storage.set(key, hash[key]);


+ 4
- 0
src/utils/tool.ts View File

@@ -1,3 +1,7 @@
console.log('initial tool.js');

export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT;

export function firstCharToLowerCase(obj: any) {
return Object.entries(obj).reduce(
(o: { [key: string]: any }, [key, value]) => {


Loading…
Cancel
Save