From 921c35bcfd1ad5f1ad84cf0a436536f49cd665c0 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Fri, 1 Sep 2017 10:52:03 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8F=91=E8=87=AA=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF=20ua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aurelia_project/aurelia.json | 5 +++ package.json | 3 +- .../elements/em-chat-content-item.html | 1 + src/resources/elements/em-chat-input.js | 2 + src/resources/elements/em-chat-msg.html | 1 + src/resources/elements/em-chat-topic-input.js | 1 + src/resources/elements/em-chat-topic.html | 2 + src/resources/value-converters/vc-common.js | 40 +++++++++++++++++++ 8 files changed, 54 insertions(+), 1 deletion(-) diff --git a/aurelia_project/aurelia.json b/aurelia_project/aurelia.json index baf6e8f..a6ce1e1 100644 --- a/aurelia_project/aurelia.json +++ b/aurelia_project/aurelia.json @@ -120,6 +120,11 @@ "dist/basic.css" ] }, + { + "name": "ua-device", + "path": "../node_modules/ua-device", + "main": "ua-device" + }, { "name": "tinycolorpicker", "path": "../node_modules/tinyColorPicker", diff --git a/package.json b/package.json index 5f63e41..83a75ff 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,12 @@ "requirejs": "^2.3.2", "semantic-ui-calendar": "0.0.6", "simplemde": "github:xiweicheng/simplemde-markdown-editor#master", - "tinycolorpicker": "github:xiweicheng/tinyColorPicker#master", "text": "github:requirejs/text#latest", "timeago.js": "^2.0.2", + "tinycolorpicker": "github:xiweicheng/tinyColorPicker#master", "tms-semantic-ui": "^3.2.10", "toastr": "^2.1.2", + "ua-device": "github:xiweicheng/ua-device#merged", "wurl": "^2.1.0" }, "peerDependencies": {}, diff --git a/src/resources/elements/em-chat-content-item.html b/src/resources/elements/em-chat-content-item.html index fc43b7d..a9e6dde 100644 --- a/src/resources/elements/em-chat-content-item.html +++ b/src/resources/elements/em-chat-content-item.html @@ -5,6 +5,7 @@
${item.creator.name} diff --git a/src/resources/elements/em-chat-input.js b/src/resources/elements/em-chat-input.js index adcc5ab..1d70301 100644 --- a/src/resources/elements/em-chat-input.js +++ b/src/resources/elements/em-chat-input.js @@ -314,6 +314,7 @@ export class EmChatInput { path: wurl('path'), chatTo: this.chatTo, content: content, + ua: navigator.userAgent, contentHtml: html }; } else { @@ -324,6 +325,7 @@ export class EmChatInput { channelId: this.channel.id, usernames: usernames, content: content, + ua: navigator.userAgent, contentHtml: html }; } diff --git a/src/resources/elements/em-chat-msg.html b/src/resources/elements/em-chat-msg.html index be437a5..cdf6882 100644 --- a/src/resources/elements/em-chat-msg.html +++ b/src/resources/elements/em-chat-msg.html @@ -8,6 +8,7 @@
${item.creator.name} diff --git a/src/resources/elements/em-chat-topic-input.js b/src/resources/elements/em-chat-topic-input.js index ff7cb02..4cd5e98 100644 --- a/src/resources/elements/em-chat-topic-input.js +++ b/src/resources/elements/em-chat-topic-input.js @@ -294,6 +294,7 @@ export class EmChatTopicInput { url: utils.getUrl(), usernames: utils.parseUsernames(content, this.members).join(','), content: content, + ua: navigator.userAgent, contentHtml: utils.md2html(content, true), id: this.chat.id }, (data, textStatus, xhr) => { diff --git a/src/resources/elements/em-chat-topic.html b/src/resources/elements/em-chat-topic.html index 9658e83..a5e0580 100644 --- a/src/resources/elements/em-chat-topic.html +++ b/src/resources/elements/em-chat-topic.html @@ -8,6 +8,7 @@
${chat.creator.name} @@ -32,6 +33,7 @@
${item.creator.name} diff --git a/src/resources/value-converters/vc-common.js b/src/resources/value-converters/vc-common.js index 78b55f2..1171753 100644 --- a/src/resources/value-converters/vc-common.js +++ b/src/resources/value-converters/vc-common.js @@ -4,6 +4,10 @@ import { default as ColorHash } from 'color-hash'; import tags from 'common/common-tags'; +import { + default as UA +} +from 'ua-device'; let tg = timeago(); @@ -202,3 +206,39 @@ export class DiffHtmlValueConverter { return value; } } + +export class UaValueConverter { + toView(value) { + if (value) { + + var ua = new UA(value); + let type = ua.device.type; + if (type === 'mobile') { + return 'mobile'; + } else if (type === 'tablet') { + return 'tablet'; + } else if (type === 'desktop') { + return 'laptop'; + } + } + return 'laptop'; + } +} + +export class Ua2ValueConverter { + toView(value) { + if (value) { + + var ua = new UA(value); + let type = ua.device.type; + if (type === 'mobile') { + return '手机'; + } else if (type === 'tablet') { + return '平板'; + } else if (type === 'desktop') { + return '电脑'; + } + } + return '电脑'; + } +} -- Gitee From 98c410e01bcb1e4450d721ebcfdbe3070de2b3a8 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Fri, 1 Sep 2017 10:52:57 +0800 Subject: [PATCH 2/5] ... --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 1dd3448..19a79d4 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ - + -- Gitee From 72dcc7b1269ad3c10dbf16ff9e1a66456dd91a2f Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Fri, 1 Sep 2017 12:58:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?ua=20=E4=B8=BA=E7=A9=BA=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/resources/elements/em-chat-content-item.html | 2 +- src/resources/elements/em-chat-msg.html | 2 +- src/resources/elements/em-chat-topic.html | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 19a79d4..452fbc7 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ - + diff --git a/src/resources/elements/em-chat-content-item.html b/src/resources/elements/em-chat-content-item.html index a9e6dde..422330d 100644 --- a/src/resources/elements/em-chat-content-item.html +++ b/src/resources/elements/em-chat-content-item.html @@ -5,7 +5,7 @@
${item.creator.name} diff --git a/src/resources/elements/em-chat-msg.html b/src/resources/elements/em-chat-msg.html index cdf6882..b83f2b5 100644 --- a/src/resources/elements/em-chat-msg.html +++ b/src/resources/elements/em-chat-msg.html @@ -8,7 +8,7 @@
${item.creator.name} diff --git a/src/resources/elements/em-chat-topic.html b/src/resources/elements/em-chat-topic.html index a5e0580..ab88699 100644 --- a/src/resources/elements/em-chat-topic.html +++ b/src/resources/elements/em-chat-topic.html @@ -8,7 +8,7 @@
${chat.creator.name} @@ -33,7 +33,7 @@
${item.creator.name} -- Gitee From 0783d6cfaf802025ed401b883e154f4f60a0c512 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Fri, 1 Sep 2017 16:54:57 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E8=87=AA?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=9B=B4=E5=A4=9A=E4=BF=A1=E6=81=AF=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/resources/value-converters/vc-common.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 452fbc7..1dd3448 100644 --- a/index.html +++ b/index.html @@ -17,7 +17,7 @@ - + diff --git a/src/resources/value-converters/vc-common.js b/src/resources/value-converters/vc-common.js index 1171753..b09e0da 100644 --- a/src/resources/value-converters/vc-common.js +++ b/src/resources/value-converters/vc-common.js @@ -227,18 +227,20 @@ export class UaValueConverter { export class Ua2ValueConverter { toView(value) { + + let s = ''; if (value) { var ua = new UA(value); let type = ua.device.type; if (type === 'mobile') { - return '手机'; + s = `手机`; } else if (type === 'tablet') { - return '平板'; + s = '平板'; } else if (type === 'desktop') { - return '电脑'; + s = '电脑'; } } - return '电脑'; + return `${s} (${ua.device.manufacturer ? ua.device.manufacturer + ' ' : ''}${ua.device.model ? ua.device.model + ' ' : ''}${ua.os.name} ${ua.browser.name}[${ua.engine.name}])`; } } -- Gitee From 5447d198e5b15adfc8c61498d0794023f349e7f3 Mon Sep 17 00:00:00 2001 From: xiweicheng Date: Tue, 5 Sep 2017 15:19:50 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=B7=E6=96=B0,=20?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=88=A4=E6=96=AD=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?,=20=E7=9B=B4=E6=8E=A5=E6=9B=BF=E6=8D=A2=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=9A=84=E6=96=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/elements/em-chat-content-item.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/resources/elements/em-chat-content-item.js b/src/resources/elements/em-chat-content-item.js index dc3c089..3ff7dd8 100644 --- a/src/resources/elements/em-chat-content-item.js +++ b/src/resources/elements/em-chat-content-item.js @@ -368,13 +368,13 @@ export class EmChatContentItem { $.get('/admin/chat/channel/get', { id: item.id }, (data) => { - if (item.version != data.data.version) { - _.extend(item, data.data); - toastr.success('刷新同步成功!'); - } else { - item.chatReplies = data.data.chatReplies; - toastr.info('消息内容暂无变更!'); - } + // if (item.version != data.data.version) { + _.extend(item, data.data); + toastr.success('刷新同步成功!'); + // } else { + // item.chatReplies = data.data.chatReplies; + // toastr.info('消息内容暂无变更!'); + // } }); } -- Gitee