提交 94399679 编写于 作者: KK's avatar KK

Revert "更新"

This reverts commit cb71c3c5.
上级 cb71c3c5
......@@ -47,7 +47,6 @@ export const AppComponents = {
v.component('app-form-group', () => import('@/components/app-form-group/app-form-group.vue'));
v.component('app-list-default', () => import('@/components/app-list-default/app-list-default.vue'));
v.component('app-list-swipe', () => import('@/components/app-list-swipe/app-list-swipe.vue'));
v.component('app-redirect-view', () => import('@/components/app-redirect-view/app-redirect-view.vue'));
// 日历组件
v.component('app-calendar',() => import('@/components/app-calendar/app-calendar.vue'));
v.component('app-vcalendar',() => import('@/components/app-vcalendar/app-vcalendar.vue'));
......
.app-redirect-view{
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
.context {
margin-left: 1em;
font-size: 24px;
font-family: ui-monospace;
}
}
\ No newline at end of file
<template>
<div class="app-redirect-view">
<div class="context">跳转中......</div>
</div>
</template>
<script lang="ts">
import { Util } from '@/ibiz-core/utils';
import qs from 'qs';
import { Vue, Component } from 'vue-property-decorator';
@Component({
})
export default class AppRedirectView extends Vue {
/**
* vue生命周期
*
* @type {*}
* @memberof AppRedirectView
*/
public created(){
let tempViewParam = this.parseViewParam(window.location.href);
this.executeRedirectLogic(tempViewParam);
}
/**
* 处理路径数据
*
* @param {*} [urlStr] 路径
*
* @memberof AppRedirectView
*/
public parseViewParam(urlStr: string): any {
let tempViewParam: any = {};
const tempViewparam: any = urlStr.slice(urlStr.lastIndexOf('?') + 1);
const viewparamArray: Array<string> = decodeURIComponent(tempViewparam).split(';');
if (viewparamArray.length > 0) {
viewparamArray.forEach((item: any) => {
Object.assign(tempViewParam, qs.parse(item));
});
}
return tempViewParam;
}
/**
* 执行数据重定向数据逻辑
*
*
* @memberof AppRedirectView
*/
public executeRedirectLogic(viewparam:any){
let tempViewParam:any = Util.deepCopy(viewparam);
const {srfdename,srfindexname}:{srfdename:string,srfindexname:string} = viewparam;
if(!viewparam || !srfdename || !srfindexname){
console.log('跳转参数不足,无法完成跳转操作!','executeRedirectLogic');
return;
}
// 避免数据污染
delete tempViewParam['srfdename'];
delete tempViewParam['srfindexname'];
delete tempViewParam[srfdename];
// 计算路径
let viewPath:string = `/${srfindexname}/${Util.srfpluralize(srfdename)}/${viewparam[srfdename]}/views/redirectview`;
if (Object.keys(tempViewParam).length > 0) {
viewPath = `${viewPath}?${qs.stringify(tempViewParam, { delimiter: ';' })}`;
}
this.$router.push({ path: viewPath });
}
}
</script>
<style lang='less'>
@import './app-redirect-view.less';
</style>
\ No newline at end of file
/**
* 复数变化规则
*
*
*/
export class PluralizeRule{
/**
* 不规则
*
* @protected
* @type {string[]}
* @memberof PluralizeRule
*/
protected irregular: Map<string, string> = new Map();
/**
* 不可数
*
* @protected
* @type {string[]}
* @memberof PluralizeRule
*/
protected uncountable: string[] = [
"equipment", "information", "rice", "money", "species", "series", "fish", "sheep", "people", "men",
"children", "sexes", "moves", "stadiums", "oxen", "octopi", "viri", "aliases", "quizzes",
];
/**
* 初始化pluralizeRule对象
*
* @param opts 额外参数
* @memberof PluralizeRule
*/
public constructor(opts: any = {}) {
this.initIrregular();
}
/**
* 初始化不规则变化
*
* @param opts 额外参数
* @memberof PluralizeRule
*/
protected initIrregular(){
this.irregular.set("person", "people");
this.irregular.set("man", "men");
this.irregular.set("child", "children");
this.irregular.set("sex", "sexes");
this.irregular.set("move", "moves");
this.irregular.set("stadium", "stadiums");
}
/**
* 是否为不可数
*
* @param word 单词
* @returns 返回判断
* @memberof PluralizeRule
*/
public isUncountable(word: string){
const index: number = this.uncountable.findIndex((wordStr: string) =>{
return Object.is(word, wordStr);
})
if (index == -1) {
return false;
} else {
return true;
}
}
/**
* 不规则变化
*
* @param word 单词
* @returns 返回变化值
* @memberof PluralizeRule
*/
public irregularChange(word: string){
for(let item of this.irregular.entries()){
if(word && (word.indexOf(item[0]) !== -1)){
return word.replace(new RegExp(item[0],'g'),item[1]);
}
}
return this.irregular.get(word);
}
/**
* 规则变化
*
* @param word 单词
* @returns 返回变化值
* @memberof PluralizeRule
*/
public ruleChange(word: string){
if(/(ax|test)is$/.test(word)) return word.replace(/is$/,"es");
if(/(octop|vir)us$/.test(word)) return word.replace(/us$/,"i");
if(/(octop|vir)i$/.test(word)) return word;
if(/(alias|status)$/.test(word)) return word+"es";
if(/(bu)s$/.test(word)) return word.replace(/s$/,"ses");
if(/(buffal|tomat)o$/.test(word)) return word.replace(/o$/,"oes");
if(/([ti])um$/.test(word)) return word.replace(/um$/,"a");
if(/([ti])a$/.test(word)) return word;
if(/sis$/.test(word)) return word.replace(/sis$/,"ses");
if(/(?:([^f])fe|([lr])f)$/.test(word)) return word.substring(0, word.length - 1)+"ves";
if(/(hive)$/.test(word)) return word+"s";
if(/([^aeiouy]|qu)y$/.test(word)) return word.replace(/y$/,"ies");
if(/(x|ch|ss|sh)$/.test(word)) return word+"es";
if(/(matr|vert|ind)ix|ex$/.test(word)) return word.replace(/ix|ex$/,"ices");
if(/([m|l])ouse$/.test(word)) return word.replace(/ouse$/,"ice");
if(/([m|l])ice$/.test(word)) return word;
if(/^(ox)$$/.test(word)) return word+"en";
if(/(quiz)$/.test(word)) return word+"zes";
if(/s$/.test(word)) return word.replace(/s$/,"s");
return word+"s";
}
}
\ No newline at end of file
import Schema from "async-validator";
import { PluralizeRule } from "./pluralizeRule";
/**
* 平台工具类
*
......@@ -281,7 +280,7 @@ export class Util {
_str = _str.replace(/---/g, '-').replace(/--/g, '-');
return _str;
}
/**
* 深度合并对象
*
......@@ -290,7 +289,7 @@ export class Util {
* @returns {Object}
* @memberof Util
*/
public static deepObjectMerge(FirstOBJ: any, SecondOBJ: any) {
public static deepObjectMerge(FirstOBJ:any, SecondOBJ:any) {
for (var key in SecondOBJ) {
FirstOBJ[key] = FirstOBJ[key] && FirstOBJ[key].toString() === "[object Object]" ?
this.deepObjectMerge(FirstOBJ[key], SecondOBJ[key]) : FirstOBJ[key] = SecondOBJ[key];
......@@ -308,7 +307,7 @@ export class Util {
* @returns {Promise}
* @memberof Util
*/
public static validateItem(property: string, data: any, rules: any) {
public static validateItem(property: string, data:any, rules:any) {
// 1.获取数值和规则
const value = data;
const rule = rules;
......@@ -324,9 +323,9 @@ export class Util {
* @returns {boolean}
* @memberof Util
*/
public static isAndroid(): boolean {
let u: any = navigator.userAgent;
return u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
public static isAndroid() :boolean{
let u :any= navigator.userAgent;
return u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
}
......@@ -339,7 +338,7 @@ export class Util {
* @returns {string}
* @memberof Util
*/
public static dateFormat(date: any, fmt: string = "YYYY-mm-dd HH:MM:SS"): string {
public static dateFormat(date: any,fmt: string = "YYYY-mm-dd HH:MM:SS"):string {
let ret;
const opt: any = {
"Y+": date.getFullYear().toString(), // 年
......@@ -359,27 +358,4 @@ export class Util {
return fmt;
}
/**
* 计算单词复数
*
* @static
* @returns {string}
* @memberof Util
*/
public static srfpluralize(word: string) {
let wordStr = word.trim().toLowerCase();
if (wordStr.length == 0) {
return wordStr;
}
const pluralizeRule = new PluralizeRule();
if (pluralizeRule.isUncountable(wordStr)) {
return wordStr;
}
const newWordStr = pluralizeRule.irregularChange(wordStr);
if (newWordStr) {
return newWordStr;
} else {
return pluralizeRule.ruleChange(wordStr);;
}
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册