diff --git a/CHANGELOG.md b/CHANGELOG.md index 25b0d1d..55e60eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ ### 🐛 Bug 修复 范围|描述|commitId --|--|-- + role | 切换角色的逻辑修正完善 | 4ae534f task任务逻辑完善 | 减少初始global及regular的不必要请求 | bd4bd38 - | 上下滑动加载定期任务 | 4090d89 - | 上下滚动时间轴 | d533a01 diff --git a/src/components/Plugin/Plugin.vue b/src/components/Plugin/Plugin.vue index 4c10106..7824536 100644 --- a/src/components/Plugin/Plugin.vue +++ b/src/components/Plugin/Plugin.vue @@ -1,22 +1,19 @@ @@ -25,48 +22,60 @@ export default { name: 'Plugin', props: { - item: { - default: () => {}, - type: Object, - }, - pluginId: { - default: '1', - type: String, - }, - styleType: { - default: 0, - type: Number, - }, - pluginTaskId: { - default: '0', - type: String, - }, + task: { default: () => {}, type: Object }, + pluginId: { default: '1', type: String }, + styleType: { default: 0, type: Number }, + pluginTaskId: { default: '0', type: String }, }, data() { return { pluginContent: null }; }, - async created() { - await this.getPlugin(); - let domList = Array.from(document.getElementsByTagName('script')); - const index = domList.findIndex(item => item.id === `p${this.pluginContent.pluginId}`); - if (this.pluginContent.js && index === -1) { - var scriptDom = document.createElement('script'); - scriptDom.id = `p${this.pluginContent.pluginId}`; - scriptDom.innerHTML = this.pluginContent.js; - document.body.append(scriptDom); - } + created() { + this.getPlugin(); }, methods: { + // 获取插件信息 async getPlugin() { const { pluginId, styleType } = this; - const res = await this.$u.api.getOtherPlugin({ + const data = await this.$u.api.getOtherPlugin({ pluginId, styleType, }); - this.pluginContent = res; + if (!data || !data.id) return; + if (data.html) { + // 查有没有data-root=“xxx” 有的话 将xxx替换为 pluginTaskId + const reg = /data-root="(\w+)"/gi; + if (reg.test(data.html)) { + const str = data.html.replace(RegExp.$1, this.pluginTaskId); + this.pluginContent = str; + } else { + this.pluginContent = data.html; + } + } + if (data.js) { + if (reg.test(data.js)) { + const str = data.js.replace(RegExp.$1, this.pluginTaskId); + this.handleDom(str); + } else { + this.handleDom(data.js); + } + } + }, + + // 创建script dom + handleDom(js) { + const { pluginId } = this; + let domList = Array.from(document.getElementsByTagName('script')); + const index = domList.findIndex(item => item.id === `p${pluginId}`); + if (js && index === -1) { + const scriptDom = document.createElement('script'); + scriptDom.id = `p${pluginId}`; + scriptDom.innerHTML = js; + document.body.append(scriptDom); + } }, }, }; diff --git a/src/components/TimeLine/component/TimeBox.vue b/src/components/TimeLine/component/TimeBox.vue index a0462bd..f24fe2b 100644 --- a/src/components/TimeLine/component/TimeBox.vue +++ b/src/components/TimeLine/component/TimeBox.vue @@ -1,12 +1,12 @@ - - diff --git a/src/plugins/p-task-duration-delay/p-task-duration-delay.vue b/src/plugins/p-task-duration-delay/p-task-duration-delay.vue index dcb14ad..0c63226 100644 --- a/src/plugins/p-task-duration-delay/p-task-duration-delay.vue +++ b/src/plugins/p-task-duration-delay/p-task-duration-delay.vue @@ -1,28 +1,20 @@ - - diff --git a/src/plugins/p-task-start-time-delay/p-task-start-time-delay.vue b/src/plugins/p-task-start-time-delay/p-task-start-time-delay.vue index d6205e2..7b74561 100644 --- a/src/plugins/p-task-start-time-delay/p-task-start-time-delay.vue +++ b/src/plugins/p-task-start-time-delay/p-task-start-time-delay.vue @@ -1,23 +1,14 @@ - - diff --git a/src/plugins/p-task-title/p-task-title.vue b/src/plugins/p-task-title/p-task-title.vue index 777ff07..1e5326f 100644 --- a/src/plugins/p-task-title/p-task-title.vue +++ b/src/plugins/p-task-title/p-task-title.vue @@ -1,20 +1,11 @@ - - diff --git a/src/store/task/actions.js b/src/store/task/actions.js index ad6eeeb..50e5b76 100644 --- a/src/store/task/actions.js +++ b/src/store/task/actions.js @@ -16,7 +16,7 @@ const actions = { /** * 根据时间和角色查找日常任务 * @param {*} commit - * @param {object} param 请求参数 + * @param {object} param 请求参数 roleId, timeNode, timeUnit */ async getGlobal({ commit }, param) { try { diff --git a/src/store/task/getters.js b/src/store/task/getters.js index 1c89578..e56b704 100644 --- a/src/store/task/getters.js +++ b/src/store/task/getters.js @@ -6,7 +6,6 @@ const getters = { // 计算任务开始时间的格式 startTimeFormat({ timeUnit }) { - console.log(uni.$t); const target = uni.$t.timeConfig.timeUnits.find(item => item.id === timeUnit); return target.format || 'D日 HH:mm'; }, diff --git a/src/store/task/mutations.js b/src/store/task/mutations.js index ef4e5c9..6d5d685 100644 --- a/src/store/task/mutations.js +++ b/src/store/task/mutations.js @@ -96,7 +96,7 @@ const mutations = { if (!data || !data.length) { state.bottomEnd = true; } - if (!state.tasks[0].name) { + if (!state.tasks[0] || !state.tasks[0].name) { state.tasks = [...data]; } else { state.tasks = [...state.tasks.concat(data)]; diff --git a/src/store/user/actions.js b/src/store/user/actions.js index cbd9ceb..f210797 100644 --- a/src/store/user/actions.js +++ b/src/store/user/actions.js @@ -11,7 +11,7 @@ const actions = { commit('setUser', res); return res; } catch (error) { - throw error || '获取个人信息失败'; + uni.$t.ui.showToast(error.msg || '获取个人信息失败'); } }, };