remove-authvalue-from-page-config

This commit is contained in:
mediabot-pt
2026-07-06 12:15:40 +08:00
parent 7042149a13
commit 02b7278c8c
2 changed files with 5 additions and 11 deletions

View File

@@ -37,7 +37,6 @@ public class SitePagesServiceImpl implements SitePagesService {
result.put("version", sp.getVersion());
result.put("entries", parsed.getOrDefault("entries", List.of()));
if (parsed.containsKey("authType")) result.put("authType", parsed.get("authType"));
if (parsed.containsKey("authValue")) result.put("authValue", parsed.get("authValue"));
result.put("updatedAt", sp.getUpdatedAt());
return result;
} catch (Exception e) {
@@ -65,7 +64,6 @@ public class SitePagesServiceImpl implements SitePagesService {
Map<String, Object> full = new LinkedHashMap<>();
full.put("entries", entries);
if (authType != null && !"NONE".equals(authType)) full.put("authType", authType);
if (authValue != null && !authValue.isBlank()) full.put("authValue", authValue);
String json = om.writerWithDefaultPrettyPrinter().writeValueAsString(full);
// 版本号递增
String currentVer = getVersion(siteId);

View File

@@ -69,8 +69,8 @@
<el-option label="X-API-Key" value="API_KEY"/>
<el-option label="自定义" value="HEADER"/>
</el-select>
<el-input v-if="authType==='API_KEY'" v-model="authValue" size="small" placeholder="API Key值或占位符" @input="syncAuth" style="flex:1;max-width:250px"/>
<el-input v-if="authType==='HEADER'" v-model="authValue" size="small" placeholder="完整header,如 Authorization: Bearer {token}" @input="syncAuth" style="flex:1;max-width:380px"/>
<span v-if="authType==='API_KEY'" style="color:#909399;font-size:12px">API Key 由外部传入,无需配置值</span>
<span v-if="authType==='HEADER'" style="color:#909399;font-size:12px">Header 由外部传入,无需配置值</span>
<span v-if="authType==='COOKIE'" style="color:#909399;font-size:12px">mediabo 管理 cookie 生命周期</span>
</div>
</div>
@@ -106,7 +106,7 @@ import api from '../api'; import { Refresh } from '@element-plus/icons-vue'
const loading = ref(false), saving = ref(false), uploading = ref(false), deleting = ref(false), sites = ref([]), pagesMap = ref({}), sitesList = ref([])
const editSiteId = ref(''), editorJson = ref('{}')
const authType = ref('NONE'), authValue = ref('')
const authType = ref('NONE')
const defaultTypes = ['nexusphp','mtorrent','gazelle','unit3d']
const isDefaultEditor = computed(() => editSiteId.value.startsWith('default:'))
const pageKeys = ref([])
@@ -126,14 +126,11 @@ const parsed = computed(() => { try { return JSON.parse(editorJson.value).entrie
const syncAuth = () => {
const obj = (() => { try { return JSON.parse(editorJson.value) } catch { return {} } })()
obj.authType = authType.value
if (authType.value !== 'NONE') obj.authValue = authValue.value
else delete obj.authValue
obj.entries = parsed.value
editorJson.value = JSON.stringify(obj, null, 2)
}
const syncToJson = () => {
const obj = { authType: authType.value, entries: parsed.value }
if (authType.value !== 'NONE') obj.authValue = authValue.value
editorJson.value = JSON.stringify(obj, null, 2)
}
const resolveUrl = (url) => url?.replace('{base}', sitesList.value.find(s=>s.siteId===editSiteId.value)?.urls?.[0] || '{base}') || ''
@@ -169,8 +166,7 @@ const editPage = async (row) => {
const r = await api.raw.get(url)
const data = r?.data || r
authType.value = data?.authType || 'NONE'
authValue.value = data?.authValue || ''
editorJson.value = JSON.stringify({ authType: authType.value, authValue: authValue.value || undefined, entries: data?.entries || [] }, null, 2)
editorJson.value = JSON.stringify({ authType: authType.value, entries: data?.entries || [] }, null, 2)
} catch { editorJson.value = JSON.stringify({ authType:'NONE', entries:[] }, null, 2) }
}
@@ -200,7 +196,7 @@ const savePages = async () => {
const url = editSiteId.value.startsWith('default:')
? '/admin/default-pages/' + editSiteId.value.replace('default:','')
: '/sites/' + editSiteId.value + '/pages'
await api.raw.put(url, { entries: parsed.value, authType: authType.value, authValue: authType.value!=='NONE'?authValue.value:null })
await api.raw.put(url, { entries: parsed.value, authType: authType.value })
ElMessage.success('已保存'); editSiteId.value=''; fetchAll()
} catch { ElMessage.error('保存失败') }
finally { saving.value = false }