diff --git a/public/index.html b/public/index.html index 4123528..be98c98 100644 --- a/public/index.html +++ b/public/index.html @@ -13,5 +13,6 @@
+ diff --git a/public/sdk.js b/public/sdk.js new file mode 100644 index 0000000..35b9312 --- /dev/null +++ b/public/sdk.js @@ -0,0 +1,82 @@ +(function(window) { + var _instance = null; + window.TallPlugin = function(config) { + this.config = config; + this.props = null; + }; + + // 初始化并保证是单例 + TallPlugin.init = function(config) { + if (!_instance) { + _instance = new TallPlugin(config); + } + return _instance; + }; + + function postMsg(message) { + let origin = '*'; + window.postMessage(message, origin); + } + + TallPlugin.prototype.created = function(callback) { + console.log('created begin'); + var _this = this; + postMsg('created'); + window.addEventListener( + 'message', + function({ data, origin }) { + console.log('on created message, data, origin: ', data, origin); + try { + var target = JSON.parse(data); + if (target.success) { + _this.props = JSON.parse(data); + callback && typeof callback === 'function' && callback.call(_this, _this.props); + } + // else { + // _this.props = null; + // } + } catch (e) { + _this.props = null; + } + }, + false, + ); + // DOM加载完成 + window.addEventListener('DOMContentLoaded', this.mounted, false); + // window onload + window.addEventListener('load', this.loaded, false); + // destroy + window.addEventListener('unload', this.destroy, false); + // error + window.addEventListener('error', this.error, false); + return this; + }; + + TallPlugin.prototype.mounted = function(callback) { + console.log('mounted'); + postMsg('mounted'); + callback && typeof callback === 'function' && callback.call(this); + return this; + }; + + TallPlugin.prototype.loaded = function(callback) { + console.log('loaded'); + postMsg('loaded'); + callback && typeof callback === 'function' && callback.call(this); + return this; + }; + + TallPlugin.prototype.destroy = function(callback) { + console.log('destroy'); + postMsg('destroy'); + callback && typeof callback === 'function' && callback.call(this); + return this; + }; + + TallPlugin.prototype.error = function(callback) { + console.log('error'); + postMsg('error'); + callback && typeof callback === 'function' && callback.call(this); + return this; + }; +})(window); diff --git a/src/App.vue b/src/App.vue index af3768b..271b478 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,16 +21,39 @@ export default { }; }, - computed: mapState(['anyringToken']), + computed: mapState(['anyringToken', 'ptProps']), + + watch: { + ptProps(val) { + if (val.userId) { + const params = { userId: val.userId }; + this.getUserId(params); + console.log('val.userId:' + val.userId); + } + }, + }, created() { - console.log('process.env ', process.env); + // 测试数据 const userId = '1218763410024566784'; const params = { userId }; this.getUserId(params); + + const that = this; + window.plugin = window.TallPlugin.init(); + // 调用created方法 向主窗体发送created消息,以便来接受、存储主窗体传递来的参数 + // created接受一个回调函数 created成功后调用 可选参数 + // 接受PT传过来的 插件id,项目id,角色id,任务id,userId + window.plugin.created(function(props) { + console.log('props: ', props); + that.setPtProps(props); + }); }, - methods: mapActions(['getUserId']), + methods: { + ...mapActions(['getUserId']), + ...mapMutations('home', ['setPtProps']), + }, }; diff --git a/src/components/Activity/ActivityAdd.vue b/src/components/Activity/ActivityAdd.vue index fbc971f..c2bf5cc 100644 --- a/src/components/Activity/ActivityAdd.vue +++ b/src/components/Activity/ActivityAdd.vue @@ -2,8 +2,8 @@
@@ -229,8 +230,11 @@ export default { this.editVisible = true; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async getSelectTeam() { await this.$emit('getSelectTeam'); }, diff --git a/src/components/Activity/ActivityEdit.vue b/src/components/Activity/ActivityEdit.vue index 23d8931..cd371e0 100644 --- a/src/components/Activity/ActivityEdit.vue +++ b/src/components/Activity/ActivityEdit.vue @@ -2,8 +2,8 @@
- + - + - + - + - + - - - 选择图片 + + + + 选择图片 + - - - {{ item }} + + + {{ item }} diff --git a/src/components/Challenge/ChallengeEdit.vue b/src/components/Challenge/ChallengeEdit.vue index 9b21ef8..7b62e6d 100644 --- a/src/components/Challenge/ChallengeEdit.vue +++ b/src/components/Challenge/ChallengeEdit.vue @@ -1,34 +1,84 @@ @@ -180,8 +181,11 @@ export default { this.editItem = record; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async getInstituteSearchBack() { await this.$emit('getInstituteSearchBack'); }, diff --git a/src/components/Institute/InstituteEdit.vue b/src/components/Institute/InstituteEdit.vue index 72a932a..e66d2b3 100644 --- a/src/components/Institute/InstituteEdit.vue +++ b/src/components/Institute/InstituteEdit.vue @@ -2,8 +2,8 @@
- +
@@ -109,8 +114,11 @@ export default { this.editVisible = true; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async selModelSearch() { await this.$emit('selModelSearch'); }, diff --git a/src/components/Manage/ManageEdit.vue b/src/components/Manage/ManageEdit.vue index 2f4cf0b..8f55cc2 100644 --- a/src/components/Manage/ManageEdit.vue +++ b/src/components/Manage/ManageEdit.vue @@ -2,8 +2,8 @@
- +
@@ -121,8 +126,11 @@ export default { this.editVisible = true; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async getPageList() { await this.$emit('getPageList'); }, diff --git a/src/components/Page/PageEdit.vue b/src/components/Page/PageEdit.vue index e96b4b4..30a6195 100644 --- a/src/components/Page/PageEdit.vue +++ b/src/components/Page/PageEdit.vue @@ -2,8 +2,8 @@
- +
@@ -156,8 +161,11 @@ export default { this.editVisible = true; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async getBackendSearch() { await this.$emit('getBackendSearch'); }, diff --git a/src/components/Partner/PartnerEdit.vue b/src/components/Partner/PartnerEdit.vue index 40f0bb0..18b36e5 100644 --- a/src/components/Partner/PartnerEdit.vue +++ b/src/components/Partner/PartnerEdit.vue @@ -2,9 +2,9 @@
增加 - +
@@ -56,8 +56,11 @@ export default { this.visible = true; }, - async closeModal() { + closeModal() { this.visible = false; + }, + + async getBackendSearch() { await this.$emit('getBackendSearch'); }, diff --git a/src/components/Policy/PolicyAdd.vue b/src/components/Policy/PolicyAdd.vue index f737b36..1e66cc1 100644 --- a/src/components/Policy/PolicyAdd.vue +++ b/src/components/Policy/PolicyAdd.vue @@ -2,8 +2,8 @@
- +
@@ -213,8 +218,11 @@ export default { this.editVisible = true; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async getSelectTeam() { await this.$emit('getSelectTeam'); }, diff --git a/src/components/Policy/PolicyEdit.vue b/src/components/Policy/PolicyEdit.vue index 1b8a227..8b452bc 100644 --- a/src/components/Policy/PolicyEdit.vue +++ b/src/components/Policy/PolicyEdit.vue @@ -2,8 +2,8 @@
- +
@@ -87,8 +87,11 @@ export default { this.visible = true; }, - async closeModal() { + closeModal() { this.visible = false; + }, + + async getSelectTeam() { await this.$emit('getSelectTeam'); }, diff --git a/src/components/RD/RDAdd.vue b/src/components/RD/RDAdd.vue index 2a4e743..5a95739 100644 --- a/src/components/RD/RDAdd.vue +++ b/src/components/RD/RDAdd.vue @@ -2,8 +2,8 @@
@@ -202,8 +203,11 @@ export default { this.editItem = record; }, - async closeModal() { + closeModal() { this.editVisible = false; + }, + + async selInstrumentSearch() { await this.$emit('selInstrumentSearch'); }, diff --git a/src/components/Transfer/TransferEdit.vue b/src/components/Transfer/TransferEdit.vue index 2848a56..c37cc9b 100644 --- a/src/components/Transfer/TransferEdit.vue +++ b/src/components/Transfer/TransferEdit.vue @@ -2,8 +2,8 @@
- + - + - + - + - + - - - 选择图片 + + + + 选择图片 + - - - {{ item }} + + + {{ item }} diff --git a/src/components/innovativeService/innovativeServiceEdit.vue b/src/components/innovativeService/innovativeServiceEdit.vue index 0cd4d1f..f79d4bf 100644 --- a/src/components/innovativeService/innovativeServiceEdit.vue +++ b/src/components/innovativeService/innovativeServiceEdit.vue @@ -1,34 +1,84 @@