Skip to content

Commit 26d0017

Browse files
author
春秋一语
authored
Merge pull request #10 from Coding/dashboard
Dashboard
2 parents e2638bc + b104d78 commit 26d0017

File tree

19 files changed

+158
-122
lines changed

19 files changed

+158
-122
lines changed

app/changelog.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
<div id="pc-has-not-login" class="right">
523523
<a href="https://cloud.tencent.com/register" target="_blank" rel="noopener noreferrer">注册</a>
524524
<span class="divide">|</span>
525-
<a href="https://dev.tencent.com/login" target="_blank" rel="noopener noreferrer">登录</a>
525+
<a href="https://dev.tencent.com/login?return_url=https://studio.dev.tencent.com/changelog" target="_blank" rel="noopener noreferrer">登录</a>
526526
</div>
527527
<div id="pc-has-login" class="right" style="display: none;">
528528
<div className="title">
@@ -600,7 +600,7 @@
600600
</a>
601601
</div>
602602
<div id="mobile-has-not-login">
603-
<a class="title" href="https://dev.tencent.com/login" target="_blank" rel="noopener noreferrer">登录</a>
603+
<a class="title" href="https://dev.tencent.com/login?return_url=https://studio.dev.tencent.com/changelog" target="_blank" rel="noopener noreferrer">登录</a>
604604
<a class="title" href="https://cloud.tencent.com/register" target="_blank" rel="noopener noreferrer">注册</a>
605605
</div>
606606
<div class="blank"></div>

