fix wrong formatted output

This commit is contained in:
KOWX712
2025-02-11 20:07:49 +08:00
parent 0427153ea6
commit 4977695022
2 changed files with 18 additions and 18 deletions

View File

@@ -307,12 +307,12 @@
<div id="advanced-mode-inputs" class="advanced-mode-inputs hidden"> <div id="advanced-mode-inputs" class="advanced-mode-inputs hidden">
<div class="input-group"> <div class="input-group">
<label id="security_patch-boot">Boot</label> <label id="security_patch-system">System</label>
<input type="text" id="boot-patch" placeholder="202501"> <input type="text" id="system-patch" placeholder="202501">
</div> </div>
<div class="input-group"> <div class="input-group">
<label id="security_patch-system">System</label> <label id="security_patch-boot">Boot</label>
<input type="text" id="system-patch" placeholder="2025-01-01"> <input type="text" id="boot-patch" placeholder="2025-01-01">
</div> </div>
<div class="input-group"> <div class="input-group">
<label id="security_patch-vendor">Vendor</label> <label id="security_patch-vendor">Vendor</label>

View File

@@ -41,7 +41,7 @@ async function loadCurrentConfig() {
const result = await execCommand('cat /data/adb/security_patch'); const result = await execCommand('cat /data/adb/security_patch');
if (result) { if (result) {
const lines = result.split('\n'); const lines = result.split('\n');
let autoConfig = '1', allValue = '0', bootValue = '0', systemValue = '0', vendorValue = '0'; let autoConfig = '1', allValue = '0', systemValue = '0', bootValue = '0', vendorValue = '0';
for (const line of lines) { for (const line of lines) {
if (line.startsWith('auto_config=')) { if (line.startsWith('auto_config=')) {
autoConfig = line.split('=')[1]; autoConfig = line.split('=')[1];
@@ -50,8 +50,8 @@ async function loadCurrentConfig() {
if (autoConfig === '1') { if (autoConfig === '1') {
allValue = null; allValue = null;
bootValue = null;
systemValue = null; systemValue = null;
bootValue = null;
vendorValue = null; vendorValue = null;
overlay.classList.add('hidden'); overlay.classList.add('hidden');
} else { } else {
@@ -64,14 +64,14 @@ async function loadCurrentConfig() {
allValue = line.split('=')[1] || null; allValue = line.split('=')[1] || null;
if (allValue !== null) allPatchInput.value = allValue; if (allValue !== null) allPatchInput.value = allValue;
} }
if (line.startsWith('boot=')) {
bootValue = line.split('=')[1] || null;
if (bootValue !== null) bootPatchInput.value = bootValue;
}
if (line.startsWith('system=')) { if (line.startsWith('system=')) {
systemValue = line.split('=')[1] || null; systemValue = line.split('=')[1] || null;
if (systemValue !== null) systemPatchInput.value = systemValue; if (systemValue !== null) systemPatchInput.value = systemValue;
} }
if (line.startsWith('boot=')) {
bootValue = line.split('=')[1] || null;
if (bootValue !== null) bootPatchInput.value = bootValue;
}
if (line.startsWith('vendor=')) { if (line.startsWith('vendor=')) {
vendorValue = line.split('=')[1] || null; vendorValue = line.split('=')[1] || null;
if (vendorValue !== null) vendorPatchInput.value = vendorValue; if (vendorValue !== null) vendorPatchInput.value = vendorValue;
@@ -139,8 +139,8 @@ export function securityPatch() {
} else { } else {
await execCommand(`sed -i "s/^auto_config=.*/auto_config=1/" /data/adb/security_patch`); await execCommand(`sed -i "s/^auto_config=.*/auto_config=1/" /data/adb/security_patch`);
allPatchInput.value = ''; allPatchInput.value = '';
bootPatchInput.value = '';
systemPatchInput.value = ''; systemPatchInput.value = '';
bootPatchInput.value = '';
vendorPatchInput.value = ''; vendorPatchInput.value = '';
showPrompt('security_patch.auto_success'); showPrompt('security_patch.auto_success');
} }
@@ -179,8 +179,8 @@ export function securityPatch() {
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
echo all=${allValue} > /data/adb/tricky_store/security_patch.txt echo all=${allValue} > /data/adb/tricky_store/security_patch.txt
`); `);
bootPatchInput.value = '';
systemPatchInput.value = ''; systemPatchInput.value = '';
bootPatchInput.value = '';
vendorPatchInput.value = ''; vendorPatchInput.value = '';
showPrompt('security_patch.save_success'); showPrompt('security_patch.save_success');
} catch (error) { } catch (error) {
@@ -207,13 +207,13 @@ export function securityPatch() {
return; return;
} }
if (bootValue && !isValid6Digit(bootValue)) { if (systemValue && !isValid6Digit(systemValue)) {
showPrompt('security_patch.invalid_boot', false); showPrompt('security_patch.invalid_system', false);
return; return;
} }
if (systemValue && !isValidDateFormat(systemValue)) { if (bootValue && !isValidDateFormat(bootValue)) {
showPrompt('security_patch.invalid_system', false); showPrompt('security_patch.invalid_boot', false);
return; return;
} }
@@ -224,13 +224,13 @@ export function securityPatch() {
try { try {
const config = [ const config = [
bootValue ? `boot=${bootValue}` : '',
systemValue ? `system=${systemValue}` : '', systemValue ? `system=${systemValue}` : '',
bootValue ? `boot=${bootValue}` : '',
vendorValue ? `vendor=${vendorValue}` : '' vendorValue ? `vendor=${vendorValue}` : ''
].filter(Boolean); ].filter(Boolean);
await execCommand(` await execCommand(`
sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch
echo "${config.join(' ')}" > /data/adb/tricky_store/security_patch.txt echo "${config.filter(Boolean).join('\n')}" > /data/adb/tricky_store/security_patch.txt
`); `);
allPatchInput.value = ''; allPatchInput.value = '';
showPrompt('security_patch.save_success'); showPrompt('security_patch.save_success');