Commit b9bcab4c by 冒粤蓉

portal finish

1 parent 4f3b21dc
{
"name": "glsx-micro-manager-portal",
"name": "micro-system-portal",
"version": "0.1.0",
"private": true,
"scripts": {
......

7.53 KB | W: | H:

17.7 KB | W: | H:

src/assets/images/home-logo.png
src/assets/images/home-logo.png
src/assets/images/home-logo.png
src/assets/images/home-logo.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -25,9 +25,9 @@
.vh-center;
width: 100%;
height: 60px;
padding: 10px 20px;
padding: 10px;
.home-logo-img {
width: 100%;
width: 120px;
}
.home-thumbnail-logo {
width: 80%;
......
......@@ -171,8 +171,8 @@ export default {
// childrenMenuName = breadChildren.menuName || firstChildren.menuName,
// childrenPath = breadChildren.path || firstChildren.menuName || '';
const getBreadCrumb = store.getters.curBreadCrumb;
const breadChildren = getBreadCrumb ? getBreadCrumb.children[0] : firstChildren;
let parentMenuName = getBreadCrumb ? getBreadCrumb.parent.menuName : firstParent.menuName,
const breadChildren = getBreadCrumb.children ? getBreadCrumb.children[0] : firstChildren;
let parentMenuName = getBreadCrumb.parent ? getBreadCrumb.parent.menuName : firstParent.menuName,
childrenMenuName = breadChildren.menuName,
childrenPath = breadChildren.path || firstChildren.path || '';
state.curBreadCrumb.parent['menuName'] = parentMenuName;
......
......@@ -24,6 +24,7 @@
font-size: 20px;
.home-logo-img {
width: 120px;
margin-right: 10px;
}
......
......@@ -29,7 +29,7 @@
<a-form-item class="form-wrapper captcha-wrapper">
<a-input class="login-input" size="large" :max="6" v-model:value="formInline.captcha" placeholder="验证码"></a-input>
<div class="captcha-content" @click="updateCaptcha">
<img class="captcha-img" :src="captchaUrl" alt="验证码" />
<img class="captcha-img" :src="`data:image/jpeg;base64,${captchaUrl}`" alt="验证码" />
</div>
</a-form-item>
<a-form-item class="login-button-wrapper">
......@@ -48,14 +48,14 @@
</template>
<script>
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
import LoginLeftSide from './LoginLeftSide';
import { trimSpace, validate_username,
debounce } from '@/utils/tools/tools';
import LoginService from '@/services/Login';
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
import { reactive, toRefs, getCurrentInstance, computed } from 'vue';
import { useStore } from 'vuex';
import { useRouter } from 'vue-router';
......@@ -70,6 +70,8 @@ export default {
const router = useRouter();
const store = useStore();
const state = reactive({
captchaUrl: '',
captchaId: '', // 后台需要的字段
alertMsg: '',
showAlert: false,
alertArr: [],
......@@ -80,10 +82,26 @@ export default {
captcha: '',
}
});
const loginService = new LoginService();
const getCaptcha = () => {
// 初始化获取验证码
loginService.getCaptchaUrl().then(res => {
if(res.code == 200) {
const resData = res.data;
state.captchaId = resData['Captcha-ID'];
state.captchaUrl = resData['captcha'];
}
}, err => {
})
}
getCaptcha();
// 登录提交验证
const handleSubmit = async () => {
const value = state.formInline,
captchaId = state.captchaId,
{ user, password, captcha } = value;
state.alertArr = [];
......@@ -113,8 +131,7 @@ export default {
return false;
}
const loginService = new LoginService();
const params = { account: user, password, captcha};
const params = { account: user, password, captcha, captchaId};
await loginService.loginAction(params).then((res) => {
if(res.code === 200) {
const { token, user } = res.data;
......@@ -134,19 +151,14 @@ export default {
};
const captchaUrl = computed(() => {
const getBaseUrlFromStorage = localStorage.getItem('BASE_URL');
return `${store.getters.baseURL || getBaseUrlFromStorage}/usercenter/captcha?rand=${state.randomVal}`;
})
// 点击刷新验证码
const updateCaptcha = debounce(() => {
state.randomVal = Date.now();
getCaptcha();
}, 1000, true);
return {
...toRefs(state),
handleSubmit,
captchaUrl,
updateCaptcha
}
}
......
import store from '@/store';
import router from '@/router';
let defaultApp = null;
const isDev = process.env.NODE_ENV === 'development';
const apps = [
/**
* name: 微应用名称 - 具有唯一性
* entry: 微应用入口 - 通过该地址加载微应用
* container: 微应用挂载节点 - 微应用加载完成后将挂载在该节点上
* activeRule: 微应用触发的路由规则 - 触发路由规则后将加载该微应用
*/
{
name: "GLSXManagementSystemSub",
entry: isDev ? "//localhost:10200" : '',
container: "#sub-system-frame",
activeRule: "/system",
props: {
data: {
store,
router,
}
}
}
];
export default apps;
\ No newline at end of file
import qianKunStart from './index';
import store from '@/store';
import BaseService from '@/services/Base';
import { getStorageToken } from '@/utils/storage/user';
......@@ -14,7 +15,20 @@ const microAppStart = () => {
// 处理token状态共享
store.dispatch('app/setToken', token);
}
qianKunStart();
}
export default microAppStart
\ No newline at end of file
const getBaseService = new BaseService();
getBaseService.getMockConfig().then(res => {
const resData = res.axios,
resBaseURL = resData.baseURL,
resSubApps = resData.subAppRegisterConfig;
// 全局接口url配置
store.dispatch('app/updateBaseURL', resBaseURL);
localStorage.setItem('BASE_URL', resBaseURL);
// 子应用注册配置
qianKunStart(resSubApps);
}, err => {
})
}
export default microAppStart
\ No newline at end of file
import { registerMicroApps, start, addGlobalUncaughtErrorHandler, setDefaultMountApp, initGlobalState } from 'qiankun';
import store from '@/store';
import apps from './apps';
import router from '@/router';
// import apps from './apps';
const showLoading = status => {
store.dispatch('app/showLoading', status);
}
registerMicroApps(apps, {
const qianKunStart = (config) => {
const configApps = config.apps;
let apps = []; // 子应用数组盒子
let defaultApp = config.defaultApp; // 默认注册应用路由前缀
configApps.forEach(i => {
apps.push({
name: i.name,
entry: i.entry,
container: '#sub-system-frame',
activeRule: i.activeRule
})
});
// props和container之后也要做动态配置
apps[0].props = {
data: {
store,
router
}
};
registerMicroApps(apps, {
// qiankun 生命周期钩子 - 加载前
beforeLoad: (app) => {
// showLoading(true);
......@@ -21,20 +43,24 @@ registerMicroApps(apps, {
// showLoading(false);
return Promise.resolve();
},
});
});
/**
/**
* 添加全局的未捕获异常处理器
*/
addGlobalUncaughtErrorHandler((event) => {
addGlobalUncaughtErrorHandler((event) => {
const { message: msg } = event;
// 加载失败时提示
if (msg && msg.includes("died in status LOADING_SOURCE_CODE")) {
console.error("子应用加载失败,请检查应用是否可运行");
}
});
});
setDefaultMountApp(defaultApp);
start();
}
setDefaultMountApp('/system');
// 导出 qiankun 的启动函数
export default start;
\ No newline at end of file
export default qianKunStart;
\ No newline at end of file
import HTTP from '@/utils/http/http';
import store from '@/store';
// 获取mock config配置,获取父系统注册子系统的配置和全局接口url配置
const mockConfigURL = store.getters.mockConfigURL;
export default class BaseService extends HTTP {
getMockConfig () {
return new Promise((resolve, reject) => {
this.axiosGet({
url: mockConfigURL,
fullUrl: true,
data: {},
success (data) {
resolve(data);
},
error (error) {
console.log('mock配置接口请求失败');
}
})
});
}
}
......@@ -2,6 +2,21 @@ import HTTP from '@/utils/http/http';
import { API } from '@/config/api';
export default class LoginService extends HTTP {
getCaptchaUrl () {
return new Promise((resolve, reject) => {
this.axiosGet({
url: API.LOGIN_CAPTCHA,
data: {},
success (data) {
resolve(data);
},
error (error) {
console.log('登录获取验证码接口请求失败');
}
})
});
}
loginAction (userInfo) {
return new Promise((resolve, reject) => {
this.axiosPost({
......
const getters = {
token: state => state.app.token,
mockConfigURL: state => state.app.mockConfigURL,
isCollapsed: state => state.app.isCollapsed,
userInfo: state => state.app.userInfo,
baseURL: state => state.app.baseURL,
......
let state = {
baseURL: '',
mockConfigURL: 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/e_sheild_config',
size: 10, // 分页 页大小
token: '',
isCollapsed: false,
......
......@@ -3,6 +3,8 @@ import store from '@/store';
import { checkStatus } from './checkStatus';
// axios.defaults.withCredentials = true;
const instance = axios.create({ //创建axios实例,在这里可以设置请求的默认配置
timeout: 60000, // 设置超时时间60s
retry: 3,
......@@ -14,7 +16,9 @@ instance.defaults.headers.post['Content-Type'] = 'application/json';
/** 添加请求拦截器 **/
instance.interceptors.request.use(config => {
if(localStorage.getItem('token')){
config.headers['Authorization'] = localStorage.getItem('token') || '';
}
// store.dispatch('app/showLoading', true);
return config
}, error => {
......@@ -83,7 +87,8 @@ instance.interceptors.response.use(response => {
})
// 从mock获取基础域名配置
const MOCK_CONFIG_URL = 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/e_sheild_config';
// 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/e_sheild_config'
const MOCK_CONFIG_URL = store.getters.mockConfigURL;
let baseFlag = true;
const getBaseUrl = () => {
return new Promise((resolve, reject) => {
......@@ -116,7 +121,7 @@ const getBaseUrl = () => {
const HTTP_POST = (baseUrl, options) => {
instance({
url: baseUrl + options.url,
url: baseUrl,
method: 'post',
data: JSON.stringify(options.data)
}).then((res) => {
......@@ -128,7 +133,7 @@ const HTTP_POST = (baseUrl, options) => {
const HTTP_GET = (baseUrl, options) => {
instance({
url: baseUrl + options.url,
url: baseUrl,
method: 'get',
params: options.data
}).then((res) => {
......@@ -141,18 +146,26 @@ const HTTP_GET = (baseUrl, options) => {
export default class HTTP {
axiosPost (options) {
if(options.fullUrl) {
HTTP_POST(options.url, options);
} else {
getBaseUrl().then((baseUrl) => {
HTTP_POST(baseUrl, options);
HTTP_POST(baseUrl + options.url, options);
}, (err) => {
HTTP_POST('');
})
}
}
axiosGet (options) {
if(options.fullUrl) {
HTTP_GET(options.url, options);
} else {
getBaseUrl().then((baseUrl) => {
HTTP_GET(baseUrl, options);
HTTP_GET(baseUrl + options.url, options);
}, (err) => {
HTTP_GET('')
})
}
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!