mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-21 17:05:22 +03:00
feat: allow setting default server via env (#854)
This commit is contained in:
parent
697a88ac3d
commit
57fd9aeae2
6 changed files with 5 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
NUXT_PUBLIC_TRANSLATE_API=
|
||||
NUXT_PUBLIC_DEFAULT_SERVER=
|
||||
|
||||
# Production only
|
||||
NUXT_CLOUDFLARE_ACCOUNT_ID=
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import Fuse from 'fuse.js'
|
||||
import { $fetch } from 'ofetch'
|
||||
import { DEFAULT_SERVER } from '~/constants'
|
||||
|
||||
const input = $ref<HTMLInputElement>()
|
||||
let server = $ref<string>('')
|
||||
|
@ -26,7 +25,7 @@ async function oauth() {
|
|||
server = server.split('/')[0]
|
||||
|
||||
try {
|
||||
location.href = await $fetch<string>(`/api/${server || DEFAULT_SERVER}/login`, {
|
||||
location.href = await $fetch<string>(`/api/${server || publicServer.value}/login`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
origin: location.origin,
|
||||
|
|
|
@ -5,7 +5,6 @@ import type { RemovableRef } from '@vueuse/core'
|
|||
import type { ElkMasto, UserLogin } from '~/types'
|
||||
import {
|
||||
DEFAULT_POST_CHARS_LIMIT,
|
||||
DEFAULT_SERVER,
|
||||
STORAGE_KEY_CURRENT_USER,
|
||||
STORAGE_KEY_NOTIFICATION,
|
||||
STORAGE_KEY_NOTIFICATION_POLICY,
|
||||
|
@ -57,7 +56,7 @@ export const currentUser = computed<UserLogin | undefined>(() => {
|
|||
const publicInstance = ref<Instance | null>(null)
|
||||
export const currentInstance = computed<null | Instance>(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value)
|
||||
|
||||
export const publicServer = ref(DEFAULT_SERVER)
|
||||
export const publicServer = ref('')
|
||||
export const currentServer = computed<string>(() => currentUser.value?.server || publicServer.value)
|
||||
|
||||
// when multiple tabs: we need to reload window when sign in, switch account or sign out
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
export const APP_NAME = 'Elk'
|
||||
|
||||
export const DEFAULT_POST_CHARS_LIMIT = 500
|
||||
export const DEFAULT_SERVER = 'mas.to'
|
||||
export const DEFAULT_FONT_SIZE = 'md'
|
||||
|
||||
export const STORAGE_KEY_DRAFTS = 'elk-drafts'
|
||||
|
|
|
@ -95,6 +95,7 @@ export default defineNuxtConfig({
|
|||
env: '', // set in build-info module
|
||||
pwaEnabled: !isDevelopment || process.env.VITE_DEV_PWA === 'true',
|
||||
translateApi: '',
|
||||
defaultServer: 'mas.to',
|
||||
},
|
||||
storage: {
|
||||
driver: isCI ? 'cloudflare' : 'fs',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
const masto = createMasto()
|
||||
publicServer.value = publicServer.value || useRuntimeConfig().public.defaultServer
|
||||
|
||||
if (process.client) {
|
||||
const { query } = useRoute()
|
||||
|
|
Loading…
Reference in a new issue