mirror of
https://forgejo.merr.is/annika/isl-vue3.git
synced 2025-12-11 10:56:31 -05:00
Made Changes To Allow The Base API URL To Be From Config
This commit is contained in:
parent
823455cf78
commit
baf8e0f954
6 changed files with 44 additions and 57 deletions
|
|
@ -1,31 +0,0 @@
|
|||
# This is making minimal changes from the guide at
|
||||
# https://bun.sh/guides/ecosystem/docker (as of 2024-02-04)
|
||||
|
||||
# use the official Bun image
|
||||
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
||||
FROM oven/bun:1-alpine as base
|
||||
WORKDIR /app
|
||||
|
||||
# install dependencies into temp directory
|
||||
# this will cache them and speed up future builds
|
||||
FROM base as install
|
||||
RUN mkdir -p /tmp/dev
|
||||
COPY package.json bun.lockb /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
# install with --production (exclude devDependencies)
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lockb /temp/prod/
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
# ^ Is this necessary? Don't we either need prod or not prod?
|
||||
|
||||
# copy node_modules from temp directory
|
||||
# then copy all (non-ignored) project files into the image
|
||||
FROM base AS prerelease
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY . .
|
||||
|
||||
FROM nginx:stable-alpine as release
|
||||
|
||||
COPY --from=build-stage /app/docker/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -15,6 +15,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.6.5",
|
||||
"axios-retry": "^4.0.0",
|
||||
"pinia": "^2.1.7",
|
||||
"sass": "^1.69.7",
|
||||
"vue": "^3.3.11",
|
||||
|
|
|
|||
3
public/config.json
Normal file
3
public/config.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"apiBaseUrl": "http://localhost:3000"
|
||||
}
|
||||
19
src/main.ts
19
src/main.ts
|
|
@ -12,12 +12,13 @@ import '@mdi/font/css/materialdesignicons.css'
|
|||
import { createVuetify } from 'vuetify'
|
||||
import * as components from 'vuetify/components'
|
||||
import * as directives from 'vuetify/directives'
|
||||
import axios from 'axios'
|
||||
|
||||
const vuetify = createVuetify({
|
||||
components,
|
||||
directives,
|
||||
icons: {
|
||||
defaultSet: 'mdi',
|
||||
defaultSet: 'mdi'
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'dark'
|
||||
|
|
@ -25,9 +26,19 @@ const vuetify = createVuetify({
|
|||
})
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(createPinia())
|
||||
const pinia = createPinia()
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
app.use(vuetify)
|
||||
|
||||
app.mount('#app')
|
||||
// Fetch my config
|
||||
axios
|
||||
.get('/config.json?noCache=' + Date.now())
|
||||
.then((resp) => {
|
||||
app.config.globalProperties.$apiBaseUrl = resp.data.apiBaseUrl
|
||||
|
||||
app.mount('#app')
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,22 @@
|
|||
import type { PowerItem } from '@/types/PowerItem'
|
||||
import axios from 'axios'
|
||||
import axios, { type AxiosRequestConfig } from 'axios'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref, toRaw } from 'vue'
|
||||
import axiosRetry from 'axios-retry'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
|
||||
const BLESSING = 1
|
||||
const INTIMACY = 2
|
||||
const FELLOW = 3
|
||||
|
||||
const noCacheConfig:AxiosRequestConfig = {
|
||||
responseType: "json",
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
'Pragma': 'no-cache',
|
||||
'Expires': '0',
|
||||
}
|
||||
}
|
||||
|
||||
export const usePowerItems = defineStore('powerItems', () => {
|
||||
const BLESSING_POWER_ITEM_STORAGE = 'BLESSING_POWER_ITEM_STORAGE'
|
||||
|
|
@ -11,16 +26,16 @@ export const usePowerItems = defineStore('powerItems', () => {
|
|||
const fellowPowerItems = ref(new Map<string, PowerItem>())
|
||||
const intimacyPowerItems = ref(new Map<string, PowerItem>())
|
||||
const isLoadComplete = ref(false)
|
||||
const apiBaseUrl = getCurrentInstance()?.appContext.config.globalProperties.$apiBaseUrl
|
||||
|
||||
axiosRetry(axios, {
|
||||
retries: 3,
|
||||
retryDelay: axiosRetry.exponentialDelay,
|
||||
})
|
||||
|
||||
async function fetchPowerItems() {
|
||||
axios
|
||||
.get('/items/blessingPowerItems.json', {
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
Expires: '0'
|
||||
}
|
||||
})
|
||||
.get(apiBaseUrl + '/powerItem/byType/' + BLESSING + '/asMap', noCacheConfig)
|
||||
.then((resp) => {
|
||||
const plainMap = new Map<string, PowerItem>(
|
||||
Object.entries(JSON.parse(localStorage.getItem(BLESSING_POWER_ITEM_STORAGE) || '{}'))
|
||||
|
|
@ -36,13 +51,7 @@ export const usePowerItems = defineStore('powerItems', () => {
|
|||
console.log(err)
|
||||
})
|
||||
axios
|
||||
.get('/items/fellowPowerItems.json', {
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
Expires: '0'
|
||||
}
|
||||
})
|
||||
.get(apiBaseUrl + '/powerItem/byType/' + FELLOW + '/asMap', noCacheConfig)
|
||||
.then((resp) => {
|
||||
const plainMap = new Map<string, PowerItem>(
|
||||
Object.entries(JSON.parse(localStorage.getItem(FELLOW_POWER_ITEM_STORAGE) || '{}'))
|
||||
|
|
@ -58,13 +67,7 @@ export const usePowerItems = defineStore('powerItems', () => {
|
|||
console.log(err)
|
||||
})
|
||||
axios
|
||||
.get('/items/intimacyPowerItems.json', {
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
Expires: '0'
|
||||
}
|
||||
})
|
||||
.get(apiBaseUrl + '/powerItem/byType/' + INTIMACY + '/asMap', noCacheConfig)
|
||||
.then((resp) => {
|
||||
const plainMap = new Map<string, PowerItem>(
|
||||
Object.entries(JSON.parse(localStorage.getItem(INTIMACY_POWER_ITEM_STORAGE) || '{}'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue