remove-authvalue-from-page-config
This commit is contained in:
@@ -37,7 +37,6 @@ public class SitePagesServiceImpl implements SitePagesService {
|
|||||||
result.put("version", sp.getVersion());
|
result.put("version", sp.getVersion());
|
||||||
result.put("entries", parsed.getOrDefault("entries", List.of()));
|
result.put("entries", parsed.getOrDefault("entries", List.of()));
|
||||||
if (parsed.containsKey("authType")) result.put("authType", parsed.get("authType"));
|
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());
|
result.put("updatedAt", sp.getUpdatedAt());
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -65,7 +64,6 @@ public class SitePagesServiceImpl implements SitePagesService {
|
|||||||
Map<String, Object> full = new LinkedHashMap<>();
|
Map<String, Object> full = new LinkedHashMap<>();
|
||||||
full.put("entries", entries);
|
full.put("entries", entries);
|
||||||
if (authType != null && !"NONE".equals(authType)) full.put("authType", authType);
|
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 json = om.writerWithDefaultPrettyPrinter().writeValueAsString(full);
|
||||||
// 版本号递增
|
// 版本号递增
|
||||||
String currentVer = getVersion(siteId);
|
String currentVer = getVersion(siteId);
|
||||||
|
|||||||
@@ -69,8 +69,8 @@
|
|||||||
<el-option label="X-API-Key" value="API_KEY"/>
|
<el-option label="X-API-Key" value="API_KEY"/>
|
||||||
<el-option label="自定义" value="HEADER"/>
|
<el-option label="自定义" value="HEADER"/>
|
||||||
</el-select>
|
</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"/>
|
<span v-if="authType==='API_KEY'" style="color:#909399;font-size:12px">API Key 由外部传入,无需配置值</span>
|
||||||
<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==='HEADER'" style="color:#909399;font-size:12px">Header 由外部传入,无需配置值</span>
|
||||||
<span v-if="authType==='COOKIE'" style="color:#909399;font-size:12px">mediabo 管理 cookie 生命周期</span>
|
<span v-if="authType==='COOKIE'" style="color:#909399;font-size:12px">mediabo 管理 cookie 生命周期</span>
|
||||||
</div>
|
</div>
|
||||||
</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 loading = ref(false), saving = ref(false), uploading = ref(false), deleting = ref(false), sites = ref([]), pagesMap = ref({}), sitesList = ref([])
|
||||||
const editSiteId = ref(''), editorJson = ref('{}')
|
const editSiteId = ref(''), editorJson = ref('{}')
|
||||||
const authType = ref('NONE'), authValue = ref('')
|
const authType = ref('NONE')
|
||||||
const defaultTypes = ['nexusphp','mtorrent','gazelle','unit3d']
|
const defaultTypes = ['nexusphp','mtorrent','gazelle','unit3d']
|
||||||
const isDefaultEditor = computed(() => editSiteId.value.startsWith('default:'))
|
const isDefaultEditor = computed(() => editSiteId.value.startsWith('default:'))
|
||||||
const pageKeys = ref([])
|
const pageKeys = ref([])
|
||||||
@@ -126,14 +126,11 @@ const parsed = computed(() => { try { return JSON.parse(editorJson.value).entrie
|
|||||||
const syncAuth = () => {
|
const syncAuth = () => {
|
||||||
const obj = (() => { try { return JSON.parse(editorJson.value) } catch { return {} } })()
|
const obj = (() => { try { return JSON.parse(editorJson.value) } catch { return {} } })()
|
||||||
obj.authType = authType.value
|
obj.authType = authType.value
|
||||||
if (authType.value !== 'NONE') obj.authValue = authValue.value
|
|
||||||
else delete obj.authValue
|
|
||||||
obj.entries = parsed.value
|
obj.entries = parsed.value
|
||||||
editorJson.value = JSON.stringify(obj, null, 2)
|
editorJson.value = JSON.stringify(obj, null, 2)
|
||||||
}
|
}
|
||||||
const syncToJson = () => {
|
const syncToJson = () => {
|
||||||
const obj = { authType: authType.value, entries: parsed.value }
|
const obj = { authType: authType.value, entries: parsed.value }
|
||||||
if (authType.value !== 'NONE') obj.authValue = authValue.value
|
|
||||||
editorJson.value = JSON.stringify(obj, null, 2)
|
editorJson.value = JSON.stringify(obj, null, 2)
|
||||||
}
|
}
|
||||||
const resolveUrl = (url) => url?.replace('{base}', sitesList.value.find(s=>s.siteId===editSiteId.value)?.urls?.[0] || '{base}') || ''
|
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 r = await api.raw.get(url)
|
||||||
const data = r?.data || r
|
const data = r?.data || r
|
||||||
authType.value = data?.authType || 'NONE'
|
authType.value = data?.authType || 'NONE'
|
||||||
authValue.value = data?.authValue || ''
|
editorJson.value = JSON.stringify({ authType: authType.value, entries: data?.entries || [] }, null, 2)
|
||||||
editorJson.value = JSON.stringify({ authType: authType.value, authValue: authValue.value || undefined, entries: data?.entries || [] }, null, 2)
|
|
||||||
} catch { editorJson.value = JSON.stringify({ authType:'NONE', 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:')
|
const url = editSiteId.value.startsWith('default:')
|
||||||
? '/admin/default-pages/' + editSiteId.value.replace('default:','')
|
? '/admin/default-pages/' + editSiteId.value.replace('default:','')
|
||||||
: '/sites/' + editSiteId.value + '/pages'
|
: '/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()
|
ElMessage.success('已保存'); editSiteId.value=''; fetchAll()
|
||||||
} catch { ElMessage.error('保存失败') }
|
} catch { ElMessage.error('保存失败') }
|
||||||
finally { saving.value = false }
|
finally { saving.value = false }
|
||||||
|
|||||||
Reference in New Issue
Block a user