Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-system
/
micro-portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ea0bf46e
authored
Oct 29, 2020
by
冒粤蓉
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix mock config
1 parent
f9b89176
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
48 deletions
src/App.vue
src/config/api.js
src/micro/app-store.js
src/micro/index.js
src/services/Base.js
src/utils/http/http.js
vue.config.js
src/App.vue
View file @
ea0bf46
...
@@ -17,7 +17,7 @@ import Dashboard from '@/views/Dashboard';
...
@@ -17,7 +17,7 @@ import Dashboard from '@/views/Dashboard';
import
Login
from
'@/views/Login'
;
import
Login
from
'@/views/Login'
;
import
Loading
from
'components/Loading/Loading'
;
import
Loading
from
'components/Loading/Loading'
;
import
BaseService
from
'services/Base'
;
//
import BaseService from 'services/Base';
import
{
onCreated
,
onMounted
,
computed
,
reactive
,
toRefs
}
from
'vue'
;
import
{
onCreated
,
onMounted
,
computed
,
reactive
,
toRefs
}
from
'vue'
;
import
{
useStore
}
from
'vuex'
;
import
{
useStore
}
from
'vuex'
;
...
@@ -33,13 +33,13 @@ export default {
...
@@ -33,13 +33,13 @@ export default {
setup
()
{
setup
()
{
const
store
=
useStore
();
const
store
=
useStore
();
const
baseService
=
new
BaseService
();
//
const baseService = new BaseService();
baseService
.
getBaseConfig
().
then
((
res
)
=>
{
//
baseService.getBaseConfig().then((res) => {
const
baseURL
=
res
.
axios
.
baseURL
;
//
const baseURL = res.axios.baseURL;
store
.
dispatch
(
'app/updateBaseURL'
,
baseURL
);
//
store.dispatch('app/updateBaseURL', baseURL);
},
(
err
)
=>
{
//
}, (err) => {
});
//
});
let
hasToken
=
computed
(()
=>
{
let
hasToken
=
computed
(()
=>
{
return
!!
store
.
getters
.
token
;
return
!!
store
.
getters
.
token
;
...
...
src/config/api.js
View file @
ea0bf46
import
store
from
'@/store/index
'
// import store from '@/store
'
let
BASE_URL
=
store
.
state
.
baseURL
;
// const MOCK_CONFIG_URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config';
const
MOCK_CONFIG_URL
=
'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
;
// const env = process.env.NODE_ENV;
const
env
=
process
.
env
.
NODE_ENV
;
if
(
!
BASE_URL
)
{
BASE_URL
=
env
===
'development'
?
'http://192.168.0.63:8880'
:
''
;
}
const
API
=
{
const
API
=
{
getMockConfig
()
{
getMockConfig
()
{
return
MOCK_CONFIG_URL
+
'/e_sheild_config'
;
return
'/e_sheild_config'
;
},
},
LOGIN_CAPTCHA
:
BASE_URL
+
'/usercenter/captcha'
,
// 非接口,直接url可展示验证码
LOGIN_CAPTCHA
:
'/usercenter/captcha'
,
// 非接口,直接url可展示验证码
LOGIN_ACTION
:
BASE_URL
+
'/usercenter/login'
,
// 登录接口
LOGIN_ACTION
:
'/usercenter/login'
,
// 登录接口
MENU_TREE_ACTION
:
BASE_URL
+
'/usercenter/menu/permtree'
,
// 用户登录成功后拉取权限菜单
MENU_TREE_ACTION
:
'/usercenter/menu/permtree'
,
// 用户登录成功后拉取权限菜单
}
}
export
{
export
{
...
...
src/micro/app-store.js
View file @
ea0bf46
src/micro/index.js
View file @
ea0bf46
...
@@ -10,6 +10,10 @@ registerMicroApps(apps, {
...
@@ -10,6 +10,10 @@ registerMicroApps(apps, {
// qiankun 生命周期钩子 - 加载前
// qiankun 生命周期钩子 - 加载前
beforeLoad
:
(
app
)
=>
{
beforeLoad
:
(
app
)
=>
{
showLoading
(
true
);
showLoading
(
true
);
// 超时
setTimeout
(()
=>
{
showLoading
(
false
);
},
10000
)
return
Promise
.
resolve
();
return
Promise
.
resolve
();
},
},
// qiankun 生命周期钩子 - 挂载后
// qiankun 生命周期钩子 - 挂载后
...
...
src/services/Base.js
deleted
100644 → 0
View file @
f9b8917
import
HTTP
from
'@/utils/http/http'
;
import
{
API
}
from
'@/config/api'
;
export
default
class
BaseService
extends
HTTP
{
getBaseConfig
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
axiosGet
({
url
:
API
.
getMockConfig
(),
data
:
{},
success
(
data
)
{
resolve
(
data
);
},
error
(
error
)
{
// 网络请求失败
console
.
log
(
'网络请求失败'
);
// window.location.reload();
}
})
});
}
}
src/utils/http/http.js
View file @
ea0bf46
...
@@ -82,10 +82,40 @@ instance.interceptors.response.use(response => {
...
@@ -82,10 +82,40 @@ instance.interceptors.response.use(response => {
});
});
})
})
export
default
class
HTTP
{
// 从mock获取基础域名配置
axiosPost
(
options
)
{
const
MOCK_CONFIG_URL
=
'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/e_sheild_config'
;
let
baseFlag
=
true
;
const
getBaseUrl
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
BASE_URL
=
store
.
getters
.
baseURL
;
if
(
!
BASE_URL
&&
baseFlag
)
{
instance
({
url
:
MOCK_CONFIG_URL
,
method
:
'get'
}).
then
((
res
)
=>
{
const
resData
=
res
.
data
;
if
(
resData
)
{
const
resBaseURL
=
resData
.
axios
.
baseURL
;
store
.
dispatch
(
'app/updateBaseURL'
,
resBaseURL
);
baseFlag
=
!!
resBaseURL
;
resolve
(
resBaseURL
);
}
else
{
baseFlag
=
true
;
resolve
(
BASE_URL
)
}
}).
catch
((
err
)
=>
{
baseFlag
=
true
;
resolve
(
BASE_URL
)
})
}
else
{
resolve
(
BASE_URL
)
}
})
}
const
HTTP_POST
=
(
baseUrl
,
options
)
=>
{
instance
({
instance
({
url
:
options
.
url
,
url
:
baseUrl
+
options
.
url
,
method
:
'post'
,
method
:
'post'
,
data
:
JSON
.
stringify
(
options
.
data
)
data
:
JSON
.
stringify
(
options
.
data
)
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
...
@@ -93,16 +123,34 @@ export default class HTTP {
...
@@ -93,16 +123,34 @@ export default class HTTP {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
options
.
error
(
err
);
options
.
error
(
err
);
})
})
}
}
axiosGet
(
options
)
{
const
HTTP_GET
=
(
baseUrl
,
options
)
=>
{
instance
({
instance
({
url
:
options
.
url
,
url
:
baseUrl
+
options
.
url
,
method
:
'get'
method
:
'get'
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
);
options
.
success
(
res
.
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
options
.
error
(
err
);
options
.
error
(
err
);
})
})
}
export
default
class
HTTP
{
axiosPost
(
options
)
{
getBaseUrl
().
then
((
baseUrl
)
=>
{
HTTP_POST
(
baseUrl
,
options
);
},
(
err
)
=>
{
HTTP_POST
(
''
);
})
}
axiosGet
(
options
)
{
getBaseUrl
().
then
((
baseUrl
)
=>
{
HTTP_GET
(
baseUrl
,
options
);
},
(
err
)
=>
{
HTTP_GET
(
''
)
})
}
}
}
}
\ No newline at end of file
\ No newline at end of file
vue.config.js
View file @
ea0bf46
...
@@ -38,6 +38,33 @@ module.exports = {
...
@@ -38,6 +38,33 @@ module.exports = {
.
set
(
"config"
,
resolve
(
"src/config"
))
.
set
(
"config"
,
resolve
(
"src/config"
))
.
set
(
"utils"
,
resolve
(
"src/utils"
))
.
set
(
"utils"
,
resolve
(
"src/utils"
))
.
set
(
"services"
,
resolve
(
"src/services"
));
.
set
(
"services"
,
resolve
(
"src/services"
));
// config.module.rule('fonts')
// .use('url-loader')
// .loader('url-loader')
// .options({
// limit: 4096, // 小于4kb将会被打包成 base64
// fallback: {
// loader: 'file-loader',
// options: {
// name: 'fonts/[name].[hash:8].[ext]',
// publicPath
// }
// }
// })
// .end();
// config.module.rule('images')
// .use('url-loader')
// .loader('url-loader')
// .options({
// limit: 4096, // 小于4kb将会被打包成 base64
// fallback: {
// loader: 'file-loader',
// options: {
// name: 'img/[name].[hash:8].[ext]',
// publicPath
// }
// }
// })
},
},
css
:
{
css
:
{
loaderOptions
:
{
loaderOptions
:
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment