Skip to content

Commit 898728a

Browse files
committed
Some fixes so both web and local UI windows can connect to API.
1 parent 250e3d1 commit 898728a

File tree

9 files changed

+44
-35
lines changed

9 files changed

+44
-35
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.DS_Store
2-
volume-slider-front/node_modules
2+
/volume-slider-front/node_modules
33
/dist
44
/output
55
/node
@@ -23,3 +23,5 @@ pnpm-debug.log*
2323
*.njsproj
2424
*.sln
2525
*.sw?
26+
bind_windows_amd64.go
27+
windows.syso

config.json

+6-10
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
],
1515
"whitelist": [
1616
{
17-
"appName": "Firefox",
18-
"exeName": "firefox.exe"
17+
"appName": "Master",
18+
"exeName": "master"
1919
},
2020
{
21-
"appName": "FACEIT",
22-
"exeName": "FACEIT.exe"
21+
"appName": "Firefox",
22+
"exeName": "firefox.exe"
2323
},
2424
{
2525
"appName": "Discord",
@@ -30,12 +30,8 @@
3030
"exeName": "Spotify.exe"
3131
},
3232
{
33-
"appName": "Master",
34-
"exeName": "master"
35-
},
36-
{
37-
"appName": "Forza",
38-
"exeName": "ForzaHorizon4.exe"
33+
"appName": "Chrome",
34+
"exeName": "chrome.exe"
3935
}
4036
]
4137
}

volume-slider-front/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11+
"axios": "^0.20.0",
1112
"bootstrap-vue": "^2.1.0",
12-
"core-js": "^3.6.5",
1313
"vue": "^2.6.11",
1414
"vue-router": "^3.2.0",
1515
"vue-slider-component": "^3.2.2",

volume-slider-front/src/components/Sliders.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@
5151
}
5252
},
5353
mounted() {
54+
this.updateHostAddress();
5455
this.fetchAppSliderList();
55-
5656
},
5757
methods: {
5858
...mapActions([
59-
'fetchAppSliderList'
59+
'fetchAppSliderList',
60+
'updateHostAddress',
6061
]),
6162
handleMsg(msg) {
6263
console.log(msg);

volume-slider-front/src/components/appSlider.vue

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import axios from 'axios';
2929
import VueSlider from 'vue-slider-component'
3030
import 'vue-slider-component/theme/antd.css'
31-
import {mapActions, mapGetters} from "vuex";
31+
import {mapActions, mapGetters, mapState} from "vuex";
3232
3333
export default {
3434
name: "appSlider",
@@ -49,6 +49,9 @@
4949
},
5050
},
5151
computed: {
52+
...mapState({
53+
hostAdd: state => state.hostAddress,
54+
}),
5255
...mapGetters([
5356
'getAppSliders'
5457
]),
@@ -80,7 +83,7 @@
8083
'postAppSliderList'
8184
]),
8285
updateSliderData() {
83-
axios.get( '/app-vol/' + this.slider.exeName)
86+
axios.get( this.hostAdd + '/app-vol/' + this.slider.exeName)
8487
.then(response => {
8588
this.value = response.data.volume;
8689
this.disabled = false;
@@ -101,7 +104,7 @@
101104
}
102105
},
103106
setAppVolume(newVol) {
104-
axios.post('/app-vol-set', {
107+
axios.post(this.hostAdd + '/app-vol-set', {
105108
name: this.slider.exeName,
106109
volume: parseInt(newVol)
107110
})

volume-slider-front/src/store/index.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Vue.use(Vuex)
66

77
export default new Vuex.Store({
88
state: {
9+
hostAddress: "",
910
appNames: [
1011
]
1112
},
@@ -14,10 +15,16 @@ export default new Vuex.Store({
1415
},
1516
mutations: {
1617
setAppSliders: (state, nameList) => (state.appNames = nameList),
18+
setHostAddress: (state, add) => (state.hostAddress = add),
1719
},
1820
actions: {
19-
fetchAppSliderList({commit}) {
20-
axios.get( '/slider-list')
21+
updateHostAddress({commit}) {
22+
if (window.location.href.includes('file:///')) {
23+
commit('setHostAddress', 'http://localhost:1323')
24+
}
25+
},
26+
fetchAppSliderList({commit, state}) {
27+
axios.get(state.hostAddress + '/slider-list')
2128
.then(response => {
2229
commit('setAppSliders', response.data)
2330
})
@@ -27,7 +34,7 @@ export default new Vuex.Store({
2734
})
2835
},
2936
postAppSliderList({state}) {
30-
axios.post( '/slider-list', {
37+
axios.post(state.hostAddress + '/slider-list', {
3138
appNames: state.appNames
3239
}).then(r => console.log(r))
3340
},

volume-slider-front/src/views/About.vue

-5
This file was deleted.

volume-slider-front/src/views/Home.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<template>
22
<div class="home">
3-
<HelloWorld msg="Welcome to Your Vue.js App"/>
3+
<Sliders/>
44
</div>
55
</template>
66

77
<script>
88
// @ is an alias to /src
9-
import HelloWorld from '@/components/Sliders.vue'
9+
import Sliders from '@/components/Sliders.vue'
1010
1111
export default {
1212
name: 'Home',
1313
components: {
14-
HelloWorld
14+
Sliders
1515
}
1616
}
1717
</script>

volume-slider-front/yarn.lock

+12-7
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,13 @@ aws4@^1.8.0:
16211621
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2"
16221622
integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==
16231623

1624+
axios@^0.20.0:
1625+
version "0.20.0"
1626+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.20.0.tgz#057ba30f04884694993a8cd07fa394cff11c50bd"
1627+
integrity sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==
1628+
dependencies:
1629+
follow-redirects "^1.10.0"
1630+
16241631
babel-eslint@^10.1.0:
16251632
version "10.1.0"
16261633
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.1.0.tgz#6968e568a910b78fb3779cdd8b6ac2f479943232"
@@ -2952,13 +2959,6 @@ dir-glob@^2.0.0, dir-glob@^2.2.2:
29522959
dependencies:
29532960
path-type "^3.0.0"
29542961

2955-
discord-game@^0.1.1:
2956-
version "0.1.1"
2957-
resolved "https://registry.yarnpkg.com/discord-game/-/discord-game-0.1.1.tgz#88d06f1ea16a2eb4b7c72419a617bc68e2e4fc82"
2958-
integrity sha512-A9Lcd04GqfxIkWFR+o2kDpXSns9aeOV08c7SB2PqvIDKnrEYZzSoDIj5f0Hv3JXxTCrONaAL0CHz9zWsQJD4rQ==
2959-
dependencies:
2960-
bindings "^1.5.0"
2961-
29622962
dns-equal@^1.0.0:
29632963
version "1.0.0"
29642964
resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
@@ -3723,6 +3723,11 @@ follow-redirects@^1.0.0:
37233723
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.12.1.tgz#de54a6205311b93d60398ebc01cf7015682312b6"
37243724
integrity sha512-tmRv0AVuR7ZyouUHLeNSiO6pqulF7dYa3s19c6t+wz9LD69/uSzdMxJ2S91nTI9U3rt/IldxpzMOFejp6f0hjg==
37253725

3726+
follow-redirects@^1.10.0:
3727+
version "1.13.0"
3728+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db"
3729+
integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==
3730+
37263731
for-in@^1.0.2:
37273732
version "1.0.2"
37283733
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"

0 commit comments

Comments
 (0)