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: { rules: {
'no-console': 'off', 'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-redeclare': 'off' 'no-redeclare': 'off',
'camelcase': 'off'
}, },
parserOptions: { parserOptions: {
parser: 'babel-eslint' parser: 'babel-eslint'

View File

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

View File

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

View File

@ -18,19 +18,19 @@ export default {
methods: { methods: {
download_install_status: function () { download_install_status: function () {
var that = this var that = this
this.$root.ajax('/api/installation-status', function (e) { this.$http.get('/api/installation-status').then(function (resp) {
that.$root.metadata = e that.$root.metadata = resp.data
that.download_config() that.download_config()
}) })
}, },
download_config: function () { download_config: function () {
var that = this var that = this
this.$root.ajax('/api/config', function (e) { this.$http.get('/api/config').then(function (resp) {
that.$root.config = e that.$root.config = resp.data
that.choose_next_state() that.choose_next_state()
}, function (e) { }).catch(function (e) {
console.error('Got error while downloading config: ' + console.error('Got error while downloading config: ' +
e) e)
@ -83,9 +83,9 @@ export default {
// Need to do a bit more digging to get at the // Need to do a bit more digging to get at the
// install location. // install location.
this.$root.ajax('/api/default-path', function (e) { this.$http.get('/api/default-path').then(function (resp) {
if (e.path != null) { if (resp.data.path != null) {
app.install_location = e.path 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" resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.0.tgz#bd76d6a23323e2ca8ffa12028dc04559c75f9019"
integrity sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw== 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: vue-eslint-parser@^5.0.0:
version "5.0.0" version "5.0.0"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz#00f4e4da94ec974b821a26ff0ed0f7a78402b8a1" resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz#00f4e4da94ec974b821a26ff0ed0f7a78402b8a1"