-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
87 lines (82 loc) · 3.2 KB
/
Copy pathconfig.js
File metadata and controls
87 lines (82 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
new Vue({
el: '#config',
data: {
navigateTimeout: 15000,
defaultTimeout: 10000,
navigateWaitUntil: 'domcontentloaded',
selectedScreenshot: 'everyScreenshot',
isCloseBrowser: true,
fullScreenshot: false,
iteration: 1,
isMobile: false,
isClearStorage: true,
},
computed: {
isFullScreenshotEnabled() {
return this.selectedScreenshot !== 'neverScreenshot';
}
},
watch: {
navigateTimeout(newValue) {
this.navigateTimeout = this.validateValue(newValue);
},
defaultTimeout(newValue) {
this.defaultTimeout = this.validateValue(newValue);
},
iteration(newValue) {
this.iteration = this.validateValue(newValue);
}
},
methods: {
validateValue(value) {
return Math.max(1, Number(value));
},
saveConfig() {
const confige2e = {
navigateTimeout: this.navigateTimeout,
defaultTimeout: this.defaultTimeout,
navigateWaitUntil: this.navigateWaitUntil,
selectedScreenshot: this.selectedScreenshot,
isCloseBrowser: this.isCloseBrowser,
fullScreenshot: this.fullScreenshot,
iteration: this.iteration,
isMobile: this.isMobile,
isClearStorage: this.isClearStorage,
};
localStorage.setItem('confige2e', JSON.stringify(confige2e));
alert('Configurações salvas com sucesso!');
},
loadConfig() {
const getConfig = localStorage.getItem('confige2e');
if (getConfig) {
try {
const config = JSON.parse(getConfig);
this.navigateTimeout = config.navigateTimeout ?? this.navigateTimeout;
this.defaultTimeout = config.defaultTimeout ?? this.defaultTimeout;
this.navigateWaitUntil = config.navigateWaitUntil ?? this.navigateWaitUntil;
this.selectedScreenshot = config.selectedScreenshot ?? this.selectedScreenshot;
this.isCloseBrowser = config.isCloseBrowser ?? this.isCloseBrowser;
this.fullScreenshot = config.fullScreenshot ?? this.fullScreenshot;
this.iteration = config.iteration ?? this.iteration;
this.isMobile = config.isMobile ?? this.isMobile;
this.isClearStorage = config.isClearStorage ?? this.isClearStorage;
} catch (e) {
console.error('Erro ao carregar configuração:', e);
}
}
}
},
mounted() {
const theme = localStorage.getItem('theme') || 'dark';
document.documentElement.setAttribute('data-theme', theme);
window.electronAPI.onThemeChange((newTheme) => {
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
});
this.loadConfig();
const btn = document.getElementById('saveSettings');
if (btn) {
btn.addEventListener('click', this.saveConfig);
}
}
});