Skip to content

Commit 4655bea

Browse files
update
1 parent b171483 commit 4655bea

File tree

11 files changed

+34
-33
lines changed

11 files changed

+34
-33
lines changed

src/boot/axios.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ declare module '@vue/runtime-core' {
1414
// good idea to move this instance creation inside of the
1515
// "export default () => {}" function below (which runs individually
1616
// for each client)
17-
const api = axios.create({ baseURL: 'https://api.example.com' });
17+
const api = axios.create({ baseURL: 'http://localhost:8081/' });
18+
// const api = axios.create({ baseURL: 'http://8.130.101.128:8081/' });
1819

1920
export default boot(({ app }) => {
2021
// for use inside Vue files (Options API) through this.$axios and this.$api

src/components/commandReq.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import axios from 'axios'
1+
import api from 'src/boot/axios'
22
import {LocalStorage} from "quasar";
33

44
export default function commandReq(com,params1,params2) {
5-
return axios.post('http://8.130.101.128:8081/api/file/commands',{
5+
return api.post('/api/file/commands',{
66
command: com.toString(),
77
params: [params1,params2]
88
},{

src/pages/AvatarPage.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515
</template>
1616
<script setup>
17-
import axios from 'axios';
17+
import { api } from 'boot/axios';
1818
import { ref } from 'vue';
1919
import Swal from 'sweetalert2';
2020
import { useRouter } from 'vue-router';
@@ -29,8 +29,8 @@ const selectAvatar = (num) => {
2929
avatar.value = num;
3030
};
3131
const setAvatar = () => {
32-
axios
33-
.post(`http://8.130.101.128:8081/api/avatar?avatar=${avatar.value}`, {}, {
32+
api
33+
.post(`/api/avatar?avatar=${avatar.value}`, {}, {
3434
headers: {
3535
'Authorization': `Bearer ${$q.localStorage.getItem('token')}`,
3636
}

src/pages/ChatPage.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<script setup lang="ts">
3030
import myBg from '../boot/bg.js';
3131
import {onMounted, ref} from 'vue'
32-
import axios from 'axios';
32+
import {api} from 'boot/axios';
3333
import {useRoute} from 'vue-router'
3434
import {useCheckStore} from 'stores/check';
3535
import Swal from 'sweetalert2';
@@ -52,7 +52,7 @@ const config = {
5252
}
5353
5454
// const update = () => {
55-
// axios.post('http://8.130.101.128:8081/api/check', {
55+
// api.post('/api/check', {
5656
// person: route.params.id
5757
// }, config
5858
// ).then((res) => {
@@ -66,7 +66,7 @@ const Profile = (e) => {
6666
}
6767
onMounted(() => {
6868
// setInterval(update, 500);
69-
axios.post('http://8.130.101.128:8081/api/info', {
69+
api.post('/api/info', {
7070
person: route.params.id
7171
}, config
7272
).then((res) => {
@@ -108,7 +108,7 @@ const sendMessage = async () => {
108108
})
109109
return
110110
}
111-
await axios.post('http://8.130.101.128:8081/api/chat', {
111+
await api.post('/api/chat', {
112112
content: message.value,
113113
receiver: route.params.id
114114
}, config

src/pages/EditorPage.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import Editor from '../components/EditorComponent.vue'
3131
import commandReq from 'components/commandReq';
3232
import {ref, onMounted} from 'vue';
33-
import axios from 'axios';
33+
import {api} from 'boot/axios';
3434
import Swal from 'sweetalert2'
3535
import {useQuasar} from 'quasar';
3636
@@ -142,7 +142,7 @@ const save = () => {
142142
filename: selectFolder.value + '/' + selectFile.value,
143143
//time: new Date().getTime()
144144
});
145-
axios.post('http://8.130.101.128:8081/api/file/save', json, {
145+
api.post('/api/file/save', json, {
146146
headers: {
147147
'Content-Type': 'application/json',
148148
'Authorization': `Bearer ${$q.localStorage.getItem('token')}`
@@ -290,13 +290,13 @@ const imgAdd = (pos, file) => {
290290
console.log(file);
291291
const formData = new FormData()
292292
formData.append('image', file);
293-
axios.post('http://8.130.101.128:8081/api/upload', formData, {
293+
api.post('/api/upload', formData, {
294294
headers: {
295295
'Authorization': `Bearer ${$q.localStorage.getItem('token')}`,
296296
'content-type': 'multipart/form-data'
297297
}
298298
}).then((res) => {
299-
const url = `http://8.130.101.128:8081/api/file/get?filename=${res.data.message}`;
299+
const url = `/api/file/get?filename=${res.data.message}`;
300300
content.value = content.value.replace(/!\[[^\]]+\]\([^)]+\)/, `![](${url})`);
301301
})
302302
}

src/pages/ListPage.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import {ref} from 'vue'
2828
import {useRouter} from 'vue-router';
2929
import {useCheckStore} from 'stores/check';
30-
import axios from "axios";
30+
import {api} from 'boot/axios';
3131
3232
import {useQuasar} from 'quasar';
3333
const $q = useQuasar()
@@ -53,7 +53,7 @@ const time = (time) => {
5353
const router = useRouter();
5454
const list = ref();
5555
const token = $q.localStorage.getItem('token');
56-
axios.post('http://8.130.101.128:8081/api/info', '', {
56+
api.post('/api/info', '', {
5757
headers: {
5858
'Authorization': `Bearer ${token}`,
5959
'Content-Type': 'application-json'

src/pages/LoginPage.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525
</template>
2626
<script setup>
27-
import axios from 'axios';
27+
import {api} from 'boot/axios';
2828
import {ref} from 'vue';
2929
import Swal from 'sweetalert2';
3030
import {useRouter} from 'vue-router';
@@ -42,8 +42,8 @@ const login = () => {
4242
title: 'Please fill out all required fields.',
4343
icon: 'error',
4444
});
45-
else axios
46-
.post('http://8.130.101.128:8081/api/login', {
45+
else api
46+
.post('/api/login', {
4747
username: username.value,
4848
password: password.value,
4949
})
@@ -55,7 +55,7 @@ const login = () => {
5555
$q.localStorage.set('token', res.data.token)
5656
$q.localStorage.set('info', res.data)
5757
const token=res.data.token;
58-
axios.post('http://8.130.101.128:8081/api/info', {
58+
api.post('/api/info', {
5959
person: ''
6060
}, {
6161
headers: {
@@ -67,7 +67,7 @@ const login = () => {
6767
store.info = {...store.info,...res.data.message[store.info.username]};
6868
$q.localStorage.set('info', store.info)
6969
});
70-
axios.post('http://8.130.101.128:8081/api/check?type=all', null, {
70+
api.post('/api/check?type=all', null, {
7171
headers: {
7272
'Authorization': `Bearer ${token}`
7373
}})

src/pages/NewFriends.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
</template>
3030

3131
<script setup>
32+
import {api} from 'boot/axios';
3233
import {useCheckStore} from 'stores/check';
3334
const store = useCheckStore();
3435
import {ref} from 'vue'
35-
import axios from 'axios';
3636
import Swal from 'sweetalert2';
3737
import {useQuasar} from 'quasar';
3838
const $q = useQuasar()
@@ -41,7 +41,7 @@ const search = ref('');
4141
const token = $q.localStorage.getItem('token')
4242
const username = $q.localStorage.getItem('info').username
4343
const request = (atti) => {
44-
axios.post(`http://8.130.101.128:8081/api/newfriends?username=${search.value}&operation=${atti}`, {}, {
44+
api.post(`/api/newfriends?username=${search.value}&operation=${atti}`, {}, {
4545
headers: {
4646
'Authorization': `Bearer ${token}`,
4747
}
@@ -53,7 +53,7 @@ const request = (atti) => {
5353
5454
}
5555
const handle = (req, atti) => {
56-
axios.post(`http://8.130.101.128:8081/api/nfmgr?info=${atti}&username=${req}`, {}, {
56+
api.post(`/api/nfmgr?info=${atti}&username=${req}`, {}, {
5757
headers: {
5858
'Authorization': `Bearer ${token}`,
5959
}
@@ -63,7 +63,7 @@ const handle = (req, atti) => {
6363
icon: res.data.code===200?'success':'error',
6464
});
6565
list.value = list.value.filter((item) => item.username !== req);
66-
axios.post('http://8.130.101.128:8081/api/info', '', {
66+
api.post('/api/info', '', {
6767
headers: {
6868
'Authorization': `Bearer ${token}`,
6969
'Content-Type': 'application-json'
@@ -76,7 +76,7 @@ const handle = (req, atti) => {
7676
7777
}
7878
79-
axios.post('http://8.130.101.128:8081/api/info', '', {
79+
api.post('/api/info', '', {
8080
headers: {
8181
'Authorization': `Bearer ${token}`,
8282
'Content-Type': 'application-json'

src/pages/ProfilePage.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {date, useQuasar} from 'quasar';
3131
import {useCheckStore} from 'stores/check';
3232
import {useRoute, useRouter} from 'vue-router';
3333
import Swal from 'sweetalert2';
34-
import axios from 'axios';
34+
import {api} from 'boot/axios';
3535
3636
const $q = useQuasar();
3737
const store = useCheckStore();
@@ -53,7 +53,7 @@ const token = $q.localStorage.getItem('token')
5353
const delFriend=()=>{
5454
Swal.fire({title:'Are you sure to delete this friend?',text:'You will not be able to recover this friend!',icon:'warning',showCancelButton:true,reverseButtons:true}).then((res)=>{
5555
if(res.isConfirmed) {
56-
axios.post(`http://8.130.101.128:8081/api/newfriends?operation=delete&username=${route.params.id}`,'',{headers:{Authorization:`Bearer ${token}`}}).then((res)=>{
56+
api.post(`/api/newfriends?operation=delete&username=${route.params.id}`,'',{headers:{Authorization:`Bearer ${token}`}}).then((res)=>{
5757
if(res.data.code===200){
5858
Swal.fire('Deleted!','Your friend has been deleted.','success').then(()=>{
5959
router.push('/chat')

src/pages/SignupPage.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</div>
3939
</template>
4040
<script setup>
41-
import axios from 'axios';
41+
import {api} from 'boot/axios';
4242
import {ref} from 'vue';
4343
import Swal from 'sweetalert2';
4444
import {useRouter} from 'vue-router';
@@ -73,8 +73,8 @@ const signup = () => {
7373
icon: 'error',
7474
});
7575
else
76-
axios
77-
.post('http://8.130.101.128:8081/api/signup', {
76+
api
77+
.post('/api/signup', {
7878
username: username.value,
7979
password: password.value,
8080
})

0 commit comments

Comments
 (0)