├── public ├── favicon.ico ├── assets │ ├── logo.png │ ├── ships.png │ ├── teapot.png │ ├── suns │ │ └── sun-0.png │ ├── planets │ │ ├── dry-0.png │ │ ├── barren-0.png │ │ ├── lava-0.png │ │ ├── rings-0.png │ │ ├── continental-0.png │ │ └── gas-giant-0.png │ ├── nebulae │ │ └── nebula-0.png │ ├── special │ │ └── wormhole.png │ ├── asteroids │ │ ├── asteroid-0.png │ │ ├── asteroid-1.png │ │ ├── asteroid-2.png │ │ ├── asteroid-3.png │ │ ├── asteroid-4.png │ │ └── asteroid-5.png │ └── manufacturers │ │ ├── zetra.png │ │ ├── electrum.png │ │ ├── gravager.png │ │ └── jackshaw.png └── index.html ├── babel.config.js ├── vue.config.js ├── src ├── plugins │ ├── vue-timeago.js │ ├── vue-axios.js │ ├── vue-chimera.js │ └── vuetify.js ├── views │ ├── Home.vue │ ├── systems │ │ ├── List.vue │ │ └── View.vue │ ├── Ships.vue │ ├── Loans.vue │ └── Market.vue ├── main.js ├── utils │ ├── orbital.js │ └── text.js ├── components │ ├── locations │ │ ├── Nebula.vue │ │ ├── Special.vue │ │ ├── Asteroid.vue │ │ ├── Planet.vue │ │ ├── Sun.vue │ │ └── PlanetRings.vue │ ├── ShipImage.vue │ ├── SelectLocation.vue │ ├── LocationImage.vue │ ├── Login.vue │ ├── Shipyard.vue │ ├── MarketSell.vue │ ├── MarketBuy.vue │ ├── ShipPurchase.vue │ └── ShipListItem.vue ├── router │ └── index.js ├── store │ └── index.js └── App.vue ├── .gitignore ├── CREDITS.md ├── .github └── workflows │ └── main.yml ├── README.md ├── LICENSE.txt └── package.json /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /public/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/logo.png -------------------------------------------------------------------------------- /public/assets/ships.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/ships.png -------------------------------------------------------------------------------- /public/assets/teapot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/teapot.png -------------------------------------------------------------------------------- /public/assets/suns/sun-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/suns/sun-0.png -------------------------------------------------------------------------------- /public/assets/planets/dry-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/planets/dry-0.png -------------------------------------------------------------------------------- /public/assets/nebulae/nebula-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/nebulae/nebula-0.png -------------------------------------------------------------------------------- /public/assets/planets/barren-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/planets/barren-0.png -------------------------------------------------------------------------------- /public/assets/planets/lava-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/planets/lava-0.png -------------------------------------------------------------------------------- /public/assets/planets/rings-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/planets/rings-0.png -------------------------------------------------------------------------------- /public/assets/special/wormhole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/special/wormhole.png -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | publicPath: '/', 3 | 4 | transpileDependencies: [ 5 | 'vuetify' 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /public/assets/asteroids/asteroid-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/asteroids/asteroid-0.png -------------------------------------------------------------------------------- /public/assets/asteroids/asteroid-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/asteroids/asteroid-1.png -------------------------------------------------------------------------------- /public/assets/asteroids/asteroid-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/asteroids/asteroid-2.png -------------------------------------------------------------------------------- /public/assets/asteroids/asteroid-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/asteroids/asteroid-3.png -------------------------------------------------------------------------------- /public/assets/asteroids/asteroid-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/asteroids/asteroid-4.png -------------------------------------------------------------------------------- /public/assets/asteroids/asteroid-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/asteroids/asteroid-5.png -------------------------------------------------------------------------------- /public/assets/manufacturers/zetra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/manufacturers/zetra.png -------------------------------------------------------------------------------- /public/assets/planets/continental-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/planets/continental-0.png -------------------------------------------------------------------------------- /public/assets/planets/gas-giant-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/planets/gas-giant-0.png -------------------------------------------------------------------------------- /public/assets/manufacturers/electrum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/manufacturers/electrum.png -------------------------------------------------------------------------------- /public/assets/manufacturers/gravager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/manufacturers/gravager.png -------------------------------------------------------------------------------- /public/assets/manufacturers/jackshaw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stumblinbear/Deliverance/HEAD/public/assets/manufacturers/jackshaw.png -------------------------------------------------------------------------------- /src/plugins/vue-timeago.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueTimeago from 'vue-timeago'; 3 | 4 | Vue.use(VueTimeago, { 5 | locale: 'en' 6 | }); -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/plugins/vue-axios.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import axios from 'axios'; 3 | import VueAxios from 'vue-axios'; 4 | import rateLimit from 'axios-rate-limit'; 5 | 6 | const api = rateLimit(axios.create(), { maxRequests: 10, perMilliseconds: 10 * 1000 }); 7 | 8 | Vue.use(VueAxios, api); 9 | 10 | export default api; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /src/plugins/vue-chimera.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueChimera, { MemoryCache } from 'vue-chimera'; 3 | import api from './vue-axios'; 4 | 5 | Vue.use(VueChimera, { 6 | axios: api, 7 | // 5 second cache. Accounts for multiple components requesting the same exact data. 8 | cache: new MemoryCache(5 * 1000), 9 | keepData: true 10 | }); -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | import vuetify from './plugins/vuetify'; 4 | import store from './store'; 5 | import router from './router'; 6 | import './plugins/vue-axios'; 7 | import './plugins/vue-chimera'; 8 | import './plugins/vue-timeago'; 9 | 10 | Vue.config.productionTip = false; 11 | 12 | new Vue({ 13 | vuetify, 14 | store, 15 | router, 16 | render: h => h(App) 17 | }).$mount('#app') 18 | -------------------------------------------------------------------------------- /CREDITS.md: -------------------------------------------------------------------------------- 1 |
Icons made by Freepik from www.flaticon.com
2 | 3 |
Icons made by DinosoftLabs from www.flaticon.com
4 | 5 |
Icons made by Smashicons from www.flaticon.com
-------------------------------------------------------------------------------- /src/plugins/vuetify.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuetify from 'vuetify/lib/framework'; 3 | 4 | Vue.use(Vuetify); 5 | 6 | export default new Vuetify({ 7 | theme: { 8 | dark: true, 9 | /*options: { 10 | customProperties: true, 11 | }, 12 | themes: { 13 | light: { 14 | primary: '#ee44aa', 15 | secondary: '#424242', 16 | accent: '#82B1FF', 17 | error: '#FF5252', 18 | info: '#2196F3', 19 | success: '#4CAF50', 20 | warning: '#FFC107' 21 | }, 22 | },*/ 23 | }, 24 | }); 25 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build Vue 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build_vue: 7 | name: Build Vue 8 | 9 | runs-on: ubuntu-latest 10 | 11 | env: 12 | NODE_OPTIONS: "--openssl-legacy-provider" 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Vue to Github Pages 17 | # You may pin to the exact commit or the version. 18 | # uses: xRealNeon/VuePagesAction@1fe4d0b38025bcbaafa71a359dd5c02f33bb03b7 19 | uses: xRealNeon/VuePagesAction@1.0.0 20 | with: 21 | username: Stumblinbear 22 | reponame: Deliverance 23 | token: ${{ secrets.GITHUB_TOKEN }} 24 | cname: deliverance.forcookies.dev 25 | -------------------------------------------------------------------------------- /src/utils/orbital.js: -------------------------------------------------------------------------------- 1 | export const sortOrbits = { 2 | methods: { 3 | getDistance(location, origin) { 4 | origin = origin ?? { x: 0, y: 0 }; 5 | 6 | return Math.sqrt(Math.pow(location.x - origin.x, 2) + Math.pow(location.y - origin.y, 2)); 7 | }, 8 | 9 | sortOrbits(locations, origin) { 10 | origin = origin ?? { x: 0, y: 0 }; 11 | 12 | const sorted = [ ...locations ]; 13 | 14 | const distances = { }; 15 | 16 | sorted.forEach(location => (distances[location.symbol] = this.getDistance(location, origin))) 17 | 18 | sorted.sort((a, b) => distances[a.symbol] - distances[b.symbol]); 19 | 20 | return sorted; 21 | } 22 | } 23 | }; 24 | 25 | export default sortOrbits; -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Deliverance 9 | 10 | 11 | 12 | 13 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/components/locations/Nebula.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | -------------------------------------------------------------------------------- /src/components/locations/Special.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | -------------------------------------------------------------------------------- /src/components/locations/Asteroid.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deliverance 2 | 3 | Deliverance is a Web UI for the [Space Traders API](https://spacetraders.io). You can access it at [deliverance.forcookies.dev](https://deliverance.forcookies.dev), or get it running yourself locally following the instructions below. 4 | 5 | ## Installation 6 | 7 | 1. Clone the repo 8 | ```sh 9 | git clone https://github.com/Stumblinbear/Deliverance.git 10 | ``` 11 | 2. Install NPM packages 12 | ```sh 13 | npm install 14 | ``` 15 | 3. Start the server 16 | ``` 17 | npm run serve 18 | ``` 19 | 20 | ## Contributing 21 | 22 | 1. Fork the Project 23 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 24 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 25 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 26 | 5. Open a Pull Request 27 | 28 | ## License 29 | 30 | Distributed under the MIT License. See `LICENSE` for more information. 31 | -------------------------------------------------------------------------------- /src/components/locations/Planet.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Othneil Drew 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/utils/text.js: -------------------------------------------------------------------------------- 1 | 2 | export const prettifyEnum = { 3 | methods: { 4 | prettifyEnum(type) { 5 | if(!type) return 'N/A'; 6 | return type.replace('_', ' ').split(' ').map(v => v[0] + v.substring(1).toLowerCase()).join(' '); 7 | } 8 | } 9 | }; 10 | 11 | export const abbreviate = { 12 | methods: { 13 | abbreviate(num) { 14 | if(num === undefined || num === null) return 'N/A'; 15 | if(Number.isNaN(num)) return 'NaN'; 16 | 17 | let abbr = ''; 18 | var rounded = num; 19 | 20 | if(num >= 1e12) { 21 | abbr = ' T'; 22 | rounded = num / 1e12; 23 | }else if(num >= 1e9) { 24 | abbr = ' B'; 25 | rounded = num / 1e9; 26 | }else if(num >= 1e6) { 27 | abbr = ' M'; 28 | rounded = num / 1e6; 29 | }else if(num >= 1e3) { 30 | abbr = 'k'; 31 | rounded = num / 1e3; 32 | } 33 | 34 | return parseFloat(rounded.toFixed(2)) + abbr; 35 | } 36 | } 37 | }; -------------------------------------------------------------------------------- /src/components/locations/Sun.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 24 | 25 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueRouter from 'vue-router'; 3 | 4 | Vue.use(VueRouter) 5 | 6 | const routes = [ 7 | { 8 | path: '/', 9 | name: 'Home', 10 | component: () => import(/* webpackChunkName: "home" */ '../views/Home.vue') 11 | }, { 12 | path: '/systems', 13 | name: 'System List', 14 | component: () => import(/* webpackChunkName: "systems" */ '../views/systems/List.vue') 15 | }, { 16 | path: '/systems/:id', 17 | name: 'System View', 18 | component: () => import(/* webpackChunkName: "systems" */ '../views/systems/View.vue') 19 | }, { 20 | path: '/ships', 21 | name: 'Ships', 22 | component: () => import(/* webpackChunkName: "ships" */ '../views/Ships.vue') 23 | }, { 24 | path: '/loans', 25 | name: 'Loans', 26 | component: () => import(/* webpackChunkName: "loans" */ '../views/Loans.vue') 27 | }, { 28 | path: '/market', 29 | name: 'Market', 30 | component: () => import(/* webpackChunkName: "market-ships" */ '../views/Market.vue') 31 | } 32 | ] 33 | 34 | const router = new VueRouter({ 35 | // mode: 'history', 36 | base: process.env.BASE_URL, 37 | routes 38 | }) 39 | 40 | export default router 41 | -------------------------------------------------------------------------------- /src/components/locations/PlanetRings.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 26 | 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deliverance", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.21.4", 12 | "axios-rate-limit": "^1.3.0", 13 | "core-js": "^3.30.2", 14 | "seedrandom": "^3.0.5", 15 | "vue": "^2.7.14", 16 | "vue-axios": "^3.5.2", 17 | "vue-chimera": "^3.0.2", 18 | "vue-router": "^3.6.5", 19 | "vue-timeago": "^5.1.3", 20 | "vuetify": "^2.6.15", 21 | "vuex": "^3.6.2" 22 | }, 23 | "devDependencies": { 24 | "@vue/cli-plugin-babel": "~4.5.0", 25 | "@vue/cli-plugin-eslint": "~4.5.0", 26 | "@vue/cli-plugin-router": "^4.5.19", 27 | "@vue/cli-plugin-vuex": "^4.5.19", 28 | "@vue/cli-service": "~4.5.0", 29 | "babel-eslint": "^10.1.0", 30 | "eslint": "^6.8.0", 31 | "eslint-plugin-vue": "^6.2.2", 32 | "sass": "^1.62.1", 33 | "sass-loader": "^10.4.1", 34 | "vue-cli-plugin-vuetify": "~2.2.2", 35 | "vue-template-compiler": "^2.7.14", 36 | "vuetify-loader": "^1.9.2" 37 | }, 38 | "eslintConfig": { 39 | "root": true, 40 | "env": { 41 | "node": true 42 | }, 43 | "extends": [ 44 | "plugin:vue/essential", 45 | "eslint:recommended" 46 | ], 47 | "parserOptions": { 48 | "parser": "babel-eslint" 49 | }, 50 | "rules": {} 51 | }, 52 | "browserslist": [ 53 | "> 1%", 54 | "last 2 versions", 55 | "not dead" 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /src/components/ShipImage.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 42 | 43 | -------------------------------------------------------------------------------- /src/views/systems/List.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | -------------------------------------------------------------------------------- /src/components/SelectLocation.vue: -------------------------------------------------------------------------------- 1 | 44 | 45 | -------------------------------------------------------------------------------- /src/components/LocationImage.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | import api from '@/plugins/vue-axios'; 4 | 5 | Vue.use(Vuex); 6 | 7 | const store = new Vuex.Store({ 8 | state: { 9 | outstandingRequests: 0, 10 | 11 | accounts: [ ], 12 | 13 | username: '', 14 | token: '', 15 | 16 | credits: null, 17 | creditsTimeout: null 18 | }, 19 | mutations: { 20 | 21 | }, 22 | actions: { 23 | SET_ACCOUNTS(store, accounts) { 24 | store.state.accounts = accounts; 25 | }, ADD_ACCOUNT(store, [ username, token ]) { 26 | store.state.accounts.push([ username, token ]); 27 | 28 | localStorage.setItem('accounts', JSON.stringify(store.state.accounts)); 29 | }, REMOVE_ACCOUNT(store, [ username, token ]) { 30 | Vue.delete(store.state.accounts, store.state.accounts.findIndex((auth) => auth[0] == username && auth[1] == token)); 31 | 32 | localStorage.setItem('accounts', JSON.stringify(store.state.accounts)); 33 | }, 34 | 35 | SET_AUTH(store, [ username, token ]) { 36 | api.defaults.headers.common['Authorization'] = 'Bearer ' + token; 37 | 38 | store.state.username = username; 39 | store.state.token = token; 40 | 41 | localStorage.setItem('username', username); 42 | localStorage.setItem('token', token); 43 | 44 | if(username != '' && token != '' && !store.state.accounts.some((auth) => auth[0] == username && auth[1] == token)) { 45 | store.dispatch('ADD_ACCOUNT', [ username, token ]); 46 | } 47 | 48 | store.dispatch('UPDATE_CREDITS'); 49 | }, 50 | 51 | async UPDATE_CREDITS(store) { 52 | if(store.state.creditsTimeout != null) 53 | clearTimeout(store.state.creditsTimeout); 54 | 55 | if(store.state.username && store.state.token) { 56 | const data = (await api.get('/users/' + store.state.username)).data; 57 | 58 | store.state.credits = data.user.credits; 59 | 60 | store.state.creditsTimeout = setTimeout(() => store.dispatch('UPDATE_CREDITS'), 10 * 1000); 61 | } 62 | } 63 | } 64 | }); 65 | 66 | api.defaults.baseURL = new URLSearchParams(window.location.search).get('url') || 'https://api.spacetraders.io/v1'; 67 | 68 | if(localStorage.getItem('accounts')) { 69 | store.dispatch('SET_ACCOUNTS', JSON.parse(localStorage.getItem('accounts'))); 70 | } 71 | 72 | if(localStorage.getItem('username') && localStorage.getItem('token')) { 73 | store.dispatch('SET_AUTH', [ localStorage.getItem('username'), localStorage.getItem('token') ]); 74 | } 75 | 76 | function reduceOutstanding() { 77 | // Add a slight delay so the loading spinner looks like a loading spinner 78 | setTimeout(() => { 79 | store.state.outstandingRequests--; 80 | }, 500); 81 | } 82 | 83 | api.interceptors.request.use(req => { store.state.outstandingRequests++; return req; }); 84 | api.interceptors.response.use(res => { reduceOutstanding(); return res; }, 85 | err => { reduceOutstanding(); throw err; }); 86 | 87 | 88 | api.interceptors.response.use(null, err => { 89 | if(err.response && err.response.status == 401) { 90 | store.dispatch('REMOVE_ACCOUNT', [ store.state.username, store.state.token ]); 91 | store.dispatch('SET_AUTH', [ '', '' ]); 92 | return; 93 | } 94 | 95 | throw err; 96 | }); 97 | 98 | export default store; 99 | -------------------------------------------------------------------------------- /src/components/Login.vue: -------------------------------------------------------------------------------- 1 | 100 | 101 | -------------------------------------------------------------------------------- /src/components/Shipyard.vue: -------------------------------------------------------------------------------- 1 | 57 | 58 | -------------------------------------------------------------------------------- /src/components/MarketSell.vue: -------------------------------------------------------------------------------- 1 | 98 | 99 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 136 | 137 | 170 | 171 | -------------------------------------------------------------------------------- /src/components/MarketBuy.vue: -------------------------------------------------------------------------------- 1 | 105 | 106 | -------------------------------------------------------------------------------- /src/views/Ships.vue: -------------------------------------------------------------------------------- 1 | 92 | 93 | -------------------------------------------------------------------------------- /src/views/Loans.vue: -------------------------------------------------------------------------------- 1 | 125 | 126 | -------------------------------------------------------------------------------- /src/components/ShipPurchase.vue: -------------------------------------------------------------------------------- 1 | 121 | 122 | 162 | 163 | -------------------------------------------------------------------------------- /src/views/Market.vue: -------------------------------------------------------------------------------- 1 | 112 | 113 | -------------------------------------------------------------------------------- /src/views/systems/View.vue: -------------------------------------------------------------------------------- 1 | 154 | 155 | 167 | 168 | -------------------------------------------------------------------------------- /src/components/ShipListItem.vue: -------------------------------------------------------------------------------- 1 | 333 | 334 | 341 | 342 | --------------------------------------------------------------------------------