維基百科討論:InPageEdit
新增話題外觀
由For Each ... Next在話題next版可以把配置存檔到meta站,以供全域使用嗎?上作出的最新留言:3 個月前
next版可以把配置存檔到meta站,以供全域使用嗎?
[編輯]v2版可以存到meta的js頁,將配置應用到所有站台。next是個json,不知道怎麼全站配置😂--𝙵𝚘𝚛 𝙴𝚊𝚌𝚑 ... 𝙽𝚎𝚡𝚝 2025年12月7日 (日) 14:07 (UTC)
- @For Each ... Next:在meta global.js加入IPE-next安裝代碼之後再加入:
window.RLQ.push(() => { mw.hook('InPageEdit.ready').add(async (ipe) => { await ipe.preferences.setMany( // 本行以下插入ipe-prefs.json保存的内容,例子: { "pluginStore.registries": [ "https://cdn.jsdelivr.net/npm/ipe-plugin-zhwiki/dist/registry.v1.json" ], "quickEdit.editSummary": "𝑄𝑢𝑖𝑐𝑘 𝑒𝑑𝑖𝑡", "toolboxAlwaysShow": true } // json结束 ); console.log('[InPageEdit] 配置已应用'); }); });
- 當然,這樣會總是覆蓋本地的配置,如果需要可以自己寫一點合併邏輯,例子:
window.RLQ.push(() => { mw.hook('InPageEdit.ready').add(async (ipe) => { // 要全域应用的配置 const newConfig = { "pluginStore.registries": [ "https://cdn.jsdelivr.net/npm/ipe-plugin-zhwiki/dist/registry.v1.json" ], "quickEdit.editSummary": "𝑄𝑢𝑖𝑐𝑘 𝑒𝑑𝑖𝑡", "toolboxAlwaysShow": true }; // 获取本地配置 const currentConfig = await ipe.preferences.getAll(); // 合并 const mergedConfig = {}; for (const [key, newValue] of Object.entries(newConfig)) { const currentValue = currentConfig[key]; // 如果是数组,合并并去重 if (Array.isArray(newValue) && Array.isArray(currentValue)) { mergedConfig[key] = [...new Set([...currentValue, ...newValue])]; } else { // 其他类型使用全域配置 mergedConfig[key] = newValue; } } await ipe.preferences.setMany(mergedConfig); console.log('[InPageEdit] 配置已应用:', mergedConfig); }); });
- --PexEric 2025年12月12日 (五) 18:34 (UTC)
- 說實話挺麻煩了。目前配置導入導出好像是主要用來備份,不知道日後會不會加入自動讀取用戶頁配置的功能,我覺得大概率不會😂。--PexEric 2025年12月12日 (五) 18:34 (UTC)
- 感謝~ 感覺好高端,還是老版本做得比較好😂 𝙵𝚘𝚛 𝙴𝚊𝚌𝚑 ... 𝙽𝚎𝚡𝚝 2025年12月13日 (六) 03:41 (UTC)