mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-17 06:30:50 +01:00
refactored extension_protocol_handler. removed all injections in index.html
This commit is contained in:
14
src/config/constants.ts
Normal file
14
src/config/constants.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Application-wide constants
|
||||
*/
|
||||
|
||||
/**
|
||||
* The custom protocol name used for extensions
|
||||
* Must match EXTENSION_PROTOCOL_NAME in Rust (src-tauri/src/extension/core/protocol.rs)
|
||||
*/
|
||||
export const EXTENSION_PROTOCOL_NAME = 'haex-extension'
|
||||
|
||||
/**
|
||||
* Build the full protocol prefix (e.g., "haex-extension://")
|
||||
*/
|
||||
export const EXTENSION_PROTOCOL_PREFIX = `${EXTENSION_PROTOCOL_NAME}://`
|
||||
@ -68,6 +68,7 @@ import {
|
||||
import { useExtensionTabsStore } from '~/stores/extensions/tabs'
|
||||
import type { IHaexHubExtension } from '~/types/haexhub'
|
||||
import { platform } from '@tauri-apps/plugin-os'
|
||||
import { EXTENSION_PROTOCOL_NAME, EXTENSION_PROTOCOL_PREFIX } from '~/config/constants'
|
||||
|
||||
definePageMeta({
|
||||
name: 'haexExtension',
|
||||
@ -151,10 +152,10 @@ const getExtensionUrl = (extension: IHaexHubExtension) => {
|
||||
|
||||
if (os === 'android' || os === 'windows') {
|
||||
// Android/Windows: http://<scheme>.localhost/path
|
||||
schemeUrl = `http://haex-extension.localhost/${encodedInfo}/index.html`
|
||||
schemeUrl = `http://${EXTENSION_PROTOCOL_NAME}.localhost/${encodedInfo}/index.html`
|
||||
} else {
|
||||
// macOS/Linux/iOS: Klassisch scheme://localhost/path
|
||||
schemeUrl = `haex-extension://localhost/${encodedInfo}/index.html`
|
||||
schemeUrl = `${EXTENSION_PROTOCOL_PREFIX}localhost/${encodedInfo}/index.html`
|
||||
}
|
||||
|
||||
return schemeUrl
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { readFile } from '@tauri-apps/plugin-fs'
|
||||
import { EXTENSION_PROTOCOL_PREFIX } from '~/config/constants'
|
||||
|
||||
import type {
|
||||
IHaexHubExtension,
|
||||
@ -86,7 +87,7 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
|
||||
currentExtension.value.version,
|
||||
)
|
||||
|
||||
return `haex-extension://localhost/${encodedInfo}/index.html`
|
||||
return `${EXTENSION_PROTOCOL_PREFIX}localhost/${encodedInfo}/index.html`
|
||||
})
|
||||
|
||||
/* const getExtensionPathAsync = async (
|
||||
|
||||
Reference in New Issue
Block a user