ui: use axios as possible

This commit is contained in:
liushuyu 2019-10-21 15:58:30 -06:00 committed by James
parent 91fb88aa98
commit 630f2231ab
5 changed files with 21 additions and 13 deletions

View file

@ -10,7 +10,8 @@ module.exports = {
rules: {
'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-redeclare': 'off'
'no-redeclare': 'off',
'camelcase': 'off'
},
parserOptions: {
parser: 'babel-eslint'

View file

@ -11,6 +11,7 @@
"axios": "^0.19.0",
"buefy": "^0.8.5",
"vue": "^2.6.10",
"vue-axios": "^2.1.5",
"vue-router": "^3.1.3"
},
"devDependencies": {

View file

@ -2,12 +2,14 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import { ajax, stream_ajax as streamAjax } from './helpers'
import VueAxios from 'vue-axios'
import { stream_ajax as streamAjax } from './helpers'
import Buefy from 'buefy'
import 'buefy/dist/buefy.css'
Vue.config.productionTip = false
Vue.use(Buefy)
Vue.use(VueAxios, axios)
// Borrowed from http://tobyho.com/2012/07/27/taking-over-console-log/
function intercept (method) {
@ -64,8 +66,8 @@ function disableShortcuts (e) {
}
// Check to see if we need to enable dark mode
ajax('/api/dark-mode', function (enable) {
if (enable) {
axios.get('/api/dark-mode').then(function (resp) {
if (resp.data === true) {
document.body.classList.add('has-background-black-ter')
}
})
@ -120,7 +122,6 @@ var app = new Vue({
} })
})
},
ajax: ajax,
stream_ajax: streamAjax
}
}).$mount('#app')

View file

@ -18,19 +18,19 @@ export default {
methods: {
download_install_status: function () {
var that = this
this.$root.ajax('/api/installation-status', function (e) {
that.$root.metadata = e
this.$http.get('/api/installation-status').then(function (resp) {
that.$root.metadata = resp.data
that.download_config()
})
},
download_config: function () {
var that = this
this.$root.ajax('/api/config', function (e) {
that.$root.config = e
this.$http.get('/api/config').then(function (resp) {
that.$root.config = resp.data
that.choose_next_state()
}, function (e) {
}).catch(function (e) {
console.error('Got error while downloading config: ' +
e)
@ -83,9 +83,9 @@ export default {
// Need to do a bit more digging to get at the
// install location.
this.$root.ajax('/api/default-path', function (e) {
if (e.path != null) {
app.install_location = e.path
this.$http.get('/api/default-path').then(function (resp) {
if (resp.data.path != null) {
app.install_location = resp.data.path
}
})

View file

@ -8094,6 +8094,11 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.0.tgz#bd76d6a23323e2ca8ffa12028dc04559c75f9019"
integrity sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==
vue-axios@^2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/vue-axios/-/vue-axios-2.1.5.tgz#1af4bf1218ed71309c76afb38d0f683e312c24a7"
integrity sha512-th5xVbInVoyIoe+qY+9GCflEVezxAvztD4xpFF39SRQYqpoKD2qkmX8yv08jJG9a2SgNOCjirjJGSwg/wTrbmA==
vue-eslint-parser@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz#00f4e4da94ec974b821a26ff0ed0f7a78402b8a1"