Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-system
/
system
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 59323340
authored
Oct 29, 2020
by
冒粤蓉
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix mock config
1 parent
71f5d8fa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
99 deletions
src/App.vue
src/config/config.js
src/main.js
src/services/Base.js
src/utils/http.js
src/App.vue
View file @
5932334
...
@@ -27,8 +27,6 @@
...
@@ -27,8 +27,6 @@
<
script
>
<
script
>
import
{
mapMutations
}
from
'vuex'
;
import
{
mapMutations
}
from
'vuex'
;
import
BaseService
from
'./services/Base'
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
@@ -43,14 +41,6 @@ export default {
...
@@ -43,14 +41,6 @@ export default {
}
}
},
},
created
()
{
created
()
{
const
baseService
=
new
BaseService
();
baseService
.
getBaseConfig
().
then
((
res
)
=>
{
// console.log(res);
const
baseURL
=
res
.
axios
.
baseURL
;
this
.
updateBaseURL
(
baseURL
);
},
(
err
)
=>
{
});
}
}
}
}
</
script
>
</
script
>
...
...
src/config/config.js
View file @
5932334
import
store
from
'@/store/index'
//
import store from '@/store/index'
let
BASE_URL
=
store
.
state
.
baseURL
//
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
// https://oss-config.test.glsx.com.cn/mock/5f8fda237ec90706c0f89d05/service
// https://oss-config.test.glsx.com.cn/mock/5f8fda237ec90706c0f89d05/service
// http://192.168.0.63:8880
// http://192.168.0.63:8880
if
(
!
BASE_URL
)
{
BASE_URL
=
env
===
'development'
?
'http://192.168.0.63:8880'
:
''
}
const
API
=
{
const
API
=
{
getMockConfig
()
{
getMockConfig
()
{
return
MOCK_CONFIG_URL
+
'/test_config'
return
MOCK_CONFIG_URL
+
'/test_config'
},
},
LOGIN_ACTION
:
BASE_URL
+
'/login_action'
LOGIN_ACTION
:
'/login_action'
}
}
const
USER_API
=
{
const
USER_API
=
{
USER_SEARCH
:
BASE_URL
+
'/usercenter/user/search'
,
USER_SEARCH
:
'/usercenter/user/search'
,
USER_SUPER
:
BASE_URL
+
'/usercenter/user/suitableSuperUsers'
,
USER_SUPER
:
'/usercenter/user/suitableSuperUsers'
,
USER_ADD
:
BASE_URL
+
'/usercenter/user/add'
,
USER_ADD
:
'/usercenter/user/add'
,
USER_EDIT
:
BASE_URL
+
'/usercenter/user/edit'
,
USER_EDIT
:
'/usercenter/user/edit'
,
USER_INFO
:
BASE_URL
+
'/usercenter/user/info'
,
USER_INFO
:
'/usercenter/user/info'
,
USER_DELETE
:
BASE_URL
+
'/usercenter/user/delete'
,
USER_DELETE
:
'/usercenter/user/delete'
,
ROLE_SIMPLELIST
:
BASE_URL
+
'/usercenter/role/simplelist'
ROLE_SIMPLELIST
:
'/usercenter/role/simplelist'
}
}
const
ROLE_API
=
{
const
ROLE_API
=
{
ROLE_SEARCH
:
BASE_URL
+
'/usercenter/role/search'
,
ROLE_SEARCH
:
'/usercenter/role/search'
,
ROLE_INFO
:
BASE_URL
+
'/usercenter/role/info'
,
ROLE_INFO
:
'/usercenter/role/info'
,
TENANT_SIMPLELIST
:
BASE_URL
+
'/usercenter/tenant/simplelist'
,
TENANT_SIMPLELIST
:
'/usercenter/tenant/simplelist'
,
ROLE_ADD
:
BASE_URL
+
'/usercenter/role/add'
,
ROLE_ADD
:
'/usercenter/role/add'
,
ROLE_EDIT
:
BASE_URL
+
'/usercenter/role/edit'
,
ROLE_EDIT
:
'/usercenter/role/edit'
,
ROLE_DELETE
:
BASE_URL
+
'/usercenter/role/delete'
,
ROLE_DELETE
:
'/usercenter/role/delete'
,
MENU_TREE
:
BASE_URL
+
'/usercenter/menu/checkedtree'
MENU_TREE
:
'/usercenter/menu/checkedtree'
}
}
const
MENU_API
=
{
const
MENU_API
=
{
MENU_SEARCH
:
BASE_URL
+
'/usercenter/menu/search'
,
MENU_SEARCH
:
'/usercenter/menu/search'
,
MENU_CHILDREN
:
BASE_URL
+
'/usercenter/menu/children'
,
MENU_CHILDREN
:
'/usercenter/menu/children'
,
MENU_ADD
:
BASE_URL
+
'/usercenter/menu/add'
,
MENU_ADD
:
'/usercenter/menu/add'
,
MENU_EDIT
:
BASE_URL
+
'/usercenter/menu/edit'
,
MENU_EDIT
:
'/usercenter/menu/edit'
,
MENU_DELETE
:
BASE_URL
+
'/usercenter/menu/delete'
,
MENU_DELETE
:
'/usercenter/menu/delete'
,
MENU_INFO
:
BASE_URL
+
'/usercenter/menu/info'
,
MENU_INFO
:
'/usercenter/menu/info'
,
MENU_PERMTREE
:
BASE_URL
+
'/usercenter/menu/permtree'
MENU_PERMTREE
:
'/usercenter/menu/permtree'
}
}
const
ORGINIZA_API
=
{
const
ORGINIZA_API
=
{
ORGINIZA_SEARCH
:
BASE_URL
+
'/usercenter/organization/search'
,
ORGINIZA_SEARCH
:
'/usercenter/organization/search'
,
ORGINIZA_CHILDREN
:
BASE_URL
+
'/usercenter/organization/children'
,
ORGINIZA_CHILDREN
:
'/usercenter/organization/children'
,
ORGINIZA_SIMPLElIST
:
BASE_URL
+
'/usercenter/organization/simplelist'
,
ORGINIZA_SIMPLElIST
:
'/usercenter/organization/simplelist'
,
ORGINIZA_TREEORY
:
BASE_URL
+
'/usercenter/organization/orgtree'
,
ORGINIZA_TREEORY
:
'/usercenter/organization/orgtree'
,
ORGINIZA_ADD
:
BASE_URL
+
'/usercenter/organization/add'
,
ORGINIZA_ADD
:
'/usercenter/organization/add'
,
ORGINIZA_EDIT
:
BASE_URL
+
'/usercenter/organization/edit'
,
ORGINIZA_EDIT
:
'/usercenter/organization/edit'
,
ORGINIZA_DELETE
:
BASE_URL
+
'/usercenter/organization/delete'
ORGINIZA_DELETE
:
'/usercenter/organization/delete'
}
}
const
DICT_API
=
{
const
DICT_API
=
{
DICT_SEARCH
:
BASE_URL
+
'/publiccenter/dict/type/search'
,
DICT_SEARCH
:
'/publiccenter/dict/type/search'
,
DICT_ADD
:
BASE_URL
+
'/publiccenter/dict/type/add'
,
DICT_ADD
:
'/publiccenter/dict/type/add'
,
DICT_EDIT
:
BASE_URL
+
'/publiccenter/dict/type/edit'
,
DICT_EDIT
:
'/publiccenter/dict/type/edit'
,
DICT_DELETE
:
BASE_URL
+
'/publiccenter/dict/type/delete'
,
DICT_DELETE
:
'/publiccenter/dict/type/delete'
,
DICTDATA_SEARCH
:
BASE_URL
+
'/publiccenter/dict/data/search'
,
DICTDATA_SEARCH
:
'/publiccenter/dict/data/search'
,
DICTDATA_EXPORT
:
BASE_URL
+
'/publiccenter/dict/data/export'
,
DICTDATA_EXPORT
:
'/publiccenter/dict/data/export'
,
DICTDATA_ADD
:
BASE_URL
+
'/publiccenter/dict/data/add'
,
DICTDATA_ADD
:
'/publiccenter/dict/data/add'
,
DICTDATA_EDIT
:
BASE_URL
+
'/publiccenter/dict/data/edit'
,
DICTDATA_EDIT
:
'/publiccenter/dict/data/edit'
,
DICTDATA_DELETE
:
BASE_URL
+
'/publiccenter/dict/data/delete'
DICTDATA_DELETE
:
'/publiccenter/dict/data/delete'
}
}
const
WORKLOG_API
=
{
const
WORKLOG_API
=
{
WORKLOG_SEARCH
:
BASE_URL
+
'/loggincenter/loggin/search'
,
WORKLOG_SEARCH
:
'/loggincenter/loggin/search'
,
WORKLOG_EXPORT
:
BASE_URL
+
'/loggincenter/loggin/export'
WORKLOG_EXPORT
:
'/loggincenter/loggin/export'
}
}
export
{
API
,
USER_API
,
ROLE_API
,
ORGINIZA_API
,
DICT_API
,
WORKLOG_API
,
MENU_API
}
export
{
API
,
USER_API
,
ROLE_API
,
ORGINIZA_API
,
DICT_API
,
WORKLOG_API
,
MENU_API
}
src/main.js
View file @
5932334
...
@@ -44,8 +44,6 @@ function render({ data = {} , container } = {}) {
...
@@ -44,8 +44,6 @@ function render({ data = {} , container } = {}) {
if
(
!
window
.
__POWERED_BY_QIANKUN__
)
{
if
(
!
window
.
__POWERED_BY_QIANKUN__
)
{
render
();
render
();
}
}
//测试全局变量污染
console
.
log
(
'window.a'
,
window
.
a
)
export
async
function
bootstrap
()
{
export
async
function
bootstrap
()
{
console
.
log
(
'vue app bootstraped'
);
console
.
log
(
'vue app bootstraped'
);
...
...
src/services/Base.js
deleted
100644 → 0
View file @
71f5d8f
import
HTTP
from
'@/utils/http'
;
import
{
API
}
from
'@/config/config'
;
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.js
View file @
5932334
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
store
from
'@/store'
;
import
{
debounce
}
from
'./tools'
;
import
{
checkStatus
,
showLoading
}
from
'./checkStatus'
;
import
{
checkStatus
,
showLoading
}
from
'./checkStatus'
;
const
instance
=
axios
.
create
({
// 创建axios实例,在这里可以设置请求的默认配置
const
instance
=
axios
.
create
({
// 创建axios实例,在这里可以设置请求的默认配置
...
@@ -81,28 +85,76 @@ instance.interceptors.response.use(response => {
...
@@ -81,28 +85,76 @@ 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/test_config'
;
instance
({
let
baseFlag
=
true
;
url
:
options
.
url
,
const
getBaseUrl
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
BASE_URL
=
store
.
state
.
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
.
commit
(
'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
({
url
:
baseUrl
+
options
.
url
,
method
:
'post'
,
method
:
'post'
,
data
:
JSON
.
stringify
(
options
.
data
)
data
:
JSON
.
stringify
(
options
.
data
)
}).
then
((
res
)
=>
{
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
)
options
.
success
(
res
.
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
options
.
error
(
err
)
options
.
error
(
err
);
})
}
const
HTTP_GET
=
(
baseUrl
,
options
)
=>
{
instance
({
url
:
baseUrl
+
options
.
url
,
method
:
'get'
,
params
:
options
.
data
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
);
}).
catch
((
err
)
=>
{
options
.
error
(
err
);
})
}
export
default
class
HTTP
{
axiosPost
(
options
)
{
getBaseUrl
().
then
((
baseUrl
)
=>
{
HTTP_POST
(
baseUrl
,
options
);
},
(
err
)
=>
{
HTTP_POST
(
''
);
})
})
}
}
axiosGet
(
options
)
{
axiosGet
(
options
)
{
instance
({
getBaseUrl
().
then
((
baseUrl
)
=>
{
url
:
options
.
url
,
HTTP_GET
(
baseUrl
,
options
);
method
:
'get'
,
},
(
err
)
=>
{
params
:
options
.
data
HTTP_GET
(
''
)
}).
then
((
res
)
=>
{
options
.
success
(
res
.
data
);
}).
catch
((
err
)
=>
{
options
.
error
(
err
);
})
})
}
}
}
}
\ No newline at end of file
\ No newline at end of file
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