@aicupa/plugin-balance 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/service.js +3 -1
- package/view/index.html +38 -5
package/package.json
CHANGED
package/service.js
CHANGED
|
@@ -130,10 +130,12 @@ module.exports = createPlugin((api) => {
|
|
|
130
130
|
const tempTime = collectDoneTime(tempNode);
|
|
131
131
|
const currentTime = collectDoneTime(currentNode);
|
|
132
132
|
const percent = Math.round((tempTime / (currentTime + tempTime)) * 100);
|
|
133
|
+
const tempContent = tempNode?.todo?.content || '';
|
|
134
|
+
const currentContent = currentNode?.todo?.content || '';
|
|
133
135
|
|
|
134
136
|
return {
|
|
135
137
|
ok: true,
|
|
136
|
-
result: { percent, tempTime, currentTime },
|
|
138
|
+
result: { percent, tempTime, currentTime, tempContent, currentContent },
|
|
137
139
|
};
|
|
138
140
|
},
|
|
139
141
|
};
|
package/view/index.html
CHANGED
|
@@ -71,18 +71,41 @@
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
.balance-bar-track {
|
|
74
|
-
height:
|
|
75
|
-
border-radius:
|
|
74
|
+
height: 16px;
|
|
75
|
+
border-radius: 8px;
|
|
76
76
|
background: rgba(128, 128, 128, 0.15);
|
|
77
77
|
overflow: hidden;
|
|
78
|
+
position: relative;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
.balance-bar-fill {
|
|
81
82
|
height: 100%;
|
|
82
|
-
border-radius:
|
|
83
|
+
border-radius: 8px;
|
|
83
84
|
transition: width 0.3s ease, background 0.3s ease;
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
.bar-label {
|
|
88
|
+
position: absolute;
|
|
89
|
+
top: 50%;
|
|
90
|
+
transform: translateY(-50%);
|
|
91
|
+
font-size: 9px;
|
|
92
|
+
opacity: 0.8;
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
text-overflow: ellipsis;
|
|
96
|
+
pointer-events: none;
|
|
97
|
+
padding: 0 4px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.bar-label-left {
|
|
101
|
+
left: 0;
|
|
102
|
+
text-align: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.bar-label-right {
|
|
106
|
+
text-align: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
86
109
|
.balance-ratio {
|
|
87
110
|
font-size: 11px;
|
|
88
111
|
opacity: 0.7;
|
|
@@ -134,6 +157,8 @@
|
|
|
134
157
|
<div class="balance-bar-wrap">
|
|
135
158
|
<div class="balance-bar-track">
|
|
136
159
|
<div class="balance-bar-fill" id="barFill" style="width:0%"></div>
|
|
160
|
+
<span class="bar-label bar-label-left" id="labelLeft"></span>
|
|
161
|
+
<span class="bar-label bar-label-right" id="labelRight"></span>
|
|
137
162
|
</div>
|
|
138
163
|
</div>
|
|
139
164
|
<span class="balance-ratio" id="ratio">0%</span>
|
|
@@ -180,6 +205,8 @@
|
|
|
180
205
|
const currentInput = document.getElementById('currentId')
|
|
181
206
|
const barFill = document.getElementById('barFill')
|
|
182
207
|
const ratioEl = document.getElementById('ratio')
|
|
208
|
+
const labelLeft = document.getElementById('labelLeft')
|
|
209
|
+
const labelRight = document.getElementById('labelRight')
|
|
183
210
|
const focusSection = document.getElementById('focusSection')
|
|
184
211
|
const focusList = document.getElementById('focusList')
|
|
185
212
|
let debounceTimer = null
|
|
@@ -210,8 +237,14 @@
|
|
|
210
237
|
const pct = Math.min(r.percent || 0, 100)
|
|
211
238
|
barFill.style.width = pct + '%'
|
|
212
239
|
var h = Math.round(120 * (1 - pct / 100))
|
|
213
|
-
barFill.style.background = '
|
|
214
|
-
|
|
240
|
+
barFill.style.background = 'hsla(' + h + ', 55%, 65%, 0.25)'
|
|
241
|
+
var offset = pct - 50
|
|
242
|
+
ratioEl.textContent = (offset > 0 ? '+' : '') + offset + '%'
|
|
243
|
+
labelLeft.textContent = r.tempContent || ''
|
|
244
|
+
labelLeft.style.width = pct + '%'
|
|
245
|
+
labelRight.textContent = r.currentContent || ''
|
|
246
|
+
labelRight.style.left = pct + '%'
|
|
247
|
+
labelRight.style.width = (100 - pct) + '%'
|
|
215
248
|
}
|
|
216
249
|
} catch (_) { }
|
|
217
250
|
|