Initial commit from monorepo

This commit is contained in:
Ruslan Bakiev
2026-01-07 09:10:35 +07:00
commit 3db50d9637
371 changed files with 43223 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
export default defineNuxtPlugin(() => {
const loadChatwoot = () => {
if (document.getElementById('chatwoot-sdk')) return
const baseUrl = 'https://chatwoot.optovia.ru'
const script = document.createElement('script')
script.id = 'chatwoot-sdk'
script.src = `${baseUrl}/packs/js/sdk.js`
script.async = true
script.defer = true
script.onload = () => {
window.chatwootSDK?.run({
websiteToken: 'bc668ge3hM5ZpPeUgGEV1ZU9',
baseUrl
})
}
if (document.body) {
document.body.appendChild(script)
} else {
document.addEventListener('DOMContentLoaded', () => {
document.body?.appendChild(script)
}, { once: true })
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadChatwoot, { once: true })
} else {
loadChatwoot()
}
})

View File

@@ -0,0 +1,8 @@
/**
* Server plugin to initialize Logto tokens on SSR.
* Fetches all access tokens and stores in useState for client hydration.
*/
export default defineNuxtPlugin(async () => {
const { initTokens } = useLogtoTokens()
await initTokens()
})

View File

@@ -0,0 +1,15 @@
export default defineNuxtPlugin(() => {
const nuxtApp = useNuxtApp()
const logtoUser = nuxtApp.ssrContext?.event.context.logtoUser ?? null
const orgId = (logtoUser as { organizations?: string[] } | null)?.organizations?.[0] ?? null
const userState = useState('logto-user', () => null)
const orgState = useState<string | null>('logto-org-id', () => null)
if (logtoUser) {
userState.value = logtoUser
}
if (orgId) {
orgState.value = orgId
}
})

17
app/plugins/me.server.ts Normal file
View File

@@ -0,0 +1,17 @@
import { useLocationStore } from '~/stores/location'
export default defineNuxtPlugin(() => {
const nuxtApp = useNuxtApp()
const me = nuxtApp.ssrContext?.event.context.me ?? null
const state = useState('me', () => null)
if (me) {
state.value = me
// Заполнить locationStore сразу на сервере для SSR
const locationStore = useLocationStore()
if (me.activeTeam?.selectedLocation) {
locationStore.setFromUserData(me.activeTeam.selectedLocation)
}
}
})

View File

@@ -0,0 +1,22 @@
import * as Sentry from '@sentry/vue'
export default defineNuxtPlugin((nuxtApp) => {
const config = useRuntimeConfig()
const dsn = config.public.sentryDsn
if (!dsn) {
return
}
Sentry.init({
app: nuxtApp.vueApp,
dsn,
integrations: [
Sentry.browserTracingIntegration({ router: nuxtApp.$router }),
Sentry.replayIntegration()
],
tracesSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0
})
})