feat: allow setting default server via env (#854)

pull/868/head
Daniel Roe 2023-01-07 13:38:31 -08:00 zatwierdzone przez GitHub
rodzic 697a88ac3d
commit 57fd9aeae2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -1,4 +1,5 @@
NUXT_PUBLIC_TRANSLATE_API=
NUXT_PUBLIC_DEFAULT_SERVER=
# Production only
NUXT_CLOUDFLARE_ACCOUNT_ID=

Wyświetl plik

@ -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,

Wyświetl plik

@ -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

Wyświetl plik

@ -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'

Wyświetl plik

@ -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',

Wyświetl plik

@ -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()