Skip to content

Commit a7c27f0

Browse files
committed
feat: 多个断点默认按照最后修改时间倒序排序
1 parent 1bc04a9 commit a7c27f0

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-script-hook",
33
"description": "用来给script类型的请求打断点",
4-
"version": "0.0.1",
4+
"version": "0.3",
55
"main": "index.js",
66
"repository": "https://github.com/JSREI/js-script-hook.git",
77
"namespace": "https://github.com/JSREI/js-script-hook.git",

src/config/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class Config {
6969
this.debuggers = [];
7070
for (let debuggerInformationObject of o.debuggers) {
7171
const debuggerInformation = new Debugger();
72+
debuggerInformation.createTime = debuggerInformationObject.createTime;
73+
debuggerInformation.updateTime = debuggerInformationObject.updateTime;
7274
debuggerInformation.id = debuggerInformationObject.id;
7375
debuggerInformation.enable = debuggerInformationObject.enable;
7476
debuggerInformation.urlPattern = debuggerInformationObject.urlPattern;

src/config/ui/component/debugger-component.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,23 @@ class DebuggerComponent {
171171
debuggerElt.find(`#${debuggerInformation.id}-enable-checkbox`).on('change', function () {
172172
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
173173
localDebuggerInformation.enable = $(this).is(':checked');
174+
localDebuggerInformation.updateTime = new Date().getTime();
174175
getGlobalConfig().persist();
175176
});
176177

177178
// URL匹配类型
178179
debuggerElt.find(`#${debuggerInformation.id}-url-pattern`).change(function () {
179180
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
180181
localDebuggerInformation.urlPatternType = $(this).val();
182+
localDebuggerInformation.updateTime = new Date().getTime();
181183
getGlobalConfig().persist();
182184
});
183185

184186
// URL匹配值
185187
debuggerElt.find(`#${debuggerInformation.id}-url-pattern-text`).on('input', function () {
186188
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
187189
localDebuggerInformation.urlPattern = this.value;
190+
localDebuggerInformation.updateTime = new Date().getTime();
188191
getGlobalConfig().persist();
189192
});
190193

@@ -200,34 +203,39 @@ class DebuggerComponent {
200203
debuggerElt.find(`#${debuggerInformation.id}-enableRequestDebugger-checkbox`).on('change', function () {
201204
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
202205
localDebuggerInformation.enableRequestDebugger = $(this).is(':checked');
206+
localDebuggerInformation.updateTime = new Date().getTime();
203207
getGlobalConfig().persist();
204208
});
205209

206210
// enableResponseDebugger
207211
debuggerElt.find(`#${debuggerInformation.id}-enableResponseDebugger-checkbox`).on('change', function () {
208212
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
209213
localDebuggerInformation.enableResponseDebugger = $(this).is(':checked');
214+
localDebuggerInformation.updateTime = new Date().getTime();
210215
getGlobalConfig().persist();
211216
});
212217

213218
// ${debuggerConfig.id}-hook-type
214219
debuggerElt.find(`#${debuggerInformation.id}-hook-type`).change(function () {
215220
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
216221
localDebuggerInformation.hookType = $(this).val();
222+
localDebuggerInformation.updateTime = new Date().getTime();
217223
getGlobalConfig().persist();
218224
});
219225

220226
// callbackFunctionParamName
221227
debuggerElt.find(`#${debuggerInformation.id}-callbackFunctionParamName-text`).on('input', function () {
222228
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
223229
localDebuggerInformation.callbackFunctionParamName = this.value;
230+
localDebuggerInformation.updateTime = new Date().getTime();
224231
getGlobalConfig().persist();
225232
});
226233

227234
// 注释
228235
debuggerElt.find(`#${debuggerInformation.id}-comment-text`).on('input', function () {
229236
const localDebuggerInformation = getGlobalConfig().findDebuggerById(debuggerInformation.id);
230237
localDebuggerInformation.comment = this.value;
238+
localDebuggerInformation.updateTime = new Date().getTime();
231239
getGlobalConfig().persist();
232240
});
233241

src/config/ui/component/debugger-manager-component.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class DebuggerManagerComponent {
2323
*/
2424
render(language, debuggers) {
2525

26+
// 按照最后修改时间排序
27+
debuggers.sort((a, b) => {
28+
const t1 = parseInt(a.updateTime || 0);
29+
const t2 = parseInt(b.updateTime || 0);
30+
return t2 - t1;
31+
});
32+
2633
const debuggerManager = $(this.html);
2734

2835
// 渲染已经存在的断点配置信息

src/debugger/debugger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class Debugger {
2525
callbackFunctionParamName = null,
2626
comment = null
2727
) {
28+
this.createTime = new Date().getTime();
29+
this.updateTime = new Date().getTime();
2830
this.id = id;
2931
this.enable = enable;
3032
this.urlPatternType = urlPatternType;

0 commit comments

Comments
 (0)