fix: move page ai launcher to pi lab
This commit is contained in:
@@ -4624,15 +4624,29 @@
|
||||
|
||||
function installLauncher() {
|
||||
if (piLabLauncherEl) return;
|
||||
piLabLauncherEl = el('button', {
|
||||
type: 'button',
|
||||
className: 'wolai-page-ai-pi-lab-launcher',
|
||||
'data-page-ai-pi-lab-launcher': 'true',
|
||||
title: 'Pi Lab',
|
||||
'aria-label': '打开 Pi Lab',
|
||||
}, 'π');
|
||||
piLabLauncherEl.addEventListener('click', showPiLab);
|
||||
document.body.appendChild(piLabLauncherEl);
|
||||
var hostButton = document.querySelector('[data-mnote-action="open-page-ai-pi-lab"], [data-testid="wolai-floating-ai"]');
|
||||
if (hostButton instanceof HTMLElement) {
|
||||
piLabLauncherEl = hostButton;
|
||||
piLabLauncherEl.setAttribute('data-page-ai-pi-lab-launcher', 'true');
|
||||
piLabLauncherEl.setAttribute('data-mnote-action', 'open-page-ai-pi-lab');
|
||||
piLabLauncherEl.setAttribute('aria-label', '打开 Pi Lab');
|
||||
piLabLauncherEl.setAttribute('title', '打开 Pi Lab');
|
||||
piLabLauncherEl.textContent = 'π';
|
||||
} else {
|
||||
piLabLauncherEl = el('button', {
|
||||
type: 'button',
|
||||
className: 'wolai-page-ai-pi-lab-launcher',
|
||||
'data-page-ai-pi-lab-launcher': 'true',
|
||||
title: 'Pi Lab',
|
||||
'aria-label': '打开 Pi Lab',
|
||||
}, 'π');
|
||||
document.body.appendChild(piLabLauncherEl);
|
||||
}
|
||||
piLabLauncherEl.addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
showPiLab();
|
||||
});
|
||||
}
|
||||
|
||||
function wireEvents() {
|
||||
|
||||
@@ -880,9 +880,9 @@ export function createSidebarPageAiRuntime(context) {
|
||||
|
||||
function pageAiOpencodeHostEnabled() {
|
||||
try {
|
||||
return window.localStorage ? window.localStorage.getItem('mnote.page_ai.opencode_host') !== '0' : true;
|
||||
return window.localStorage ? window.localStorage.getItem('mnote.page_ai.opencode_host') === '1' : false;
|
||||
} catch (_error) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3191,6 +3191,16 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
return;
|
||||
}
|
||||
|
||||
var pageAiPiLabTrigger = closestAction(e.target, '[data-mnote-action="open-page-ai-pi-lab"]');
|
||||
if (pageAiPiLabTrigger) {
|
||||
e.preventDefault();
|
||||
if (window.createSidebarPageAiPiLabRuntime) {
|
||||
window.createSidebarPageAiPiLabRuntime({});
|
||||
}
|
||||
window.postMessage({ source: 'mnote-sidebar', type: 'mnote:pi-lab-show' }, window.location.origin);
|
||||
return;
|
||||
}
|
||||
|
||||
var navigationPageTrigger = closestAction(e.target, '[data-mnote-action="open-navigation-page"]');
|
||||
if (navigationPageTrigger) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user