|
1 | | -import React, { Component } from 'react' |
| 1 | +import React, { Component } from 'react'; |
2 | 2 |
|
3 | | -import Prompt from 'components/Prompt/Prompt' |
4 | | -//import { browserDetect } from 'utils' |
5 | | -import config from 'config' |
6 | | -import i18n from 'utils/createI18n' |
| 3 | +import Prompt from 'components/Prompt/Prompt'; |
| 4 | +//import { browserDetect } from 'utils'; |
| 5 | +import config from 'config'; |
| 6 | +import i18n from 'utils/createI18n'; |
7 | 7 |
|
8 | 8 | class GlobalPrompt extends Component { |
9 | | - constructor (props) { |
10 | | - super(props) |
11 | | - this.state = { |
12 | | - prompts: [] |
| 9 | + state = { |
| 10 | + prompts: [], |
13 | 11 | } |
14 | | - } |
15 | 12 |
|
16 | | - componentDidMount () { |
17 | | - let id = 0 |
18 | | - //const browserVersion = browserDetect() |
19 | | - const promptMessage = [] |
20 | | - const { prompts } = this.state |
21 | | - |
22 | | - // promptMessage.push({ |
23 | | - // content: ( |
24 | | - // <p> |
25 | | - // Cloud Studio 将于 9 月 6 日 19 点进行系统维护,预计时间为 30 分钟,敬请谅解。 |
26 | | - // </p> |
27 | | - // ), |
28 | | - // id: `global-prompt-${id++}`, |
29 | | - // type: 'update' |
30 | | - // }) |
31 | | - |
32 | | - // if (!localStorage.getItem('visited')) { |
33 | | - // promptMessage.push({ |
34 | | - // content: ( |
35 | | - // <p> |
36 | | - // WebIDE 现已全面升级为 Cloud Studio, 使用旧版 IDE 请点击{' '} |
37 | | - // <a href='https://ide.coding.net' target='_blank' rel='noopener noreferrer'> |
38 | | - // WebIDE |
39 | | - // </a>{' '} |
40 | | - // </p> |
41 | | - // ), |
42 | | - // id: `global-prompt-${id++}`, |
43 | | - // type: 'update' |
44 | | - // }) |
45 | | - // } |
46 | | - |
47 | | - // if (browserVersion !== 'Chrome' && browserVersion !== 'Safari') { |
48 | | - // promptMessage.push({ |
49 | | - // content: ( |
50 | | - // <p> |
51 | | - // 检测到您的浏览器为 {browserVersion},为保障用户体验,推荐使用 Chrome 或 Safari |
52 | | - // 浏览器访问。 |
53 | | - // </p> |
54 | | - // ), |
55 | | - // id: `global-prompt-${id++}`, |
56 | | - // type: 'compatibility' |
57 | | - // }) |
58 | | - // } |
59 | | - if (config.willExpire) { |
60 | | - promptMessage.push({ |
61 | | - content: ( |
62 | | - // <p> |
63 | | - // {i18n`global.machineOutofDateSoon`} |
64 | | - // <span className='important'>{i18n`global.outofDateSoon`}</span> |
65 | | - // {i18n`global.machineOutofDateSoon2`} |
66 | | - // <a href='https://console.cloud.tencent.com/lighthosting' target='_blank' rel='noopener noreferrer'>{i18n`global.renewals`}</a> |
67 | | - // {i18n`global.and`} |
68 | | - // <a href='https://dnspod.cloud.tencent.com/act/coding' target='_blank' rel='noopener noreferrer' >{i18n`global.actHint`}</a> |
69 | | - // </p> |
70 | | - <p> |
71 | | - {i18n`global.offlineInfo`} |
72 | | - <a href='https://studio.dev.tencent.com' rel='noopener noreferrer'>{i18n`global.gotoIDE`}</a> |
73 | | - </p> |
74 | | - ), |
75 | | - id: `global-prompt-${id++}`, |
76 | | - type: 'compatibility' |
77 | | - }) |
| 13 | + render() { |
| 14 | + const { prompts } = this.state; |
| 15 | + return <Prompt prompts={prompts} handleClose={this.handleClosePrompt} /> |
78 | 16 | } |
79 | 17 |
|
80 | | - this.setState({ |
81 | | - prompts: [...prompts, ...promptMessage] |
82 | | - }) |
83 | | - } |
84 | | - |
85 | | - handleClosePrompt = (id, type) => { |
86 | | - const { prompts } = this.state |
87 | | - this.setState({ prompts: prompts.filter(prompt => prompt.id !== id) }) |
88 | | - if (type === 'update') { |
89 | | - localStorage.setItem('visited', true) |
| 18 | + componentDidMount () { |
| 19 | + let id = 0; |
| 20 | + //const browserVersion = browserDetect(); |
| 21 | + const promptMessage = []; |
| 22 | + const { prompts } = this.state; |
| 23 | + promptMessage.push({ |
| 24 | + content: ( |
| 25 | + <p> |
| 26 | + 为提供更好的体验,我们将于 12 月 20 日 24:00 至 12 月 21 日 03:00 之间进行系统维护,请避免在此时间段内使用 Cloud Studio 服务。维护完毕之后,如遇见账户或使用问题,请尝试刷新和重新登录,或前往 <a href="https://feedback.coding.net/" target="blank" rel="noopener">feedback</a> 进行反馈。 |
| 27 | + </p> |
| 28 | + ), |
| 29 | + id: `global-prompt-${id++}`, |
| 30 | + type: 'update', |
| 31 | + }); |
| 32 | + // if (!localStorage.getItem('visited')) { |
| 33 | + // promptMessage.push({ |
| 34 | + // content: ( |
| 35 | + // <p> |
| 36 | + // WebIDE 现已全面升级为 Cloud Studio, 使用旧版 IDE 请点击{' '} |
| 37 | + // <a href='https://ide.coding.net' target='_blank' rel='noopener noreferrer'> |
| 38 | + // WebIDE |
| 39 | + // </a>{' '} |
| 40 | + // </p> |
| 41 | + // ), |
| 42 | + // id: `global-prompt-${id++}`, |
| 43 | + // type: 'update' |
| 44 | + // }) |
| 45 | + // } |
| 46 | + // if (browserVersion !== 'Chrome' && browserVersion !== 'Safari') { |
| 47 | + // promptMessage.push({ |
| 48 | + // content: ( |
| 49 | + // <p> |
| 50 | + // 检测到您的浏览器为 {browserVersion},为保障用户体验,推荐使用 Chrome 或 Safari |
| 51 | + // 浏览器访问。 |
| 52 | + // </p> |
| 53 | + // ), |
| 54 | + // id: `global-prompt-${id++}`, |
| 55 | + // type: 'compatibility' |
| 56 | + // }) |
| 57 | + // } |
| 58 | + if (config.willExpire) { |
| 59 | + promptMessage.push({ |
| 60 | + content: ( |
| 61 | + // <p> |
| 62 | + // {i18n`global.machineOutofDateSoon`} |
| 63 | + // <span className='important'>{i18n`global.outofDateSoon`}</span> |
| 64 | + // {i18n`global.machineOutofDateSoon2`} |
| 65 | + // <a href='https://console.cloud.tencent.com/lighthosting' target='_blank' rel='noopener noreferrer'>{i18n`global.renewals`}</a> |
| 66 | + // {i18n`global.and`} |
| 67 | + // <a href='https://dnspod.cloud.tencent.com/act/coding' target='_blank' rel='noopener noreferrer' >{i18n`global.actHint`}</a> |
| 68 | + // </p> |
| 69 | + <p> |
| 70 | + {i18n`global.offlineInfo`} |
| 71 | + <a href='https://studio.dev.tencent.com' rel='noopener noreferrer'>{i18n`global.gotoIDE`}</a> |
| 72 | + </p> |
| 73 | + ), |
| 74 | + id: `global-prompt-${id++}`, |
| 75 | + type: 'compatibility', |
| 76 | + }); |
| 77 | + } |
| 78 | + this.setState({ |
| 79 | + prompts: [...prompts, ...promptMessage] |
| 80 | + }); |
90 | 81 | } |
91 | | - } |
92 | 82 |
|
93 | | - render () { |
94 | | - const { prompts } = this.state |
95 | | - return <Prompt prompts={prompts} handleClose={this.handleClosePrompt} /> |
96 | | - } |
| 83 | + handleClosePrompt = (id, type) => { |
| 84 | + const { prompts } = this.state; |
| 85 | + this.setState({ prompts: prompts.filter(prompt => prompt.id !== id) }); |
| 86 | + if (type === 'update') { |
| 87 | + localStorage.setItem('visited', true); |
| 88 | + } |
| 89 | + } |
97 | 90 | } |
98 | 91 |
|
99 | | -export default GlobalPrompt |
| 92 | +export default GlobalPrompt; |
0 commit comments