From d395bd40852429a9700f876f99b5204621414cb1 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 31 May 2022 09:55:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A1=E6=9D=91=E7=9B=B8=E5=86=8C=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/serve.js | 15 ++++++++++++--- src/common/axios.js | 3 ++- src/pages/login.vue | 9 ++++++--- src/store/index.js | 2 ++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/bin/serve.js b/bin/serve.js index 1db3957b..59be85ff 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -14,14 +14,23 @@ const getFileInfo = (app, file) => { if (/^App/.test(app.name)) { let {name, label} = app, path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/apps/$1/$2`) - apps.list.push({id: file.replace(/\.\/?(vue)?/g, '')?.replace(/[\\\/]/g,'_'), name, label, path, libPath: file.replace(/\\/g, '/').replace(/^src(\/.+)\.vue/, '$1'), type: 'wxwork'}) + apps.list.push({ + id: file.replace(/\.\/?(vue)?/g, '')?.replace(/[\\\/]/g, '_'), + name, + label, + path, + libPath: file.replace(/\\/g, '/').replace(/^src(\/.+)\.vue/, '$1'), + type: 'wxwork' + }) } } const saveApps = app => { if (app.list.length > 0) { - axios.post("http://192.168.1.87:12525/node/wechatapps/addOrUpdate", app).then(res => { + axios.post("http://192.168.1.87:12525/node/wechatapps/addOrUpdate", app, {timeout: 1000}).then(res => { if (res.code == 0) chalkTag.done("产品库目录已同步至后台数据库...") - }).catch(() => 0) + }).catch(err => { + console.log(err) + }) } } diff --git a/src/common/axios.js b/src/common/axios.js index 61c0c61e..148bd9da 100644 --- a/src/common/axios.js +++ b/src/common/axios.js @@ -10,7 +10,8 @@ let instance = axios.create({ }) instance.interceptors.request.use(config => { store.commit('initWaterMarker') - if (/AppCountryAlbum/.test(location.pathname)) { + console.log(config) + if (/AppCountryAlbum/.test(location.pathname)||config.module=='AppCountryAlbum') { config.baseURL = '/aca' config.url = config.url.replace(/(app|auth|admin)\//, "api/") } else if (/\/node\//.test(config.url)) { diff --git a/src/pages/login.vue b/src/pages/login.vue index 066d76b9..890873d0 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -32,9 +32,11 @@ export default { target() { return decodeURIComponent(this.$route.query.back) || "" }, + currentApp() { + return this.apps.find(e => this.target.indexOf(e.libPath) > -1) || {} + }, appPath() { - let app = this.apps.find(e => this.target.indexOf(e.libPath) > -1) - return app?.label || "" + return this.currentApp?.label || "" } }, data() { @@ -48,7 +50,8 @@ export default { handleLogin() { this.$refs.loginForm.validate(v => { if (v) { - this.getToken(this.form).then(() => { + let {name: module} = this.currentApp + this.getToken({...this.form, module}).then(() => { this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) }).catch(() => 0) } diff --git a/src/store/index.js b/src/store/index.js index 7dd601b9..4aea6ee6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -179,9 +179,11 @@ const store = new Vuex.Store({ return encrypted.toString(); } } + let {module} = params return new Promise((resolve, reject) => { http.post("/auth/oauth/token", null, { withoutToken: true, + module, params: { ...params, grant_type: 'password', password: encryptByDES(params.password)