diff --git a/resources/graphrag.html b/resources/graphrag.html new file mode 100644 index 00000000..169a1e55 --- /dev/null +++ b/resources/graphrag.html @@ -0,0 +1,66 @@ +
+ + + + + + + + diff --git a/resources/js/bridge.js b/resources/js/bridge.js new file mode 100644 index 00000000..f6c0021a --- /dev/null +++ b/resources/js/bridge.js @@ -0,0 +1,36 @@ +;(() => { + let messageId = 0 + const pendingCalls = new Map() + + function api(method, ...args) { + const id = messageId++ + return new Promise((resolve, reject) => { + pendingCalls.set(id, { resolve, reject }) + window.parent.postMessage({ id, type: 'api-call', method, args }, '*') + }) + } + + window.addEventListener('message', (event) => { + if (event.data.type === 'api-response') { + const { id, result, error } = event.data + const pendingCall = pendingCalls.get(id) + if (pendingCall) { + if (error) { + pendingCall.reject(new Error(error)) + } else { + pendingCall.resolve(result) + } + pendingCalls.delete(id) + } + } + }) + + window.api = new Proxy( + {}, + { + get: (target, prop) => { + return (...args) => api(prop, ...args) + } + } + ) +})() diff --git a/resources/js/utils.js b/resources/js/utils.js new file mode 100644 index 00000000..36981ac4 --- /dev/null +++ b/resources/js/utils.js @@ -0,0 +1,5 @@ +export function getQueryParam(paramName) { + const url = new URL(window.location.href) + const params = new URLSearchParams(url.search) + return params.get(paramName) +} diff --git a/resources/minapp.html b/resources/minapp.html index 164ce2e8..f782f790 100644 --- a/resources/minapp.html +++ b/resources/minapp.html @@ -19,22 +19,22 @@ justify-content: space-between; -webkit-app-region: drag; } - .header-right { + #header-left { + margin-left: 10px; + margin-right: auto; + } + #header-center { + color: #fff; + font-size: 14px; + margin-left: 10px; + } + #header-right { margin-left: auto; margin-right: 10px; display: flex; flex-direction: row; align-items: center; } - .header-left { - margin-left: 10px; - margin-right: auto; - } - .header-center { - color: #fff; - font-size: 14px; - margin-left: 10px; - } button { background: none; border: none; @@ -57,9 +57,14 @@