From a3e68d3e189b3197e1d1827dfd0c75b7e31380e6 Mon Sep 17 00:00:00 2001
From: wally <18603454788@163.com>
Date: Thu, 29 Jul 2021 20:11:11 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E5=A4=84=E7=90=86=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 1 +
src/components/Plugin/Plugin.vue | 101 ++++++++++--------
src/components/TimeLine/component/TimeBox.vue | 42 +++++---
.../p-task-description/p-task-description.vue | 13 +--
.../p-task-duration-delay.vue | 24 ++---
.../p-task-start-time-delay.vue | 15 +--
src/plugins/p-task-title/p-task-title.vue | 13 +--
src/store/task/actions.js | 2 +-
src/store/task/getters.js | 1 -
src/store/task/mutations.js | 2 +-
src/store/user/actions.js | 2 +-
11 files changed, 99 insertions(+), 117 deletions(-)
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 @@
-
+
-
+
- {{ $moment(+item.planStart).format(startTimeFormat) }}
+ {{ $moment(+task.planStart).format(startTimeFormat) }}
@@ -18,27 +18,29 @@
-
+
+
+
-
-
+
+
@@ -48,14 +50,15 @@
+
-
-
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 @@
-
+
- +{{ $t.time.formatDuration(+item.realDuration - +item.planDuration) }}
+
+ +{{ $t.time.formatDuration(+realDuration - +planDuration) }}
+
- -{{ $t.time.formatDuration(+item.planDuration - +item.realDuration) }}
+
+ -{{ $t.time.formatDuration(+planDuration - +realDuration) }}
+
-
-
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 @@
-
+
- {{ $t.time.formatDuration(+item.realStart - +item.planStart) }}
+ {{ $t.time.formatDuration(+realStart - +planStart) }}
-
-
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 @@
- {{ item.name }}
+ {{ name }}
-
-
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 || '获取个人信息失败');
}
},
};