正在显示
16 个修改的文件
包含
156 行增加
和
1125 行删除
| 1 | export default { | 1 | export default { |
| 2 | plugins: [ | 2 | plugins: [ |
| 3 | - ['umi-plugin-block-dev', {}], | ||
| 4 | - ['umi-plugin-react', { | ||
| 5 | - dva: true, | ||
| 6 | - locale: true, | ||
| 7 | - antd: true, | ||
| 8 | - }] | 3 | + ['umi-plugin-block-dev', { layout: 'ant-design-pro' }], |
| 4 | + [ | ||
| 5 | + 'umi-plugin-react', | ||
| 6 | + { | ||
| 7 | + dva: true, | ||
| 8 | + locale: true, | ||
| 9 | + antd: true, | ||
| 10 | + }, | ||
| 11 | + ], | ||
| 9 | ], | 12 | ], |
| 10 | -} | 13 | +}; |
| 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 | -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 | -} |
| 1 | -import moment from 'moment'; | ||
| 2 | -import React from 'react'; | ||
| 3 | -import nzh from 'nzh/cn'; | ||
| 4 | -import { parse, stringify } from 'qs'; | ||
| 5 | - | ||
| 6 | -export function fixedZero(val) { | ||
| 7 | - return val * 1 < 10 ? `0${val}` : val; | ||
| 8 | -} | ||
| 9 | - | ||
| 10 | -export function getTimeDistance(type) { | ||
| 11 | - const now = new Date(); | ||
| 12 | - const oneDay = 1000 * 60 * 60 * 24; | ||
| 13 | - | ||
| 14 | - if (type === 'today') { | ||
| 15 | - now.setHours(0); | ||
| 16 | - now.setMinutes(0); | ||
| 17 | - now.setSeconds(0); | ||
| 18 | - return [moment(now), moment(now.getTime() + (oneDay - 1000))]; | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - if (type === 'week') { | ||
| 22 | - let day = now.getDay(); | ||
| 23 | - now.setHours(0); | ||
| 24 | - now.setMinutes(0); | ||
| 25 | - now.setSeconds(0); | ||
| 26 | - | ||
| 27 | - if (day === 0) { | ||
| 28 | - day = 6; | ||
| 29 | - } else { | ||
| 30 | - day -= 1; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - const beginTime = now.getTime() - day * oneDay; | ||
| 34 | - | ||
| 35 | - return [moment(beginTime), moment(beginTime + (7 * oneDay - 1000))]; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - if (type === 'month') { | ||
| 39 | - const year = now.getFullYear(); | ||
| 40 | - const month = now.getMonth(); | ||
| 41 | - const nextDate = moment(now).add(1, 'months'); | ||
| 42 | - const nextYear = nextDate.year(); | ||
| 43 | - const nextMonth = nextDate.month(); | ||
| 44 | - | ||
| 45 | - return [ | ||
| 46 | - moment(`${year}-${fixedZero(month + 1)}-01 00:00:00`), | ||
| 47 | - moment(moment(`${nextYear}-${fixedZero(nextMonth + 1)}-01 00:00:00`).valueOf() - 1000), | ||
| 48 | - ]; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - const year = now.getFullYear(); | ||
| 52 | - return [moment(`${year}-01-01 00:00:00`), moment(`${year}-12-31 23:59:59`)]; | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -export function getPlainNode(nodeList, parentPath = '') { | ||
| 56 | - const arr = []; | ||
| 57 | - nodeList.forEach(node => { | ||
| 58 | - const item = node; | ||
| 59 | - item.path = `${parentPath}/${item.path || ''}`.replace(/\/+/g, '/'); | ||
| 60 | - item.exact = true; | ||
| 61 | - if (item.children && !item.component) { | ||
| 62 | - arr.push(...getPlainNode(item.children, item.path)); | ||
| 63 | - } else { | ||
| 64 | - if (item.children && item.component) { | ||
| 65 | - item.exact = false; | ||
| 66 | - } | ||
| 67 | - arr.push(item); | ||
| 68 | - } | ||
| 69 | - }); | ||
| 70 | - return arr; | ||
| 71 | -} | ||
| 72 | - | ||
| 73 | -export function digitUppercase(n) { | ||
| 74 | - return nzh.toMoney(n); | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -function getRelation(str1, str2) { | ||
| 78 | - if (str1 === str2) { | ||
| 79 | - console.warn('Two path are equal!'); // eslint-disable-line | ||
| 80 | - } | ||
| 81 | - const arr1 = str1.split('/'); | ||
| 82 | - const arr2 = str2.split('/'); | ||
| 83 | - if (arr2.every((item, index) => item === arr1[index])) { | ||
| 84 | - return 1; | ||
| 85 | - } | ||
| 86 | - if (arr1.every((item, index) => item === arr2[index])) { | ||
| 87 | - return 2; | ||
| 88 | - } | ||
| 89 | - return 3; | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -function getRenderArr(routes) { | ||
| 93 | - let renderArr = []; | ||
| 94 | - renderArr.push(routes[0]); | ||
| 95 | - for (let i = 1; i < routes.length; i += 1) { | ||
| 96 | - // 去重 | ||
| 97 | - renderArr = renderArr.filter(item => getRelation(item, routes[i]) !== 1); | ||
| 98 | - // 是否包含 | ||
| 99 | - const isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3); | ||
| 100 | - if (isAdd) { | ||
| 101 | - renderArr.push(routes[i]); | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | - return renderArr; | ||
| 105 | -} | ||
| 106 | - | ||
| 107 | -/** | ||
| 108 | - * Get router routing configuration | ||
| 109 | - * { path:{name,...param}}=>Array<{name,path ...param}> | ||
| 110 | - * @param {string} path | ||
| 111 | - * @param {routerData} routerData | ||
| 112 | - */ | ||
| 113 | -export function getRoutes(path, routerData) { | ||
| 114 | - let routes = Object.keys(routerData).filter( | ||
| 115 | - routePath => routePath.indexOf(path) === 0 && routePath !== path | ||
| 116 | - ); | ||
| 117 | - // Replace path to '' eg. path='user' /user/name => name | ||
| 118 | - routes = routes.map(item => item.replace(path, '')); | ||
| 119 | - // Get the route to be rendered to remove the deep rendering | ||
| 120 | - const renderArr = getRenderArr(routes); | ||
| 121 | - // Conversion and stitching parameters | ||
| 122 | - const renderRoutes = renderArr.map(item => { | ||
| 123 | - const exact = !routes.some(route => route !== item && getRelation(route, item) === 1); | ||
| 124 | - return { | ||
| 125 | - exact, | ||
| 126 | - ...routerData[`${path}${item}`], | ||
| 127 | - key: `${path}${item}`, | ||
| 128 | - path: `${path}${item}`, | ||
| 129 | - }; | ||
| 130 | - }); | ||
| 131 | - return renderRoutes; | ||
| 132 | -} | ||
| 133 | - | ||
| 134 | -export function getPageQuery() { | ||
| 135 | - return parse(window.location.href.split('?')[1]); | ||
| 136 | -} | ||
| 137 | - | ||
| 138 | -export function getQueryPath(path = '', query = {}) { | ||
| 139 | - const search = stringify(query); | ||
| 140 | - if (search.length) { | ||
| 141 | - return `${path}?${search}`; | ||
| 142 | - } | ||
| 143 | - return path; | ||
| 144 | -} | ||
| 145 | - | ||
| 146 | -/* eslint no-useless-escape:0 */ | ||
| 147 | -const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | ||
| 148 | - | ||
| 149 | -export function isUrl(path) { | ||
| 150 | - return reg.test(path); | ||
| 151 | -} | ||
| 152 | - | ||
| 153 | -export function formatWan(val) { | ||
| 154 | - const v = val * 1; | ||
| 155 | - if (!v || Number.isNaN(v)) return ''; | ||
| 156 | - | ||
| 157 | - let result = val; | ||
| 158 | - if (val > 10000) { | ||
| 159 | - result = Math.floor(val / 10000); | ||
| 160 | - result = ( | ||
| 161 | - <span> | ||
| 162 | - {result} | ||
| 163 | - <span | ||
| 164 | - style={{ | ||
| 165 | - position: 'relative', | ||
| 166 | - top: -2, | ||
| 167 | - fontSize: 14, | ||
| 168 | - fontStyle: 'normal', | ||
| 169 | - marginLeft: 2, | ||
| 170 | - }} | ||
| 171 | - > | ||
| 172 | - 万 | ||
| 173 | - </span> | ||
| 174 | - </span> | ||
| 175 | - ); | ||
| 176 | - } | ||
| 177 | - return result; | ||
| 178 | -} | ||
| 179 | - | ||
| 180 | -// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 | ||
| 181 | -export function isAntdPro() { | ||
| 182 | - return window.location.hostname === 'preview.pro.ant.design'; | ||
| 183 | -} |
| 1 | -.textOverflow() { | ||
| 2 | - overflow: hidden; | ||
| 3 | - text-overflow: ellipsis; | ||
| 4 | - word-break: break-all; | ||
| 5 | - white-space: nowrap; | ||
| 6 | -} | ||
| 7 | - | ||
| 8 | -.textOverflowMulti(@line: 3, @bg: #fff) { | ||
| 9 | - overflow: hidden; | ||
| 10 | - position: relative; | ||
| 11 | - line-height: 1.5em; | ||
| 12 | - max-height: @line * 1.5em; | ||
| 13 | - text-align: justify; | ||
| 14 | - margin-right: -1em; | ||
| 15 | - padding-right: 1em; | ||
| 16 | - &:before { | ||
| 17 | - background: @bg; | ||
| 18 | - content: '...'; | ||
| 19 | - padding: 0 1px; | ||
| 20 | - position: absolute; | ||
| 21 | - right: 14px; | ||
| 22 | - bottom: 0; | ||
| 23 | - } | ||
| 24 | - &:after { | ||
| 25 | - background: white; | ||
| 26 | - content: ''; | ||
| 27 | - margin-top: 0.2em; | ||
| 28 | - position: absolute; | ||
| 29 | - right: 14px; | ||
| 30 | - width: 1em; | ||
| 31 | - height: 1em; | ||
| 32 | - } | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | -// mixins for clearfix | ||
| 36 | -// ------------------------ | ||
| 37 | -.clearfix() { | ||
| 38 | - zoom: 1; | ||
| 39 | - &:before, | ||
| 40 | - &:after { | ||
| 41 | - content: ' '; | ||
| 42 | - display: table; | ||
| 43 | - } | ||
| 44 | - &:after { | ||
| 45 | - clear: both; | ||
| 46 | - visibility: hidden; | ||
| 47 | - font-size: 0; | ||
| 48 | - height: 0; | ||
| 49 | - } | ||
| 50 | -} |
| @@ -11,14 +11,15 @@ | @@ -11,14 +11,15 @@ | ||
| 11 | "url": "https://github.com/umijs/umi-blocks/ant-design-pro/accountcenter" | 11 | "url": "https://github.com/umijs/umi-blocks/ant-design-pro/accountcenter" |
| 12 | }, | 12 | }, |
| 13 | "dependencies": { | 13 | "dependencies": { |
| 14 | - "react": "^16.6.3", | ||
| 15 | - "dva": "^2.4.0", | ||
| 16 | "antd": "^3.10.9", | 14 | "antd": "^3.10.9", |
| 17 | - "qs": "^6.6.0", | 15 | + "dva": "^2.4.0", |
| 18 | "hash.js": "^1.1.5", | 16 | "hash.js": "^1.1.5", |
| 17 | + "mockjs": "*", | ||
| 19 | "moment": "^2.22.2", | 18 | "moment": "^2.22.2", |
| 20 | "nzh": "^1.0.3", | 19 | "nzh": "^1.0.3", |
| 21 | - "mockjs": "*" | 20 | + "qs": "^6.6.0", |
| 21 | + "react": "^16.6.3", | ||
| 22 | + "umi-request": "^1.0.0" | ||
| 22 | }, | 23 | }, |
| 23 | "devDependencies": { | 24 | "devDependencies": { |
| 24 | "umi": "^2.3.0-beta.1", | 25 | "umi": "^2.3.0-beta.1", |
| 1 | @import '~antd/lib/style/themes/default.less'; | 1 | @import '~antd/lib/style/themes/default.less'; |
| 2 | -@import '~@/utils/utils.less'; | ||
| 3 | 2 | ||
| 4 | .avatarHolder { | 3 | .avatarHolder { |
| 5 | text-align: center; | 4 | text-align: center; |
| @@ -80,7 +79,10 @@ | @@ -80,7 +79,10 @@ | ||
| 80 | margin-bottom: 24px; | 79 | margin-bottom: 24px; |
| 81 | color: @text-color; | 80 | color: @text-color; |
| 82 | transition: color 0.3s; | 81 | transition: color 0.3s; |
| 83 | - .textOverflow(); | 82 | + overflow: hidden; |
| 83 | + text-overflow: ellipsis; | ||
| 84 | + word-break: break-all; | ||
| 85 | + white-space: nowrap; | ||
| 84 | 86 | ||
| 85 | &:hover { | 87 | &:hover { |
| 86 | color: @primary-color; | 88 | color: @primary-color; |
| 1 | -import mockjs from 'mockjs'; | ||
| 2 | - | ||
| 3 | const titles = [ | 1 | const titles = [ |
| 4 | 'Alipay', | 2 | 'Alipay', |
| 5 | 'Angular', | 3 | 'Angular', |
| @@ -21,138 +19,6 @@ const avatars = [ | @@ -21,138 +19,6 @@ const avatars = [ | ||
| 21 | 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack | 19 | 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack |
| 22 | ]; | 20 | ]; |
| 23 | 21 | ||
| 24 | -const avatars2 = [ | ||
| 25 | - 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', | ||
| 26 | - 'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png', | ||
| 27 | - 'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png', | ||
| 28 | - 'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png', | ||
| 29 | - 'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png', | ||
| 30 | - 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png', | ||
| 31 | - 'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png', | ||
| 32 | - 'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png', | ||
| 33 | - 'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png', | ||
| 34 | - 'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png', | ||
| 35 | -]; | ||
| 36 | - | ||
| 37 | -const covers = [ | ||
| 38 | - 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', | ||
| 39 | - 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', | ||
| 40 | - 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', | ||
| 41 | - 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png', | ||
| 42 | -]; | ||
| 43 | -const desc = [ | ||
| 44 | - '那是一种内在的东西, 他们到达不了,也无法触及的', | ||
| 45 | - '希望是一个好东西,也许是最好的,好东西是不会消亡的', | ||
| 46 | - '生命就像一盒巧克力,结果往往出人意料', | ||
| 47 | - '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', | ||
| 48 | - '那时候我只会想自己想要什么,从不想自己拥有什么', | ||
| 49 | -]; | ||
| 50 | - | ||
| 51 | -const user = [ | ||
| 52 | - '付小小', | ||
| 53 | - '曲丽丽', | ||
| 54 | - '林东东', | ||
| 55 | - '周星星', | ||
| 56 | - '吴加好', | ||
| 57 | - '朱偏右', | ||
| 58 | - '鱼酱', | ||
| 59 | - '乐哥', | ||
| 60 | - '谭小仪', | ||
| 61 | - '仲尼', | ||
| 62 | -]; | ||
| 63 | - | ||
| 64 | -function fakeList(count) { | ||
| 65 | - const list = []; | ||
| 66 | - for (let i = 0; i < count; i += 1) { | ||
| 67 | - list.push({ | ||
| 68 | - id: `fake-list-${i}`, | ||
| 69 | - owner: user[i % 10], | ||
| 70 | - title: titles[i % 8], | ||
| 71 | - avatar: avatars[i % 8], | ||
| 72 | - cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)], | ||
| 73 | - status: ['active', 'exception', 'normal'][i % 3], | ||
| 74 | - percent: Math.ceil(Math.random() * 50) + 50, | ||
| 75 | - logo: avatars[i % 8], | ||
| 76 | - href: 'https://ant.design', | ||
| 77 | - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i), | ||
| 78 | - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i), | ||
| 79 | - subDescription: desc[i % 5], | ||
| 80 | - description: | ||
| 81 | - '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', | ||
| 82 | - activeUser: Math.ceil(Math.random() * 100000) + 100000, | ||
| 83 | - newUser: Math.ceil(Math.random() * 1000) + 1000, | ||
| 84 | - star: Math.ceil(Math.random() * 100) + 100, | ||
| 85 | - like: Math.ceil(Math.random() * 100) + 100, | ||
| 86 | - message: Math.ceil(Math.random() * 10) + 10, | ||
| 87 | - content: | ||
| 88 | - '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。', | ||
| 89 | - members: [ | ||
| 90 | - { | ||
| 91 | - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', | ||
| 92 | - name: '曲丽丽', | ||
| 93 | - id: 'member1', | ||
| 94 | - }, | ||
| 95 | - { | ||
| 96 | - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', | ||
| 97 | - name: '王昭君', | ||
| 98 | - id: 'member2', | ||
| 99 | - }, | ||
| 100 | - { | ||
| 101 | - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', | ||
| 102 | - name: '董娜娜', | ||
| 103 | - id: 'member3', | ||
| 104 | - }, | ||
| 105 | - ], | ||
| 106 | - }); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - return list; | ||
| 110 | -} | ||
| 111 | - | ||
| 112 | -let sourceData; | ||
| 113 | - | ||
| 114 | -function getFakeList(req, res) { | ||
| 115 | - const params = req.query; | ||
| 116 | - | ||
| 117 | - const count = params.count * 1 || 20; | ||
| 118 | - | ||
| 119 | - const result = fakeList(count); | ||
| 120 | - sourceData = result; | ||
| 121 | - return res.json(result); | ||
| 122 | -} | ||
| 123 | - | ||
| 124 | -function postFakeList(req, res) { | ||
| 125 | - const { /* url = '', */ body } = req; | ||
| 126 | - // const params = getUrlParams(url); | ||
| 127 | - const { method, id } = body; | ||
| 128 | - // const count = (params.count * 1) || 20; | ||
| 129 | - let result = sourceData; | ||
| 130 | - | ||
| 131 | - switch (method) { | ||
| 132 | - case 'delete': | ||
| 133 | - result = result.filter(item => item.id !== id); | ||
| 134 | - break; | ||
| 135 | - case 'update': | ||
| 136 | - result.forEach((item, i) => { | ||
| 137 | - if (item.id === id) { | ||
| 138 | - result[i] = Object.assign(item, body); | ||
| 139 | - } | ||
| 140 | - }); | ||
| 141 | - break; | ||
| 142 | - case 'post': | ||
| 143 | - result.unshift({ | ||
| 144 | - body, | ||
| 145 | - id: `fake-list-${result.length}`, | ||
| 146 | - createdAt: new Date().getTime(), | ||
| 147 | - }); | ||
| 148 | - break; | ||
| 149 | - default: | ||
| 150 | - break; | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - return res.json(result); | ||
| 154 | -} | ||
| 155 | - | ||
| 156 | const getNotice = [ | 22 | const getNotice = [ |
| 157 | { | 23 | { |
| 158 | id: 'xxx1', | 24 | id: 'xxx1', |
| @@ -216,125 +82,9 @@ const getNotice = [ | @@ -216,125 +82,9 @@ const getNotice = [ | ||
| 216 | }, | 82 | }, |
| 217 | ]; | 83 | ]; |
| 218 | 84 | ||
| 219 | -const getActivities = [ | ||
| 220 | - { | ||
| 221 | - id: 'trend-1', | ||
| 222 | - updatedAt: new Date(), | ||
| 223 | - user: { | ||
| 224 | - name: '曲丽丽', | ||
| 225 | - avatar: avatars2[0], | ||
| 226 | - }, | ||
| 227 | - group: { | ||
| 228 | - name: '高逼格设计天团', | ||
| 229 | - link: 'http://github.com/', | ||
| 230 | - }, | ||
| 231 | - project: { | ||
| 232 | - name: '六月迭代', | ||
| 233 | - link: 'http://github.com/', | ||
| 234 | - }, | ||
| 235 | - template: '在 @{group} 新建项目 @{project}', | ||
| 236 | - }, | ||
| 237 | - { | ||
| 238 | - id: 'trend-2', | ||
| 239 | - updatedAt: new Date(), | ||
| 240 | - user: { | ||
| 241 | - name: '付小小', | ||
| 242 | - avatar: avatars2[1], | ||
| 243 | - }, | ||
| 244 | - group: { | ||
| 245 | - name: '高逼格设计天团', | ||
| 246 | - link: 'http://github.com/', | ||
| 247 | - }, | ||
| 248 | - project: { | ||
| 249 | - name: '六月迭代', | ||
| 250 | - link: 'http://github.com/', | ||
| 251 | - }, | ||
| 252 | - template: '在 @{group} 新建项目 @{project}', | ||
| 253 | - }, | ||
| 254 | - { | ||
| 255 | - id: 'trend-3', | ||
| 256 | - updatedAt: new Date(), | ||
| 257 | - user: { | ||
| 258 | - name: '林东东', | ||
| 259 | - avatar: avatars2[2], | ||
| 260 | - }, | ||
| 261 | - group: { | ||
| 262 | - name: '中二少女团', | ||
| 263 | - link: 'http://github.com/', | ||
| 264 | - }, | ||
| 265 | - project: { | ||
| 266 | - name: '六月迭代', | ||
| 267 | - link: 'http://github.com/', | ||
| 268 | - }, | ||
| 269 | - template: '在 @{group} 新建项目 @{project}', | ||
| 270 | - }, | ||
| 271 | - { | ||
| 272 | - id: 'trend-4', | ||
| 273 | - updatedAt: new Date(), | ||
| 274 | - user: { | ||
| 275 | - name: '周星星', | ||
| 276 | - avatar: avatars2[4], | ||
| 277 | - }, | ||
| 278 | - project: { | ||
| 279 | - name: '5 月日常迭代', | ||
| 280 | - link: 'http://github.com/', | ||
| 281 | - }, | ||
| 282 | - template: '将 @{project} 更新至已发布状态', | ||
| 283 | - }, | ||
| 284 | - { | ||
| 285 | - id: 'trend-5', | ||
| 286 | - updatedAt: new Date(), | ||
| 287 | - user: { | ||
| 288 | - name: '朱偏右', | ||
| 289 | - avatar: avatars2[3], | ||
| 290 | - }, | ||
| 291 | - project: { | ||
| 292 | - name: '工程效能', | ||
| 293 | - link: 'http://github.com/', | ||
| 294 | - }, | ||
| 295 | - comment: { | ||
| 296 | - name: '留言', | ||
| 297 | - link: 'http://github.com/', | ||
| 298 | - }, | ||
| 299 | - template: '在 @{project} 发布了 @{comment}', | ||
| 300 | - }, | ||
| 301 | - { | ||
| 302 | - id: 'trend-6', | ||
| 303 | - updatedAt: new Date(), | ||
| 304 | - user: { | ||
| 305 | - name: '乐哥', | ||
| 306 | - avatar: avatars2[5], | ||
| 307 | - }, | ||
| 308 | - group: { | ||
| 309 | - name: '程序员日常', | ||
| 310 | - link: 'http://github.com/', | ||
| 311 | - }, | ||
| 312 | - project: { | ||
| 313 | - name: '品牌迭代', | ||
| 314 | - link: 'http://github.com/', | ||
| 315 | - }, | ||
| 316 | - template: '在 @{group} 新建项目 @{project}', | ||
| 317 | - }, | ||
| 318 | -]; | ||
| 319 | - | ||
| 320 | -function getFakeCaptcha(req, res) { | ||
| 321 | - return res.json('captcha-xxx'); | ||
| 322 | -} | ||
| 323 | - | ||
| 324 | export default { | 85 | export default { |
| 325 | - 'GET /api/project/notice': getNotice, | ||
| 326 | - 'GET /api/activities': getActivities, | ||
| 327 | - 'POST /api/forms': (req, res) => { | ||
| 328 | - res.send({ message: 'Ok' }); | ||
| 329 | - }, | ||
| 330 | - 'GET /api/tags': mockjs.mock({ | ||
| 331 | - 'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }], | ||
| 332 | - }), | ||
| 333 | - 'GET /api/fake_list': getFakeList, | ||
| 334 | - 'POST /api/fake_list': postFakeList, | ||
| 335 | - 'GET /api/captcha': getFakeCaptcha, | ||
| 336 | - // 支持值为 Object 和 Array | ||
| 337 | - 'GET /api/currentUser': { | 86 | + // 支持值为 Object 和 Array |
| 87 | + 'GET /api/currentUser': { | ||
| 338 | name: 'Serati Ma', | 88 | name: 'Serati Ma', |
| 339 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', | 89 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', |
| 340 | userid: '00000001', | 90 | userid: '00000001', |
| @@ -342,6 +92,7 @@ export default { | @@ -342,6 +92,7 @@ export default { | ||
| 342 | signature: '海纳百川,有容乃大', | 92 | signature: '海纳百川,有容乃大', |
| 343 | title: '交互专家', | 93 | title: '交互专家', |
| 344 | group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED', | 94 | group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED', |
| 95 | + notice: getNotice, | ||
| 345 | tags: [ | 96 | tags: [ |
| 346 | { | 97 | { |
| 347 | key: '0', | 98 | key: '0', |
| 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 | -}; |
| 1 | import React, { PureComponent } from 'react'; | 1 | import React, { PureComponent } from 'react'; |
| 2 | import { connect } from 'dva'; | 2 | import { connect } from 'dva'; |
| 3 | import Link from 'umi/link'; | 3 | import Link from 'umi/link'; |
| 4 | -import router from 'umi/router'; | ||
| 5 | -import { Card, Row, Col, Icon, Avatar, Tag, Divider, Spin, Input } from 'antd'; | ||
| 6 | -import GridContent from '@/components/PageHeaderWrapper/GridContent'; | 4 | +import { Card, Row, Col, Icon, Avatar, Tag, Divider, Input } from 'antd'; |
| 7 | import styles from './Center.less'; | 5 | import styles from './Center.less'; |
| 6 | +// import router from 'umi/router'; | ||
| 8 | 7 | ||
| 9 | -@connect(({ loading, user, project }) => ({ | ||
| 10 | - listLoading: loading.effects['list/fetch'], | 8 | +const operationTabList = [ |
| 9 | + { | ||
| 10 | + key: 'articles', | ||
| 11 | + tab: ( | ||
| 12 | + <span> | ||
| 13 | + 文章 <span style={{ fontSize: 14 }}>(8)</span> | ||
| 14 | + </span> | ||
| 15 | + ), | ||
| 16 | + }, | ||
| 17 | + { | ||
| 18 | + key: 'applications', | ||
| 19 | + tab: ( | ||
| 20 | + <span> | ||
| 21 | + 应用 <span style={{ fontSize: 14 }}>(8)</span> | ||
| 22 | + </span> | ||
| 23 | + ), | ||
| 24 | + }, | ||
| 25 | + { | ||
| 26 | + key: 'projects', | ||
| 27 | + tab: ( | ||
| 28 | + <span> | ||
| 29 | + 项目 <span style={{ fontSize: 14 }}>(8)</span> | ||
| 30 | + </span> | ||
| 31 | + ), | ||
| 32 | + }, | ||
| 33 | +]; | ||
| 34 | + | ||
| 35 | +@connect(({ loading, user }) => ({ | ||
| 11 | currentUser: user.currentUser, | 36 | currentUser: user.currentUser, |
| 12 | currentUserLoading: loading.effects['user/fetchCurrent'], | 37 | currentUserLoading: loading.effects['user/fetchCurrent'], |
| 13 | - project, | ||
| 14 | - projectLoading: loading.effects['project/fetchNotice'], | ||
| 15 | })) | 38 | })) |
| 16 | class Center extends PureComponent { | 39 | class Center extends PureComponent { |
| 40 | + static getDerivedStateFromProps(props, state) { | ||
| 41 | + const { match, location } = props; | ||
| 42 | + const { tabKey } = state; | ||
| 43 | + const urlTabKey = location.pathname.replace(`${match.path}/`, ''); | ||
| 44 | + if (urlTabKey && urlTabKey !== '/' && tabKey !== urlTabKey) { | ||
| 45 | + return { | ||
| 46 | + tabKey: urlTabKey, | ||
| 47 | + }; | ||
| 48 | + } | ||
| 49 | + return null; | ||
| 50 | + } | ||
| 51 | + | ||
| 17 | state = { | 52 | state = { |
| 18 | newTags: [], | 53 | newTags: [], |
| 19 | inputVisible: false, | 54 | inputVisible: false, |
| 20 | inputValue: '', | 55 | inputValue: '', |
| 56 | + tabKey: 'articles', | ||
| 21 | }; | 57 | }; |
| 22 | 58 | ||
| 23 | componentDidMount() { | 59 | componentDidMount() { |
| @@ -25,32 +61,15 @@ class Center extends PureComponent { | @@ -25,32 +61,15 @@ class Center extends PureComponent { | ||
| 25 | dispatch({ | 61 | dispatch({ |
| 26 | type: 'user/fetchCurrent', | 62 | type: 'user/fetchCurrent', |
| 27 | }); | 63 | }); |
| 28 | - dispatch({ | ||
| 29 | - type: 'list/fetch', | ||
| 30 | - payload: { | ||
| 31 | - count: 8, | ||
| 32 | - }, | ||
| 33 | - }); | ||
| 34 | - dispatch({ | ||
| 35 | - type: 'project/fetchNotice', | ||
| 36 | - }); | ||
| 37 | } | 64 | } |
| 38 | 65 | ||
| 39 | onTabChange = key => { | 66 | onTabChange = key => { |
| 40 | - const { match } = this.props; | ||
| 41 | - switch (key) { | ||
| 42 | - case 'articles': | ||
| 43 | - router.push(`${match.url}/articles`); | ||
| 44 | - break; | ||
| 45 | - case 'applications': | ||
| 46 | - router.push(`${match.url}/applications`); | ||
| 47 | - break; | ||
| 48 | - case 'projects': | ||
| 49 | - router.push(`${match.url}/projects`); | ||
| 50 | - break; | ||
| 51 | - default: | ||
| 52 | - break; | ||
| 53 | - } | 67 | + // If you need to sync state to url |
| 68 | + // const { match } = this.props; | ||
| 69 | + // router.push(`${match.url}/${key}`); | ||
| 70 | + this.setState({ | ||
| 71 | + tabKey: key, | ||
| 72 | + }); | ||
| 54 | }; | 73 | }; |
| 55 | 74 | ||
| 56 | showInput = () => { | 75 | showInput = () => { |
| @@ -80,135 +99,92 @@ class Center extends PureComponent { | @@ -80,135 +99,92 @@ class Center extends PureComponent { | ||
| 80 | }; | 99 | }; |
| 81 | 100 | ||
| 82 | render() { | 101 | render() { |
| 83 | - const { newTags, inputVisible, inputValue } = this.state; | ||
| 84 | - const { | ||
| 85 | - listLoading, | ||
| 86 | - currentUser, | ||
| 87 | - currentUserLoading, | ||
| 88 | - project: { notice }, | ||
| 89 | - projectLoading, | ||
| 90 | - match, | ||
| 91 | - location, | ||
| 92 | - children, | ||
| 93 | - } = this.props; | ||
| 94 | - | ||
| 95 | - const operationTabList = [ | ||
| 96 | - { | ||
| 97 | - key: 'articles', | ||
| 98 | - tab: ( | ||
| 99 | - <span> | ||
| 100 | - 文章 <span style={{ fontSize: 14 }}>(8)</span> | ||
| 101 | - </span> | ||
| 102 | - ), | ||
| 103 | - }, | ||
| 104 | - { | ||
| 105 | - key: 'applications', | ||
| 106 | - tab: ( | ||
| 107 | - <span> | ||
| 108 | - 应用 <span style={{ fontSize: 14 }}>(8)</span> | ||
| 109 | - </span> | ||
| 110 | - ), | ||
| 111 | - }, | ||
| 112 | - { | ||
| 113 | - key: 'projects', | ||
| 114 | - tab: ( | ||
| 115 | - <span> | ||
| 116 | - 项目 <span style={{ fontSize: 14 }}>(8)</span> | ||
| 117 | - </span> | ||
| 118 | - ), | ||
| 119 | - }, | ||
| 120 | - ]; | ||
| 121 | - | 102 | + const { newTags, inputVisible, inputValue, tabKey } = this.state; |
| 103 | + const { currentUser, currentUserLoading, children } = this.props; | ||
| 104 | + const dataLoading = currentUserLoading || !(currentUser && Object.keys(currentUser).length); | ||
| 122 | return ( | 105 | return ( |
| 123 | - <GridContent className={styles.userCenter}> | ||
| 124 | - <Row gutter={24}> | ||
| 125 | - <Col lg={7} md={24}> | ||
| 126 | - <Card bordered={false} style={{ marginBottom: 24 }} loading={currentUserLoading}> | ||
| 127 | - {currentUser && Object.keys(currentUser).length ? ( | ||
| 128 | - <div> | ||
| 129 | - <div className={styles.avatarHolder}> | ||
| 130 | - <img alt="" src={currentUser.avatar} /> | ||
| 131 | - <div className={styles.name}>{currentUser.name}</div> | ||
| 132 | - <div>{currentUser.signature}</div> | ||
| 133 | - </div> | ||
| 134 | - <div className={styles.detail}> | ||
| 135 | - <p> | ||
| 136 | - <i className={styles.title} /> | ||
| 137 | - {currentUser.title} | ||
| 138 | - </p> | ||
| 139 | - <p> | ||
| 140 | - <i className={styles.group} /> | ||
| 141 | - {currentUser.group} | ||
| 142 | - </p> | ||
| 143 | - <p> | ||
| 144 | - <i className={styles.address} /> | ||
| 145 | - {currentUser.geographic.province.label} | ||
| 146 | - {currentUser.geographic.city.label} | ||
| 147 | - </p> | ||
| 148 | - </div> | ||
| 149 | - <Divider dashed /> | ||
| 150 | - <div className={styles.tags}> | ||
| 151 | - <div className={styles.tagsTitle}>标签</div> | ||
| 152 | - {currentUser.tags.concat(newTags).map(item => ( | ||
| 153 | - <Tag key={item.key}>{item.label}</Tag> | 106 | + <Row gutter={24}> |
| 107 | + <Col lg={7} md={24}> | ||
| 108 | + <Card bordered={false} style={{ marginBottom: 24 }} loading={dataLoading}> | ||
| 109 | + {!dataLoading ? ( | ||
| 110 | + <div> | ||
| 111 | + <div className={styles.avatarHolder}> | ||
| 112 | + <img alt="" src={currentUser.avatar} /> | ||
| 113 | + <div className={styles.name}>{currentUser.name}</div> | ||
| 114 | + <div>{currentUser.signature}</div> | ||
| 115 | + </div> | ||
| 116 | + <div className={styles.detail}> | ||
| 117 | + <p> | ||
| 118 | + <i className={styles.title} /> | ||
| 119 | + {currentUser.title} | ||
| 120 | + </p> | ||
| 121 | + <p> | ||
| 122 | + <i className={styles.group} /> | ||
| 123 | + {currentUser.group} | ||
| 124 | + </p> | ||
| 125 | + <p> | ||
| 126 | + <i className={styles.address} /> | ||
| 127 | + {currentUser.geographic.province.label} | ||
| 128 | + {currentUser.geographic.city.label} | ||
| 129 | + </p> | ||
| 130 | + </div> | ||
| 131 | + <Divider dashed /> | ||
| 132 | + <div className={styles.tags}> | ||
| 133 | + <div className={styles.tagsTitle}>标签</div> | ||
| 134 | + {currentUser.tags.concat(newTags).map(item => ( | ||
| 135 | + <Tag key={item.key}>{item.label}</Tag> | ||
| 136 | + ))} | ||
| 137 | + {inputVisible && ( | ||
| 138 | + <Input | ||
| 139 | + ref={this.saveInputRef} | ||
| 140 | + type="text" | ||
| 141 | + size="small" | ||
| 142 | + style={{ width: 78 }} | ||
| 143 | + value={inputValue} | ||
| 144 | + onChange={this.handleInputChange} | ||
| 145 | + onBlur={this.handleInputConfirm} | ||
| 146 | + onPressEnter={this.handleInputConfirm} | ||
| 147 | + /> | ||
| 148 | + )} | ||
| 149 | + {!inputVisible && ( | ||
| 150 | + <Tag | ||
| 151 | + onClick={this.showInput} | ||
| 152 | + style={{ background: '#fff', borderStyle: 'dashed' }} | ||
| 153 | + > | ||
| 154 | + <Icon type="plus" /> | ||
| 155 | + </Tag> | ||
| 156 | + )} | ||
| 157 | + </div> | ||
| 158 | + <Divider style={{ marginTop: 16 }} dashed /> | ||
| 159 | + <div className={styles.team}> | ||
| 160 | + <div className={styles.teamTitle}>团队</div> | ||
| 161 | + <Row gutter={36}> | ||
| 162 | + {currentUser.notice.map(item => ( | ||
| 163 | + <Col key={item.id} lg={24} xl={12}> | ||
| 164 | + <Link to={item.href}> | ||
| 165 | + <Avatar size="small" src={item.logo} /> | ||
| 166 | + {item.member} | ||
| 167 | + </Link> | ||
| 168 | + </Col> | ||
| 154 | ))} | 169 | ))} |
| 155 | - {inputVisible && ( | ||
| 156 | - <Input | ||
| 157 | - ref={this.saveInputRef} | ||
| 158 | - type="text" | ||
| 159 | - size="small" | ||
| 160 | - style={{ width: 78 }} | ||
| 161 | - value={inputValue} | ||
| 162 | - onChange={this.handleInputChange} | ||
| 163 | - onBlur={this.handleInputConfirm} | ||
| 164 | - onPressEnter={this.handleInputConfirm} | ||
| 165 | - /> | ||
| 166 | - )} | ||
| 167 | - {!inputVisible && ( | ||
| 168 | - <Tag | ||
| 169 | - onClick={this.showInput} | ||
| 170 | - style={{ background: '#fff', borderStyle: 'dashed' }} | ||
| 171 | - > | ||
| 172 | - <Icon type="plus" /> | ||
| 173 | - </Tag> | ||
| 174 | - )} | ||
| 175 | - </div> | ||
| 176 | - <Divider style={{ marginTop: 16 }} dashed /> | ||
| 177 | - <div className={styles.team}> | ||
| 178 | - <div className={styles.teamTitle}>团队</div> | ||
| 179 | - <Spin spinning={projectLoading}> | ||
| 180 | - <Row gutter={36}> | ||
| 181 | - {notice.map(item => ( | ||
| 182 | - <Col key={item.id} lg={24} xl={12}> | ||
| 183 | - <Link to={item.href}> | ||
| 184 | - <Avatar size="small" src={item.logo} /> | ||
| 185 | - {item.member} | ||
| 186 | - </Link> | ||
| 187 | - </Col> | ||
| 188 | - ))} | ||
| 189 | - </Row> | ||
| 190 | - </Spin> | ||
| 191 | - </div> | 170 | + </Row> |
| 192 | </div> | 171 | </div> |
| 193 | - ) : ( | ||
| 194 | - 'loading...' | ||
| 195 | - )} | ||
| 196 | - </Card> | ||
| 197 | - </Col> | ||
| 198 | - <Col lg={17} md={24}> | ||
| 199 | - <Card | ||
| 200 | - className={styles.tabsCard} | ||
| 201 | - bordered={false} | ||
| 202 | - tabList={operationTabList} | ||
| 203 | - activeTabKey={location.pathname.replace(`${match.path}/`, '')} | ||
| 204 | - onTabChange={this.onTabChange} | ||
| 205 | - loading={listLoading} | ||
| 206 | - > | ||
| 207 | - {children} | ||
| 208 | - </Card> | ||
| 209 | - </Col> | ||
| 210 | - </Row> | ||
| 211 | - </GridContent> | 172 | + </div> |
| 173 | + ) : null} | ||
| 174 | + </Card> | ||
| 175 | + </Col> | ||
| 176 | + <Col lg={17} md={24}> | ||
| 177 | + <Card | ||
| 178 | + className={styles.tabsCard} | ||
| 179 | + bordered={false} | ||
| 180 | + tabList={operationTabList} | ||
| 181 | + activeTabKey={tabKey} | ||
| 182 | + onTabChange={this.onTabChange} | ||
| 183 | + > | ||
| 184 | + {children} | ||
| 185 | + </Card> | ||
| 186 | + </Col> | ||
| 187 | + </Row> | ||
| 212 | ); | 188 | ); |
| 213 | } | 189 | } |
| 214 | } | 190 | } |
| 1 | -import { queryProjectNotice } from '@/services/api'; | ||
| 2 | - | ||
| 3 | -export default { | ||
| 4 | - namespace: 'project', | ||
| 5 | - | ||
| 6 | - state: { | ||
| 7 | - notice: [], | ||
| 8 | - }, | ||
| 9 | - | ||
| 10 | - effects: { | ||
| 11 | - *fetchNotice(_, { call, put }) { | ||
| 12 | - const response = yield call(queryProjectNotice); | ||
| 13 | - yield put({ | ||
| 14 | - type: 'saveNotice', | ||
| 15 | - payload: Array.isArray(response) ? response : [], | ||
| 16 | - }); | ||
| 17 | - }, | ||
| 18 | - }, | ||
| 19 | - | ||
| 20 | - reducers: { | ||
| 21 | - saveNotice(state, action) { | ||
| 22 | - return { | ||
| 23 | - ...state, | ||
| 24 | - notice: action.payload, | ||
| 25 | - }; | ||
| 26 | - }, | ||
| 27 | - }, | ||
| 28 | -}; |
| 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 | -}; |
请
注册
或
登录
后发表评论