提交 c8f3aa48365da33c210d853120c2722f6c70bf5e

作者 Yu
提交者 GitHub
2 个父辈 35d81a6e b354400d

Merge pull request #3 from umijs/feat/analysis

remove GridContent dep
1   -import React, { PureComponent } from 'react';
2   -import { connect } from 'dva';
3   -import styles from './GridContent.less';
4   -
5   -class GridContent extends PureComponent {
6   - render() {
7   - const { contentWidth, children } = this.props;
8   - let className = `${styles.main}`;
9   - if (contentWidth === 'Fixed') {
10   - className = `${styles.main} ${styles.wide}`;
11   - }
12   - return <div className={className}>{children}</div>;
13   - }
14   -}
15   -
16   -export default connect(({ setting }) => ({
17   - contentWidth: setting.contentWidth,
18   -}))(GridContent);
1   -.main {
2   - width: 100%;
3   - height: 100%;
4   - min-height: 100%;
5   - transition: 0.3s;
6   - &.wide {
7   - max-width: 1200px;
8   - margin: 0 auto;
9   - }
10   -}
1   -import { stringify } from 'qs';
2   -import request from '@/utils/request';
3   -
4   -export async function queryProjectNotice() {
5   - return request('/api/project/notice');
6   -}
7   -
8   -export async function queryActivities() {
9   - return request('/api/activities');
10   -}
11   -
12   -export async function queryRule(params) {
13   - return request(`/api/rule?${stringify(params)}`);
14   -}
15   -
16   -export async function removeRule(params) {
17   - return request('/api/rule', {
18   - method: 'POST',
19   - body: {
20   - ...params,
21   - method: 'delete',
22   - },
23   - });
24   -}
25   -
26   -export async function addRule(params) {
27   - return request('/api/rule', {
28   - method: 'POST',
29   - body: {
30   - ...params,
31   - method: 'post',
32   - },
33   - });
34   -}
35   -
36   -export async function updateRule(params) {
37   - return request('/api/rule', {
38   - method: 'POST',
39   - body: {
40   - ...params,
41   - method: 'update',
42   - },
43   - });
44   -}
45   -
46   -export async function fakeSubmitForm(params) {
47   - return request('/api/forms', {
48   - method: 'POST',
49   - body: params,
50   - });
51   -}
52   -
53   -export async function fakeChartData() {
54   - return request('/api/fake_chart_data');
55   -}
56   -
57   -export async function queryTags() {
58   - return request('/api/tags');
59   -}
60   -
61   -export async function queryBasicProfile() {
62   - return request('/api/profile/basic');
63   -}
64   -
65   -export async function queryAdvancedProfile() {
66   - return request('/api/profile/advanced');
67   -}
68   -
69   -export async function queryFakeList(params) {
70   - return request(`/api/fake_list?${stringify(params)}`);
71   -}
72   -
73   -export async function removeFakeList(params) {
74   - const { count = 5, ...restParams } = params;
75   - return request(`/api/fake_list?count=${count}`, {
76   - method: 'POST',
77   - body: {
78   - ...restParams,
79   - method: 'delete',
80   - },
81   - });
82   -}
83   -
84   -export async function addFakeList(params) {
85   - const { count = 5, ...restParams } = params;
86   - return request(`/api/fake_list?count=${count}`, {
87   - method: 'POST',
88   - body: {
89   - ...restParams,
90   - method: 'post',
91   - },
92   - });
93   -}
94   -
95   -export async function updateFakeList(params) {
96   - const { count = 5, ...restParams } = params;
97   - return request(`/api/fake_list?count=${count}`, {
98   - method: 'POST',
99   - body: {
100   - ...restParams,
101   - method: 'update',
102   - },
103   - });
104   -}
105   -
106   -export async function fakeAccountLogin(params) {
107   - return request('/api/login/account', {
108   - method: 'POST',
109   - body: params,
110   - });
111   -}
112   -
113   -export async function fakeRegister(params) {
114   - return request('/api/register', {
115   - method: 'POST',
116   - body: params,
117   - });
118   -}
119   -
120   -export async function queryNotices() {
121   - return request('/api/notices');
122   -}
123   -
124   -export async function getFakeCaptcha(mobile) {
125   - return request(`/api/captcha?mobile=${mobile}`);
126   -}
1   -import fetch from 'dva/fetch';
2   -import { notification } from 'antd';
3   -import router from 'umi/router';
4   -import hash from 'hash.js';
5   -import { isAntdPro } from './utils';
6   -
7   -const codeMessage = {
8   - 200: '服务器成功返回请求的数据。',
9   - 201: '新建或修改数据成功。',
10   - 202: '一个请求已经进入后台排队(异步任务)。',
11   - 204: '删除数据成功。',
12   - 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
13   - 401: '用户没有权限(令牌、用户名、密码错误)。',
14   - 403: '用户得到授权,但是访问是被禁止的。',
15   - 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
16   - 406: '请求的格式不可得。',
17   - 410: '请求的资源被永久删除,且不会再得到的。',
18   - 422: '当创建一个对象时,发生一个验证错误。',
19   - 500: '服务器发生错误,请检查服务器。',
20   - 502: '网关错误。',
21   - 503: '服务不可用,服务器暂时过载或维护。',
22   - 504: '网关超时。',
23   -};
24   -
25   -const checkStatus = response => {
26   - if (response.status >= 200 && response.status < 300) {
27   - return response;
28   - }
29   - const errortext = codeMessage[response.status] || response.statusText;
30   - notification.error({
31   - message: `请求错误 ${response.status}: ${response.url}`,
32   - description: errortext,
33   - });
34   - const error = new Error(errortext);
35   - error.name = response.status;
36   - error.response = response;
37   - throw error;
38   -};
39   -
40   -const cachedSave = (response, hashcode) => {
41   - /**
42   - * Clone a response data and store it in sessionStorage
43   - * Does not support data other than json, Cache only json
44   - */
45   - const contentType = response.headers.get('Content-Type');
46   - if (contentType && contentType.match(/application\/json/i)) {
47   - // All data is saved as text
48   - response
49   - .clone()
50   - .text()
51   - .then(content => {
52   - sessionStorage.setItem(hashcode, content);
53   - sessionStorage.setItem(`${hashcode}:timestamp`, Date.now());
54   - });
55   - }
56   - return response;
57   -};
58   -
59   -/**
60   - * Requests a URL, returning a promise.
61   - *
62   - * @param {string} url The URL we want to request
63   - * @param {object} [option] The options we want to pass to "fetch"
64   - * @return {object} An object containing either "data" or "err"
65   - */
66   -export default function request(url, option) {
67   - const options = {
68   - expirys: isAntdPro(),
69   - ...option,
70   - };
71   - /**
72   - * Produce fingerprints based on url and parameters
73   - * Maybe url has the same parameters
74   - */
75   - const fingerprint = url + (options.body ? JSON.stringify(options.body) : '');
76   - const hashcode = hash
77   - .sha256()
78   - .update(fingerprint)
79   - .digest('hex');
80   -
81   - const defaultOptions = {
82   - credentials: 'include',
83   - };
84   - const newOptions = { ...defaultOptions, ...options };
85   - if (
86   - newOptions.method === 'POST' ||
87   - newOptions.method === 'PUT' ||
88   - newOptions.method === 'DELETE'
89   - ) {
90   - if (!(newOptions.body instanceof FormData)) {
91   - newOptions.headers = {
92   - Accept: 'application/json',
93   - 'Content-Type': 'application/json; charset=utf-8',
94   - ...newOptions.headers,
95   - };
96   - newOptions.body = JSON.stringify(newOptions.body);
97   - } else {
98   - // newOptions.body is FormData
99   - newOptions.headers = {
100   - Accept: 'application/json',
101   - ...newOptions.headers,
102   - };
103   - }
104   - }
105   -
106   - const expirys = options.expirys && 60;
107   - // options.expirys !== false, return the cache,
108   - if (options.expirys !== false) {
109   - const cached = sessionStorage.getItem(hashcode);
110   - const whenCached = sessionStorage.getItem(`${hashcode}:timestamp`);
111   - if (cached !== null && whenCached !== null) {
112   - const age = (Date.now() - whenCached) / 1000;
113   - if (age < expirys) {
114   - const response = new Response(new Blob([cached]));
115   - return response.json();
116   - }
117   - sessionStorage.removeItem(hashcode);
118   - sessionStorage.removeItem(`${hashcode}:timestamp`);
119   - }
120   - }
121   - return fetch(url, newOptions)
122   - .then(checkStatus)
123   - .then(response => cachedSave(response, hashcode))
124   - .then(response => {
125   - // DELETE and 204 do not return data by default
126   - // using .json will report an error.
127   - if (newOptions.method === 'DELETE' || response.status === 204) {
128   - return response.text();
129   - }
130   - return response.json();
131   - })
132   - .catch(e => {
133   - const status = e.name;
134   - if (status === 401) {
135   - // @HACK
136   - /* eslint-disable no-underscore-dangle */
137   - window.g_app._store.dispatch({
138   - type: 'login/logout',
139   - });
140   - return;
141   - }
142   - // environment should not be used
143   - if (status === 403) {
144   - router.push('/exception/403');
145   - return;
146   - }
147   - if (status <= 504 && status >= 500) {
148   - router.push('/exception/500');
149   - return;
150   - }
151   - if (status >= 404 && status < 422) {
152   - router.push('/exception/404');
153   - }
154   - });
155   -}
... ... @@ -16,7 +16,7 @@
16 16 "antd": "^3.10.9",
17 17 "moment": "^2.22.2",
18 18 "nzh": "^1.0.3",
19   - "qs": "^6.6.0",
  19 + "umi-request": "^1.0.0-beta.1",
