From 2755a35548ecd2c0a04664dc597b1dd92d3d50b0 Mon Sep 17 00:00:00 2001 From: flashily Date: Thu, 27 Mar 2025 00:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0run=20local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/.env.local | 8 ++++++ main/manager-web/package.json | 1 + main/manager-web/src/apis/api.js | 3 ++- main/manager-web/src/views/login.vue | 39 ++++++++++++++++++---------- 4 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 main/manager-web/.env.local diff --git a/main/manager-web/.env.local b/main/manager-web/.env.local new file mode 100644 index 000000000..7ff265bcf --- /dev/null +++ b/main/manager-web/.env.local @@ -0,0 +1,8 @@ +/* + * @Description: 本地开发环境 + * @Version: 1.0 + * @Author: flashily + * @LastEditTime: 2025-03-26 + */ +VUE_APP_URL = 'http://localhost:8002/xiaozhi-esp32-api' +/*VUE_APP_SERVER_ID = 1 */ diff --git a/main/manager-web/package.json b/main/manager-web/package.json index fddf19aa4..2fd608aeb 100644 --- a/main/manager-web/package.json +++ b/main/manager-web/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { + "local": "vue-cli-service serve --mode local", "serve": "vue-cli-service serve", "build": "vue-cli-service build" }, diff --git a/main/manager-web/src/apis/api.js b/main/manager-web/src/apis/api.js index 2f789925f..aa812762d 100755 --- a/main/manager-web/src/apis/api.js +++ b/main/manager-web/src/apis/api.js @@ -7,7 +7,8 @@ import admin from './module/admin.js' * 如果你想调用8002端口,就用'/xiaozhi-esp32-api/api/v1',请与vue.config.js的devServer配置相结合,方便跨域请求 * */ -const DEV_API_SERVICE = 'https://apifoxmock.com/m1/5931378-5618560-default' +const DEV_API_SERVICE = process.env.VUE_APP_URL == '' ? 'https://apifoxmock.com/m1/5931378-5618560-default' : process.env.VUE_APP_URL + // 8002开发完成完成后使用这个 // const DEV_API_SERVICE = '/xiaozhi-esp32-api' diff --git a/main/manager-web/src/views/login.vue b/main/manager-web/src/views/login.vue index ef6255e19..fc42f656e 100644 --- a/main/manager-web/src/views/login.vue +++ b/main/manager-web/src/views/login.vue @@ -83,26 +83,37 @@ export default { } }, mounted() { + this.captchaUuid = getUUID(); this.fetchCaptcha(); }, methods: { fetchCaptcha() { - if (this.$store.getters.getToken) { - goToPage('/home') - } else { - this.captchaUuid = getUUID(); + Api.user.getCaptcha(this.captchaUuid, (res) => { + if (res.status === 200) { + const blob = new Blob([res.data], {type: res.data.type}); + this.captchaUrl = URL.createObjectURL(blob); - Api.user.getCaptcha(this.captchaUuid, (res) => { - if (res.status === 200) { - const blob = new Blob([res.data], {type: res.data.type}); - this.captchaUrl = URL.createObjectURL(blob); + } else { + console.error('验证码加载异常:', error); + showDanger('验证码加载失败,点击刷新') + } + }); + // if (this.$store.getters.getToken) { + // // goToPage('/home') + // } else { + // this.captchaUuid = getUUID(); - } else { - console.error('验证码加载异常:', error); - showDanger('验证码加载失败,点击刷新') - } - }); - } + // Api.user.getCaptcha(this.captchaUuid, (res) => { + // if (res.status === 200) { + // const blob = new Blob([res.data], {type: res.data.type}); + // this.captchaUrl = URL.createObjectURL(blob); + + // } else { + // console.error('验证码加载异常:', error); + // showDanger('验证码加载失败,点击刷新') + // } + // }); + // } }, // 封装输入验证逻辑