From b68ba47ac273221435ef0dc7d465dfd252496973 Mon Sep 17 00:00:00 2001 From: mip-platform Date: Mon, 5 Mar 2018 19:15:35 +0800 Subject: [PATCH] update extensions --- mip-cambrian/mip-cambrian.js | 29 +++++++++++++++++++++++++++-- mip-cambrian/package.json | 4 ++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mip-cambrian/mip-cambrian.js b/mip-cambrian/mip-cambrian.js index 4b2679f9..e25591d8 100644 --- a/mip-cambrian/mip-cambrian.js +++ b/mip-cambrian/mip-cambrian.js @@ -1,8 +1,9 @@ /** * @file mip-cambrian 寒武纪组件 + * * @author liulangyu huangjing02 * @date 2017-04-20 - * @version 1.1.0 + * @version 1.1.1 */ define(function (require) { @@ -13,11 +14,17 @@ define(function (require) { // viewer 窗口 var viewer = require('viewer'); + // 是否已经使用过,在一个page内组件只允许调用一次 + var ifBuild = false; /** * 构造元素,只会运行一次 */ customElement.prototype.build = function () { + // 组件只允许调用一次 + if (ifBuild) { + return; + } // 获取script标签里的内容 var el = $('[type$=json]'); @@ -33,8 +40,26 @@ define(function (require) { config = {}; } } + + var id = this.element.getAttribute('site-id'); - id && viewer.sendMessage('cambrian-header', {id: id, title: config.title, images: config.images}); + + if (id) { + // 获取页面描述 + var description = $('meta[name=description]').attr('content'); + + ifBuild = true; + + viewer.sendMessage( + 'cambrian-header', + { + id: id, + title: config.title || document.title, + images: config.images, + description: config.description || description + } + ); + } }; return customElement; diff --git a/mip-cambrian/package.json b/mip-cambrian/package.json index c06bde9a..f729b818 100644 --- a/mip-cambrian/package.json +++ b/mip-cambrian/package.json @@ -1,6 +1,6 @@ { "name": "mip-cambrian", - "version": "1.1.0", + "version": "1.1.1", "description": "寒武纪组件", "contributors": [ { @@ -13,6 +13,6 @@ } ], "engines": { - "mip": ">=1.1.0" + "mip": ">=1.1.1" } }