app/commands/commandBindings/file.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as Modal from '../../components/Modal/actions'
55
import uniqueId from 'lodash/uniqueId'
66
import TabStore from 'components/Tab/store'
77
import TabState from 'components/Tab/state'
8-
import FileState from 'commons/File/state'
8+
import FileState, { extState } from 'commons/File/state'
99
import FileStore from 'commons/File/store'
1010
import { notify, NOTIFY_TYPE } from '../../components/Notification/actions'
1111
import i18n from 'utils/createI18n'
@@ -158,6 +158,9 @@ export function openFile (obj, callback) {
158158
return api.readFile(path, encoding || currentEncoding).then((data) => {
159159
FileStore.loadNodeData(data)
160160
FileState.initData.set(path, {})
161+
for (const listener of extState.didOpenListeners) {
162+
listener(FileState.entities.get(path))
163+
}
161164
return data
162165
}).then(() => {
163166
const activeTabGroup = TabStore.getState().activeTabGroup

app/commons/File/state.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const state = observable({
2020
get root () {
2121
return this.entities.get(ROOT_PATH)
2222
},
23+
})
24+
25+
// for plugin
26+
const extState = observable({
2327
createdListeners: [],
28+
didOpenListeners: [],
2429
})
2530

2631
// state.entities.intercept((change) => {
@@ -45,8 +50,8 @@ class FileNode {
4550
}
4651
state.entities.set(this.path, this)
4752
// 文件创建钩子
48-
if (state.createdListeners && state.createdListeners.length > 0) {
49-
for (const createdListener of state.createdListeners) {
53+
if (extState.createdListeners && extState.createdListeners.length > 0) {
54+
for (const createdListener of extState.createdListeners) {
5055
createdListener(this)
5156
}
5257
}
@@ -171,4 +176,4 @@ function hydrate (json) {
171176
}
172177

173178
export default state
174-
export { state, FileNode, hydrate }
179+
export { state, FileNode, hydrate, extState }

app/dashboard/i18n/en_US/global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lastModified": "Last modified {{days}} days ago",
5151
"lastModifiedToday": "Last modified Today",
5252
"deletedDaysAgo": "Deleted {{days}} days ago",
53-
"deletedTime": "Deleted {{hours}} hours {{minutes}} minutes {{seconds}} seconds ago",
53+
"deletedTime": "Deleted {{hours}} hours {{minutes}} minutes ago",
5454
"copyed": "Copyed",
5555
"noDesc": "[No Description]",
5656
"manage": "Manage",

app/dashboard/i18n/zh_CN/global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lastModified": "最后更新于 {{days}} 天前",
5151
"lastModifiedToday": "最后更新于 今天",
5252
"deletedDaysAgo": "删除于 {{days}} 天前",
53-
"deletedTime": "删除于 {{hours}} 小时 {{minutes}} 分 {{seconds}} 秒前",
53+
"deletedTime": "删除于 {{hours}} 小时 {{minutes}} 分钟前",
5454
"copyed": "复制完成",
5555
"noDesc": "[暂无描述]",
5656
"manage": "管理",

app/dashboard/utils/date.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,33 @@ const twoDigit = (num) => {
44
return num < 10 ? `0${num}` : num;
55
}
66

7-
export const getModifiedTime = (now, lastModified) => {
8-
const ms = now - lastModified;
9-
const d = Math.floor(ms / 3600000 / 24);
7+
export const getModifiedTime = (lastModified) => {
8+
const ms = new Date(new Date().setHours(0, 0, 0, 0)).getTime() - lastModified;
9+
const d = ms / 3600000 / 24;
1010
if (d > 0) {
11-
return i18n('global.lastModified', { days: d });
11+
return i18n('global.lastModified', { days: Math.ceil(d) });
1212
} else {
1313
return i18n('global.lastModifiedToday');
1414
}
1515
}
1616

17-
export const getDeletedTime = (now, lastModified) => {
18-
const ms = now - lastModified;
19-
const d = Math.floor(ms / 3600000 / 24);
17+
export const getDeletedTime = (lastModified) => {
18+
const ms = new Date(new Date().setHours(0, 0, 0, 0)).getTime() - lastModified;
19+
const d = ms / 3600000 / 24;
2020
if (d > 0) {
21-
return i18n('global.deletedDaysAgo', { days: d });
21+
return i18n('global.deletedDaysAgo', { days: Math.ceil(d) });
2222
} else {
23-
let h = Math.floor(ms / 3600000 % 24);
23+
const timestamp = Date.now() - lastModified;
24+
let h = Math.floor(timestamp / 3600000 % 24);
2425
h = h < 0 ? 0 : h;
25-
let m = Math.floor(ms / 60000 % 24);
26+
let m = Math.floor(timestamp / 60000 % 24);
2627
m = m < 0 ? 0 : m;
27-
let s = Math.floor(ms / 1000 % 60);
28-
s = s < 0 ? 0 : s;
29-
return i18n('global.deletedTime', { hours: h, minutes: m, seconds: s });
28+
return i18n('global.deletedTime', { hours: h, minutes: m });
3029
}
3130
}
3231

33-
export const getCreatedTime = (now) => {
34-
const date = new Date(now);
32+
export const getCreatedTime = (time) => {
33+
const date = new Date(time);
3534
const y = date.getFullYear();
3635
const m = twoDigit(date.getMonth() + 1);
3736
const d = twoDigit(date.getDate());
@@ -41,8 +40,8 @@ export const getCreatedTime = (now) => {
4140
return `Created: ${y}-${m}-${d} ${h}:${n}:${s}`;
4241
}
4342

44-
export const getFormatTime = (now) => {
45-
const date = new Date(now);
43+
export const getFormatTime = (time) => {
44+
const date = new Date(time);
4645
const y = date.getFullYear();
4746
const m = twoDigit(date.getMonth() + 1);
4847
const d = twoDigit(date.getDate());

app/dashboard/view/plugin/card/Card.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

app/dashboard/view/plugin/card/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, { Component } from 'react';
2+
import { Link } from 'react-router-dom';
3+
4+
import './card.css';
5+
6+
import i18n from '../../../utils/i18n';
7+
import config from '../../../utils/config';
8+
import parseStatus from '../../pluginSet/status';
9+
10+
class MCard extends Component {
11+
render() {
12+
const { id, pluginName, remark, createdBy, repoName, pluginVersions } = this.props;
13+
const { version, status, hasPrePublish, preStatus } = parseStatus(pluginVersions);
14+
const marketHref = window === window.top ? `${window.location.origin}/plugins/detail/${id}` : `${config.studioOrigin}/plugins/detail/${id}`;
15+
const wsHref = `${window === window.top ? window.location.origin : config.studioOrigin}/ws/?ownerName=${createdBy}&projectName=${repoName}`;
16+
return (
17+
<div className = "plugin-card">
18+
<div className="top">
19+
{
20+
status === 5 ? (
21+
<a className="name" href={marketHref} target="_blank" rel="noopener noreferrer">{pluginName}</a>
22+
) : <span className="name">{pluginName}</span>
23+
}
24+
<div className="right">
25+
{status === 5 && <div className="version">v{version}</div>}
26+
{
27+
(hasPrePublish && preStatus === 2) ? (
28+
<div className="tag">{i18n('plugin.prePublish')}</div>
29+
) : (status === 5 && <div className="tag">{i18n('plugin.published')}</div>)
30+
}
31+
</div>
32+
</div>
33+
<div className="desc">
34+
<span>{remark}</span>
35+
</div>
36+
<div className="control">
37+
<Link className="button" to={`/dashboard/plugin/mine/${id}`}>{i18n('global.manage')}</Link>
38+
<a className="button" href={wsHref} target="_blank" rel="noopener noreferrer">{i18n('global.workspace')}</a>
39+
</div>
40+
</div>
41+
);
42+
}
43+
}
44+
45+
export default MCard;

app/dashboard/view/plugin/card/card.css renamed to app/dashboard/view/plugin/mCard/card.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
overflow: hidden;
5454
position: relative;
5555
}
56-
.plugin-list .plugin-card .desc .ellipsis {
56+
.plugin-list .plugin-card .desc::after {
57+
content: '';
5758
width: 60px;
5859
height: 20px;
5960
background: linear-gradient(to right, transparent, #3b3b3b);

0 commit comments

Comments
 (0)