提交 f7809e95 编写于 作者: tony001's avatar tony001

update:更新

上级 86103fac
import { SyncSeriesHook } from "qx-util";
import { Environment } from "@/environments/environment";
import router from "@/router";
import { OpenViewService } from "@/utils";
import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy, getSessionStorage, Http, AppUtil, NavDataService, INavDataService } from "@core";
import { SyncSeriesHook } from "qx-util";
import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy, getSessionStorage, Http, AppUtil } from "@core";
import { AppFuncConfig, AppViewConfig, AppEntityConfig } from './config';
import { DataServiceRegister, UIServiceRegister } from "./register";
......@@ -123,7 +124,6 @@ export class App extends AppBase implements IApp {
/**
* 获取视图信息
*
* @static
* @param codeName 视图codeName
* @return {*}
*/
......@@ -134,7 +134,6 @@ export class App extends AppBase implements IApp {
/**
* 获取实体信息
*
* @static
* @param codeName 实体codeName
* @return {*}
*/
......@@ -143,12 +142,30 @@ export class App extends AppBase implements IApp {
}
/**
* @description 获取导航数据服务
* @return {*} {*}
* @description 跳转登录页
*
* @memberof App
*/
gotoLoginPage(): void {
const currentRoute = unref(router.currentRoute);
if (Environment.loginUrl) {
window.location.href = `${Environment.loginUrl}?redirect=${window.location.href}`;
} else {
if (Object.is(currentRoute.name, 'login')) {
return;
}
router.push({ name: 'login', query: { redirect: window.location.hash.replace("#", '') } });
}
}
/**
* @description 登录
*
* @return {*} {Promise<IParam>}
* @memberof App
*/
public getNavDataService(): INavDataService {
return NavDataService.getInstance();
handleLogin(): Promise<IParam> {
throw new Error("Method not implemented.");
}
}
\ No newline at end of file
import { IParam, ViewDetail } from "../common";
import { IAppFuncService, IDataServiceRegister, INavDataService, IOpenViewService, IUIServiceRegister } from "../service";
import { IAppFuncService, IOpenViewService } from "../service";
/**
......@@ -100,10 +100,18 @@ export interface IApp {
setAppData(opt: IParam): void;
/**
* @description 获取导航数据服务
* @return {*} {INavDataService}
* @description 跳转登录页
*
* @memberof IApp
*/
gotoLoginPage(): void;
/**
* @description 登录
*
* @return {*} {Promise<IParam>}
* @memberof IApp
*/
getNavDataService(): INavDataService;
handleLogin(): Promise<IParam>;
}
\ No newline at end of file
import { INavDataParam, IParam, ViewDetail } from "@core";
import { Subject } from 'rxjs';
/**
* @description 打开视图服务接口
* @export
* @interface INavDataService
*/
export interface INavDataService {
addNavData(curNavData: INavDataParam): void;
getNavData(): Array<INavDataParam>;
getPreNavData(tag: string): INavDataParam | null;
skipNavData(tag: string): void;
removeNavData(tag: string): void;
removeNavDataFirst(): void;
removeNavDataLast(): void;
removeAllNavData(): void;
}
\ No newline at end of file
......@@ -2,5 +2,4 @@ export * from './i-app-func-service';
export * from './i-app-action-service';
export * from './i-open-view-service';
export * from './i-data-service-register';
export * from './i-ui-service-register';
export * from './i-nav-data-service';
\ No newline at end of file
export * from './i-ui-service-register';
\ No newline at end of file
import { AppFuncService, IApp, IAppFuncService, IOpenViewService, ViewDetail } from "@core";
import { IDataServiceRegister, INavDataService, IParam, IUIServiceRegister } from "@core/interface";
import { IParam } from "@core/interface";
/**
* 应用基类
......@@ -122,11 +122,31 @@ export abstract class AppBase implements IApp {
}
/**
* @description 获取导航数据服务
* @return {*} {INavDataService}
* @description 获取实体信息
*
* @param {string} codeName
* @memberof AppBase
*/
public getEntityInfo(codeName: string) {
throw new Error("Method not implemented.");
}
/**
* @description 跳转登录页
*
* @memberof AppBase
*/
gotoLoginPage(): void {
throw new Error("Method not implemented.");
}
/**
* @description 登录
*
* @return {*} {Promise<IParam>}
* @memberof AppBase
*/
public getNavDataService(): INavDataService {
handleLogin(): Promise<IParam> {
throw new Error("Method not implemented.");
}
}
\ No newline at end of file
......@@ -189,24 +189,6 @@ export class ViewBase {
*/
public useCounterService() { }
/**
* @description 处理视图初始化
*
* @memberof ViewBase
*/
public useViewInit() {
const route = useRoute();
App.getNavDataService().addNavData({title: this.state.viewCaption, viewType: this.state.viewType, path: unref(route.fullPath), openType: this.props.openType, tag: this.state.viewCodeName, key: '', data: {}});
}
/**
* @description 视图销毁
* @memberof ViewBase
*/
public useViewDestroyed() {
// 视图销毁从导航栈里面删除数据
App.getNavDataService().removeNavData(this.state.viewCodeName);
}
/**
* @description 安装视图所有功能模块的方法
......@@ -224,8 +206,6 @@ export class ViewBase {
this.useDataService();
// 使用UI服务
this.useUIService();
// 处理视图初始化
this.useViewInit();
return {
state: this.state
};
......
export * from './navdata-service';
export * from './navdata-param';
\ No newline at end of file
import { IParam } from '@core';
export interface INavDataParam {
/**
* @description 视图标题
* @type {*}
* @memberof INavDataParam
*/
title: string;
/**
* @description 视图数据
* @type {*}
* @memberof INavDataParam
*/
data: IParam;
/**
* @description 视图路径
* @type {string}
* @memberof INavDataParam
*/
path: string;
/**
* @description 视图打开模式("ROUTE" | "MODAL" | "EMBED")
* @type {("ROUTE" | "MODAL" | "EMBED")}
* @memberof INavDataParam
*/
openType: "ROUTE" | "MODAL" | "EMBED";
/**
* @description 视图类型
* @type {string}
* @memberof INavDataParam
*/
viewType: string;
/**
* @description 视图标识
* @type {string}
* @memberof INavDataParam
*/
tag: string;
/**
* @description 数据标识
* @type {*}
* @memberof INavDataParam
*/
key: string;
}
import { IActionParam, INavDataService } from '@core';
import { Subject } from 'rxjs';
import { INavDataParam } from './navdata-param';
/**
* 导航数据服务
*
* @export
* @class CodeListService
*/
export class NavDataService implements INavDataService {
/**
* 单例变量声明
*
* @private
* @static
* @type {NavDataService}
* @memberof NavDataService
*/
private static navDataService: NavDataService;
/**
* 服务状态
*
* @memberof NavDataService
*/
public serviceState: Subject<IActionParam> = new Subject();
/**
* 导航数据栈
*
* @memberof NavDataService
*/
public navDataStack: Array<INavDataParam> = [];
/**
* 初始化实例
*
* @memberof NavDataService
*/
constructor(opts: any = {}) { }
/**
* 获取 NavDataService 单例对象
*
* @static
* @returns {NavDataService}
* @memberof NavDataService
*/
public static getInstance(): NavDataService {
if (!NavDataService.navDataService) {
NavDataService.navDataService = new NavDataService();
}
return this.navDataService;
}
/**
* 添加基础导航数据到栈中
*
* @memberof NavDataService
*/
public addNavData(curNavData: INavDataParam) {
this.navDataStack.push(curNavData);
}
/**
* 设置指定数据到基础导航数据栈中
*
* @memberof NavDataService
*/
public setNavDataByTag(tag: string, isSingleMode: boolean, data: any) {
if (this.navDataStack.length > 0) {
let tempIndex: number = this.navDataStack.findIndex((element: INavDataParam) => {
return Object.is(element.tag, tag);
})
if(this.navDataStack[tempIndex]){
this.navDataStack[tempIndex].data = data;
if (isSingleMode && data.srfkey && data.srfmajortext) {
this.navDataStack[tempIndex].key = data.srfkey;
this.navDataStack[tempIndex].title = data.srfmajortext;
}
return this.navDataStack[tempIndex];
}else{
return null;
}
} else {
return null;
}
}
/**
* 获取基础导航数据
*
* @memberof NavDataService
*/
public getNavData() {
return this.navDataStack;
}
/**
* 从导航数据栈中获取指定数据的前一条数据
*
* @memberof NavDataService
*/
public getPreNavData(tag: string) {
if (this.navDataStack.length > 0) {
let tempIndex: number = this.navDataStack.findIndex((element: INavDataParam) => {
return Object.is(element.tag, tag);
})
return this.navDataStack[tempIndex - 1];
} else {
return null;
}
}
/**
* 跳转到导航数据栈中指定数据
*
* @memberof NavDataService
*/
public skipNavData(tag: string) {
if ((this.navDataStack.length > 0) && tag) {
let tempIndex: number = this.navDataStack.findIndex((element: INavDataParam) => {
return Object.is(element.tag, tag);
})
if (tempIndex !== -1) {
this.navDataStack = this.navDataStack.slice(0, tempIndex + 1);
}
}
}
/**
* 从导航数据栈中指定数据
*
* @memberof NavDataService
*/
public removeNavData(tag: string) {
if ((this.navDataStack.length > 0) && tag) {
let tempIndex: number = this.navDataStack.findIndex((element: INavDataParam) => {
return Object.is(element.tag, tag);
})
if (tempIndex !== -1) {
this.navDataStack = this.navDataStack.slice(0, tempIndex);
}
}
}
/**
* 从导航数据栈中删除仅剩第一条数据
*
* @memberof NavDataService
*/
public removeNavDataFirst() {
if (this.navDataStack.length > 0) {
this.navDataStack = this.navDataStack.slice(0, 1);
}
}
/**
* 从导航数据栈中删除最后一条数据
*
* @memberof NavDataService
*/
public removeNavDataLast() {
if (this.navDataStack.length > 0) {
this.navDataStack.pop();
}
}
/**
* 从导航数据栈中删除所有数据
*
* @memberof NavDataService
*/
public removeAllNavData() {
this.navDataStack = [];
}
}
\ No newline at end of file
export * from './control-service'
export * from './entity-service'
export * from './ui-service'
export * from './common-service'
\ No newline at end of file
export * from './ui-service'
\ No newline at end of file
......@@ -97,7 +97,7 @@ export class Interceptors {
res.data.entityName = res.headers['x-ibz-params'];
}
if (res.status === 401) {
this.doNoLogin(res, _data.data);
App.gotoLoginPage();
}
if (res.status === 403) {
if (res.data && res.data.status && Object.is(res.data.status, "FORBIDDEN")) {
......@@ -114,16 +114,5 @@ export class Interceptors {
});
}
/**
* 处理未登录异常情况
*
* @private
* @param {*} [data={}]
* @memberof Interceptors
*/
private doNoLogin(response: any, data: any = {}): void {
// todo
}
}
\ No newline at end of file
import { Environment } from "@/environments/environment";
import { getSessionStorage, Http, IParam, setSessionStorage } from "@core";
import qs from "qs";
import { getCookie } from "qx-util";
import { Environment } from "@/environments/environment";
import { getSessionStorage, Http, IParam, setSessionStorage } from "@core";
/**
* 应用相关处理逻辑工具类
......@@ -47,7 +47,7 @@ export class AppUtil {
return false;
}
} catch (error) {
console.warn(error);
// App.gotoLoginPage();
return false;
}
}
......@@ -95,7 +95,7 @@ export class AppUtil {
return false;
}
} catch (error) {
console.warn(error);
// App.gotoLoginPage();
return false;
}
}
......
......@@ -26,7 +26,7 @@ export default defineConfig({
},
server:{
proxy:{
'/api':'http://localhost:8080'
// '/api':'http://localhost:8080'
}
},
plugins: [
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册