20 20 "ant-design-pro": "^2.1.1",
21 21 "numeral": "^2.0.6",
22 22 "hash.js": "^1.1.5"
... ...
... ... @@ -2,11 +2,13 @@ import React, { memo } from 'react';
2 2 import { Row, Col, Icon, Tooltip } from 'antd';
3 3 import { FormattedMessage } from 'umi/locale';
4 4 import styles from './Analysis.less';
5   -import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from 'ant-design-pro/lib/Charts';
6   -import Trend from 'ant-design-pro/lib/Trend';
  5 +import { Charts } from 'ant-design-pro';
  6 +import { Trend } from 'ant-design-pro';
7 7 import numeral from 'numeral';
8 8 import Yuan from '@/utils/Yuan';
9 9
  10 +const { ChartCard, MiniArea, MiniBar, MiniProgress, Field } = Charts;
  11 +
10 12 const topColResponsiveProps = {
11 13 xs: 24,
12 14 sm: 12,
... ...
1 1 import React, { memo } from 'react';
2 2 import { Card, Tabs, Row, Col } from 'antd';
3 3 import { formatMessage, FormattedMessage } from 'umi/locale';
4   -import { TimelineChart, Pie } from 'ant-design-pro/lib/Charts';
5   -import NumberInfo from 'ant-design-pro/lib/NumberInfo';
  4 +import { Charts } from 'ant-design-pro';
  5 +import { NumberInfo } from 'ant-design-pro';
6 6 import styles from './Analysis.less';
7 7
  8 +const { TimelineChart, Pie } = Charts;
  9 +
8 10 const CustomTab = ({ data, currentTabKey: currentKey }) => (
9 11 <Row gutter={8} style={{ width: 138, margin: '8px 0' }}>
10 12 <Col span={12}>
... ...
... ... @@ -2,9 +2,11 @@ import React, { memo } from 'react';
2 2 import { Card, Radio } from 'antd';
3 3 import { FormattedMessage } from 'umi/locale';
4 4 import styles from './Analysis.less';
5   -import { Pie } from 'ant-design-pro/lib/Charts';
  5 +import { Charts } from 'ant-design-pro';
6 6 import Yuan from '@/utils/Yuan';
7 7
  8 +const { Pie } = Charts;
  9 +
8 10 const ProportionSales = memo(
9 11 ({ dropdownGroup, salesType, loading, salesPieData, handleChangeSalesType }) => (
10 12 <Card
... ...
... ... @@ -2,9 +2,11 @@ import React, { memo } from 'react';
2 2 import { Row, Col, Card, Tabs, DatePicker } from 'antd';
3 3 import { FormattedMessage, formatMessage } from 'umi/locale';
4 4 import numeral from 'numeral';
5   -import { Bar } from 'ant-design-pro/lib/Charts';
  5 +import { Charts } from 'ant-design-pro';
6 6 import styles from './Analysis.less';
7 7
  8 +const { Bar } = Charts;
  9 +
8 10 const { RangePicker } = DatePicker;
9 11 const { TabPane } = Tabs;
10 12
... ...
1 1 import React, { memo } from 'react';
2 2 import { Row, Col, Table, Tooltip, Card, Icon } from 'antd';
3 3 import { FormattedMessage } from 'umi/locale';
4   -import Trend from 'ant-design-pro/lib/Trend';
  4 +import { Trend, NumberInfo, Charts } from 'ant-design-pro';
5 5 import numeral from 'numeral';
6   -import NumberInfo from 'ant-design-pro/lib/NumberInfo';
7   -import { MiniArea } from 'ant-design-pro/lib/Charts';
8 6 import styles from './Analysis.less';
9 7
  8 +const { MiniArea } = Charts;
  9 +
10 10 const columns = [
11 11 {
12 12 title: <FormattedMessage id="app.analysis.table.rank" defaultMessage="Rank" />,
... ...
1   -module.exports = {
2   - navTheme: 'dark', // theme for nav menu
3   - primaryColor: '#1890FF', // primary color of ant design
4   - layout: 'sidemenu', // nav menu position: sidemenu or topmenu
5   - contentWidth: 'Fluid', // layout of content: Fluid or Fixed, only works when layout is topmenu
6   - fixedHeader: false, // sticky header
7   - autoHideHeader: false, // auto hide header
8   - fixSiderbar: false, // sticky siderbar
9   -};
... ... @@ -2,7 +2,6 @@ import React, { Component, Suspense } from 'react';
2 2 import { connect } from 'dva';
3 3 import { Row, Col, Icon, Menu, Dropdown } from 'antd';
4 4
5   -import GridContent from '@/components/PageHeaderWrapper/GridContent';
6 5 import { getTimeDistance } from '@/utils/utils';
7 6
8 7 import styles from './Analysis.less';
... ... @@ -130,7 +129,7 @@ class Analysis extends Component {
130 129 const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name);
131 130
132 131 return (
133   - <GridContent>
  132 + <React.Fragment>
134 133 <Suspense fallback={<PageLoading />}>
135 134 <IntroduceRow loading={loading} visitData={visitData} />
136 135 </Suspense>
... ... @@ -177,7 +176,7 @@ class Analysis extends Component {
177 176 handleTabChange={this.handleTabChange}
178 177 />
179 178 </Suspense>
180   - </GridContent>
  179 + </React.Fragment>
181 180 );
182 181 }
183 182 }
... ...
  1 +export default {
  2 + 'app.analysis.test': 'Gongzhuan No.{no} shop',
  3 + 'app.analysis.introduce': 'Introduce',
  4 + 'app.analysis.total-sales': 'Total Sales',
  5 + 'app.analysis.day-sales': 'Daily Sales',
  6 + 'app.analysis.visits': 'Visits',
  7 + 'app.analysis.visits-trend': 'Visits Trend',
  8 + 'app.analysis.visits-ranking': 'Visits Ranking',
  9 + 'app.analysis.day-visits': 'Daily Visits',
  10 + 'app.analysis.week': 'WoW Change',
  11 + 'app.analysis.day': 'DoD Change',
  12 + 'app.analysis.payments': 'Payments',
  13 + 'app.analysis.conversion-rate': 'Conversion Rate',
  14 + 'app.analysis.operational-effect': 'Operational Effect',
  15 + 'app.analysis.sales-trend': 'Stores Sales Trend',
  16 + 'app.analysis.sales-ranking': 'Sales Ranking',
  17 + 'app.analysis.all-year': 'All Year',
  18 + 'app.analysis.all-month': 'All Month',
  19 + 'app.analysis.all-week': 'All Week',
  20 + 'app.analysis.all-day': 'All day',
  21 + 'app.analysis.search-users': 'Search Users',
  22 + 'app.analysis.per-capita-search': 'Per Capita Search',
  23 + 'app.analysis.online-top-search': 'Online Top Search',
  24 + 'app.analysis.the-proportion-of-sales': 'The Proportion Of Sales',
  25 + 'app.analysis.channel.all': 'ALL',
  26 + 'app.analysis.channel.online': 'Online',
  27 + 'app.analysis.channel.stores': 'Stores',
  28 + 'app.analysis.sales': 'Sales',
  29 + 'app.analysis.traffic': 'Traffic',
  30 + 'app.analysis.table.rank': 'Rank',
  31 + 'app.analysis.table.search-keyword': 'Keyword',
  32 + 'app.analysis.table.users': 'Users',
  33 + 'app.analysis.table.weekly-range': 'Weekly Range',
  34 +};
... ...
  1 +export default {
  2 + 'app.analysis.test': 'Gongzhuan No.{no} shop',
  3 + 'app.analysis.introduce': 'Introduzir',
  4 + 'app.analysis.total-sales': 'Vendas Totais',
  5 + 'app.analysis.day-sales': 'Vendas do Dia',
  6 + 'app.analysis.visits': 'Visitas',
  7 + 'app.analysis.visits-trend': 'Tendência de Visitas',
  8 + 'app.analysis.visits-ranking': 'Ranking de Visitas',
  9 + 'app.analysis.day-visits': 'Visitas do Dia',
  10 + 'app.analysis.week': 'Taxa Semanal',
  11 + 'app.analysis.day': 'Taxa Diária',
  12 + 'app.analysis.payments': 'Pagamentos',
  13 + 'app.analysis.conversion-rate': 'Taxa de Conversão',
  14 + 'app.analysis.operational-effect': 'Efeito Operacional',
  15 + 'app.analysis.sales-trend': 'Tendência de Vendas das Lojas',
  16 + 'app.analysis.sales-ranking': 'Ranking de Vendas',
  17 + 'app.analysis.all-year': 'Todo ano',
  18 + 'app.analysis.all-month': 'Todo mês',
  19 + 'app.analysis.all-week': 'Toda semana',
  20 + 'app.analysis.all-day': 'Todo dia',
  21 + 'app.analysis.search-users': 'Pesquisa de Usuários',
  22 + 'app.analysis.per-capita-search': 'Busca Per Capta',
  23 + 'app.analysis.online-top-search': 'Mais Buscadas Online',
  24 + 'app.analysis.the-proportion-of-sales': 'The Proportion Of Sales',
  25 + 'app.analysis.channel.all': 'Tudo',
  26 + 'app.analysis.channel.online': 'Online',
  27 + 'app.analysis.channel.stores': 'Lojas',
  28 + 'app.analysis.sales': 'Vendas',
  29 + 'app.analysis.traffic': 'Tráfego',
  30 + 'app.analysis.table.rank': 'Rank',
  31 + 'app.analysis.table.search-keyword': 'Palavra chave',
  32 + 'app.analysis.table.users': 'Usuários',
  33 + 'app.analysis.table.weekly-range': 'Faixa Semanal',
  34 +};
... ...
  1 +export default {
  2 + 'app.analysis.test': '工专路 {no} 号店',
  3 + 'app.analysis.introduce': '指标说明',
  4 + 'app.analysis.total-sales': '总销售额',
  5 + 'app.analysis.day-sales': '日销售额',
  6 + 'app.analysis.visits': '访问量',
  7 + 'app.analysis.visits-trend': '访问量趋势',
  8 + 'app.analysis.visits-ranking': '门店访问量排名',
  9 + 'app.analysis.day-visits': '日访问量',
  10 + 'app.analysis.week': '周同比',
  11 + 'app.analysis.day': '日同比',
  12 + 'app.analysis.payments': '支付笔数',
  13 + 'app.analysis.conversion-rate': '转化率',
  14 + 'app.analysis.operational-effect': '运营活动效果',
  15 + 'app.analysis.sales-trend': '销售趋势',
  16 + 'app.analysis.sales-ranking': '门店销售额排名',
  17 + 'app.analysis.all-year': '全年',
  18 + 'app.analysis.all-month': '本月',
  19 + 'app.analysis.all-week': '本周',
  20 + 'app.analysis.all-day': '今日',
  21 + 'app.analysis.search-users': '搜索用户数',
  22 + 'app.analysis.per-capita-search': '人均搜索次数',
  23 + 'app.analysis.online-top-search': '线上热门搜索',
  24 + 'app.analysis.the-proportion-of-sales': '销售额类别占比',
  25 + 'app.analysis.channel.all': '全部渠道',
  26 + 'app.analysis.channel.online': '线上',
  27 + 'app.analysis.channel.stores': '门店',
  28 + 'app.analysis.sales': '销售额',
  29 + 'app.analysis.traffic': '客流量',
  30 + 'app.analysis.table.rank': '排名',
  31 + 'app.analysis.table.search-keyword': '搜索关键词',
  32 + 'app.analysis.table.users': '用户数',
  33 + 'app.analysis.table.weekly-range': '周涨幅',
  34 +};
... ...
  1 +export default {
  2 + 'app.analysis.test': '工專路 {no} 號店',
  3 + 'app.analysis.introduce': '指標說明',
  4 + 'app.analysis.total-sales': '總銷售額',
  5 + 'app.analysis.day-sales': '日銷售額',
  6 + 'app.analysis.visits': '訪問量',
  7 + 'app.analysis.visits-trend': '訪問量趨勢',
  8 + 'app.analysis.visits-ranking': '門店訪問量排名',
  9 + 'app.analysis.day-visits': '日訪問量',
  10 + 'app.analysis.week': '周同比',
  11 + 'app.analysis.day': '日同比',
  12 + 'app.analysis.payments': '支付筆數',
  13 + 'app.analysis.conversion-rate': '轉化率',
  14 + 'app.analysis.operational-effect': '運營活動效果',
  15 + 'app.analysis.sales-trend': '銷售趨勢',
  16 + 'app.analysis.sales-ranking': '門店銷售額排名',
  17 + 'app.analysis.all-year': '全年',
  18 + 'app.analysis.all-month': '本月',
  19 + 'app.analysis.all-week': '本周',
  20 + 'app.analysis.all-day': '今日',
  21 + 'app.analysis.search-users': '搜索用戶數',
  22 + 'app.analysis.per-capita-search': '人均搜索次數',
  23 + 'app.analysis.online-top-search': '線上熱門搜索',
  24 + 'app.analysis.the-proportion-of-sales': '銷售額類別占比',
  25 + 'app.analysis.channel.all': '全部渠道',
  26 + 'app.analysis.channel.online': '線上',
  27 + 'app.analysis.channel.stores': '門店',
  28 + 'app.analysis.sales': '銷售額',
  29 + 'app.analysis.traffic': '客流量',
  30 + 'app.analysis.table.rank': '排名',
  31 + 'app.analysis.table.search-keyword': '搜索關鍵詞',
  32 + 'app.analysis.table.users': '用戶數',
  33 + 'app.analysis.table.weekly-range': '周漲幅',
  34 +};
... ...
1   -import { fakeChartData } from '@/services/api';
  1 +import { fakeChartData } from '../service';
2 2
3 3 export default {
4 4 namespace: 'chart',
... ...
1   -import { message } from 'antd';
2   -import defaultSettings from '../defaultSettings';
3   -
4   -let lessNodesAppended;
5   -const updateTheme = primaryColor => {
6   - // Don't compile less in production!
7   - if (APP_TYPE !== 'site') {
8   - return;
9   - }
10   - // Determine if the component is remounted
11   - if (!primaryColor) {
12   - return;
13   - }
14   - const hideMessage = message.loading('正在编译主题!', 0);
15   - function buildIt() {
16   - if (!window.less) {
17   - return;
18   - }
19   - setTimeout(() => {
20   - window.less
21   - .modifyVars({
22   - '@primary-color': primaryColor,
23   - })
24   - .then(() => {
25   - hideMessage();
26   - })
27   - .catch(() => {
28   - message.error('Failed to update theme');
29   - hideMessage();
30   - });
31   - }, 200);
32   - }
33   - if (!lessNodesAppended) {
34   - // insert less.js and color.less
35   - const lessStyleNode = document.createElement('link');
36   - const lessConfigNode = document.createElement('script');
37   - const lessScriptNode = document.createElement('script');
38   - lessStyleNode.setAttribute('rel', 'stylesheet/less');
39   - lessStyleNode.setAttribute('href', '/color.less');
40   - lessConfigNode.innerHTML = `
41   - window.less = {
42   - async: true,
43   - env: 'production',
44   - javascriptEnabled: true
45   - };
46   - `;
47   - lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js';
48   - lessScriptNode.async = true;
49   - lessScriptNode.onload = () => {
50   - buildIt();
51   - lessScriptNode.onload = null;
52   - };
53   - document.body.appendChild(lessStyleNode);
54   - document.body.appendChild(lessConfigNode);
55   - document.body.appendChild(lessScriptNode);
56   - lessNodesAppended = true;
57   - } else {
58   - buildIt();
59   - }
60   -};
61   -
62   -const updateColorWeak = colorWeak => {
63   - document.body.className = colorWeak ? 'colorWeak' : '';
64   -};
65   -
66   -export default {
67   - namespace: 'setting',
68   - state: defaultSettings,
69   - reducers: {
70   - getSetting(state) {
71   - const setting = {};
72   - const urlParams = new URL(window.location.href);
73   - Object.keys(state).forEach(key => {
74   - if (urlParams.searchParams.has(key)) {
75   - const value = urlParams.searchParams.get(key);
76   - setting[key] = value === '1' ? true : value;
77   - }
78   - });
79   - const { primaryColor, colorWeak } = setting;
80   - if (state.primaryColor !== primaryColor) {
81   - updateTheme(primaryColor);
82   - }
83   - updateColorWeak(colorWeak);
84   - return {
85   - ...state,
86   - ...setting,
87   - };
88   - },
89   - changeSetting(state, { payload }) {
90   - const urlParams = new URL(window.location.href);
91   - Object.keys(defaultSettings).forEach(key => {
92   - if (urlParams.searchParams.has(key)) {
93   - urlParams.searchParams.delete(key);
94   - }
95   - });
96   - Object.keys(payload).forEach(key => {
97   - if (key === 'collapse') {
98   - return;
99   - }
100   - let value = payload[key];
101   - if (value === true) {
102   - value = 1;
103   - }
104   - if (defaultSettings[key] !== value) {
105   - urlParams.searchParams.set(key, value);
106   - }
107   - });
108   - const { primaryColor, colorWeak, contentWidth } = payload;
109   - if (state.primaryColor !== primaryColor) {
110   - updateTheme(primaryColor);
111   - }
112   - if (state.contentWidth !== contentWidth && window.dispatchEvent) {
113   - window.dispatchEvent(new Event('resize'));
114   - }
115   - updateColorWeak(colorWeak);
116   - window.history.replaceState(null, 'setting', urlParams.href);
117   - return {
118   - ...state,
119   - ...payload,
120   - };
121   - },
122   - },
123   -};
  1 +import request from 'umi-request';
  2 +
  3 +export async function fakeChartData() {
  4 + return request('/api/fake_chart_data');
  5 +}
... ...
注册登录 后发表评论