Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2f0c37b4c | |||
| a6533be095 | |||
| 6d6055fa6e | |||
| bf7f8f6992 |
@@ -36,6 +36,23 @@
|
||||
{{ isDarkTheme ? 'Light theme' : 'Dark theme' }}
|
||||
</div>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem
|
||||
v-if="isDisableCacheSupported"
|
||||
v-slot="{ active }"
|
||||
@click="toggleCache"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
active ? 'bg-highlight-1' : '',
|
||||
'my-1 text-body-2xs flex justify-between px-2 py-1 text-foreground cursor-pointer transition mx-1 rounded'
|
||||
]"
|
||||
>
|
||||
<span>Disable Cache</span>
|
||||
<span v-if="isCacheDisabled" class="text-primary font-bold ml-2">✓</span>
|
||||
</div>
|
||||
</MenuItem>
|
||||
|
||||
<div class="border-t border-outline-3 mt-1">
|
||||
<MenuItem v-if="app.$revitMapperBinding" v-slot="{ active }">
|
||||
<button
|
||||
@@ -120,12 +137,40 @@ import { storeToRefs } from 'pinia'
|
||||
import { XMarkIcon, Bars3Icon } from '@heroicons/vue/20/solid'
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
||||
import { useConfigStore } from '~/store/config'
|
||||
import { useHostAppStore } from '~/store/hostApp'
|
||||
|
||||
const app = useNuxtApp()
|
||||
|
||||
const uiConfigStore = useConfigStore()
|
||||
const { isDarkTheme, hasConfigBindings, isDevMode } = storeToRefs(uiConfigStore)
|
||||
const { toggleTheme } = uiConfigStore
|
||||
const { isDarkTheme, hasConfigBindings, isDevMode, isCacheDisabled } =
|
||||
storeToRefs(uiConfigStore)
|
||||
const { toggleTheme, toggleCache } = uiConfigStore
|
||||
|
||||
const hostAppStore = useHostAppStore()
|
||||
const { hostAppName, connectorVersion } = storeToRefs(hostAppStore)
|
||||
|
||||
const isDisableCacheSupported = computed(() => {
|
||||
const appName = hostAppName.value
|
||||
const version = connectorVersion.value
|
||||
|
||||
if (!appName || !version) return false
|
||||
|
||||
// excludes non-sharp connectors (assuming they don't have backend cache bypass)
|
||||
const nonSharpApps = ['sketchup', 'archicad', 'vectorworks']
|
||||
if (nonSharpApps.includes(appName.toLowerCase())) return false
|
||||
|
||||
// always show in dev environments
|
||||
if (version.includes('dev') || version.includes('local')) return true
|
||||
|
||||
// for sharp connectors, check if version is >= 3.18.0
|
||||
const targetVersion = '3.18.0'
|
||||
return (
|
||||
version.localeCompare(targetVersion, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: 'base'
|
||||
}) >= 0
|
||||
)
|
||||
})
|
||||
|
||||
const { $showDevTools, $openUrl } = useNuxtApp()
|
||||
const showAccountsDialog = ref(false)
|
||||
|
||||
@@ -31,6 +31,7 @@ export type GlobalConfig = {
|
||||
|
||||
export type ConnectorConfig = {
|
||||
darkTheme: boolean
|
||||
disableCache?: boolean
|
||||
}
|
||||
|
||||
export type AccountsConfig = {
|
||||
@@ -48,7 +49,7 @@ export class MockedConfigBinding implements IConfigBinding {
|
||||
}
|
||||
|
||||
public async getConfig() {
|
||||
return await { darkTheme: false }
|
||||
return await { darkTheme: false, disableCache: false }
|
||||
}
|
||||
|
||||
public async getGlobalConfig() {
|
||||
|
||||
+13
-2
@@ -8,11 +8,14 @@ export const useConfigStore = defineStore('configStore', () => {
|
||||
|
||||
const userSelectedWorkspaceId = ref<string>()
|
||||
|
||||
const config = ref<ConnectorConfig>({ darkTheme: true })
|
||||
const config = ref<ConnectorConfig>({ darkTheme: true, disableCache: false })
|
||||
|
||||
const isDarkTheme = computed(() => {
|
||||
return config.value?.darkTheme
|
||||
})
|
||||
const isCacheDisabled = computed(() => {
|
||||
return config.value?.disableCache || false
|
||||
})
|
||||
const isDevMode = ref(false)
|
||||
|
||||
const toggleTheme = () => {
|
||||
@@ -20,6 +23,11 @@ export const useConfigStore = defineStore('configStore', () => {
|
||||
$configBinding.updateConfig(config.value)
|
||||
}
|
||||
|
||||
const toggleCache = () => {
|
||||
config.value.disableCache = !config.value.disableCache
|
||||
$configBinding.updateConfig(config.value)
|
||||
}
|
||||
|
||||
const setUserSelectedWorkspace = (workspaceId: string) => {
|
||||
userSelectedWorkspaceId.value = workspaceId
|
||||
try {
|
||||
@@ -33,7 +41,8 @@ export const useConfigStore = defineStore('configStore', () => {
|
||||
|
||||
const init = async () => {
|
||||
if (!$configBinding) return
|
||||
config.value = await $configBinding.getConfig()
|
||||
const fetchedConfig = await $configBinding.getConfig()
|
||||
config.value = { disableCache: false, ...fetchedConfig }
|
||||
const workspacesConfig = await $configBinding.getWorkspacesConfig()
|
||||
if (workspacesConfig && workspacesConfig.userSelectedWorkspaceId) {
|
||||
userSelectedWorkspaceId.value = workspacesConfig.userSelectedWorkspaceId
|
||||
@@ -51,9 +60,11 @@ export const useConfigStore = defineStore('configStore', () => {
|
||||
config,
|
||||
hasConfigBindings,
|
||||
isDarkTheme,
|
||||
isCacheDisabled,
|
||||
isDevMode,
|
||||
userSelectedWorkspaceId,
|
||||
toggleTheme,
|
||||
toggleCache,
|
||||
setUserSelectedWorkspace
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user