Commit b08bda0b authored by 徐光星's avatar 徐光星

Merge branch 'feat/v1.6' into 'master'

Feat/v1.6

See merge request !83
parents ffccb439 9c577be1
import { Component, Vue } from 'vue-property-decorator'; import { Component, Vue } from 'vue-property-decorator';
import { transformStyle, getStyle } from '@/service/utils.service'; import { transformStyle, getStyle, isPx, pxToRem } from '@/service/utils.service';
import { Mutation } from 'vuex-class'; import { Mutation } from 'vuex-class';
@Component({ name: 'TransformStyleMixin' }) @Component({ name: 'TransformStyleMixin' })
...@@ -17,7 +17,7 @@ export default class TransformStyleMixin extends Vue { ...@@ -17,7 +17,7 @@ export default class TransformStyleMixin extends Vue {
if ( typeof styleObj[key] === 'number') { if ( typeof styleObj[key] === 'number') {
style[key] = `${(styleObj[key] / 37.5).toFixed(2)}rem`; style[key] = `${(styleObj[key] / 37.5).toFixed(2)}rem`;
} else { } else {
style[key] = styleObj[key]?.includes('px') ? `${(+(styleObj[key].slice(0, -2)) / 37.5).toFixed(2)}rem` : styleObj[key]; style[key] = isPx(styleObj[key]) ? pxToRem(styleObj[key]) : styleObj[key];
} }
if (key === 'backgroundImage' && style.backgroundImage) { if (key === 'backgroundImage' && style.backgroundImage) {
style.backgroundImage = `url(${style.backgroundImage})`; style.backgroundImage = `url(${style.backgroundImage})`;
......
...@@ -108,6 +108,15 @@ export const validateType = function(obj) { ...@@ -108,6 +108,15 @@ export const validateType = function(obj) {
return typeof obj === 'object' ? class2type[Object.prototype.toString.call(obj)] || 'object' : typeof obj; return typeof obj === 'object' ? class2type[Object.prototype.toString.call(obj)] || 'object' : typeof obj;
}; };
export const isPx = str => /(\d+(\.\d*)?)+(px)/gi.test(str);
export const pxToRem = (str, width = 37.5) => {
const reg = /(\d+(\.\d*)?)+(px)/gi; //可以匹配浮点数
let newStr = str.replace(reg, function (_x) {
_x = _x.replace(/px"/gi, '');
return parseFloat(parseFloat(_x) / width).toFixed(2) + 'rem';
});
return newStr;
}
export const transformStyle = function(styleObj = {}) { export const transformStyle = function(styleObj = {}) {
// console.log('transformStyle', styleObj); // console.log('transformStyle', styleObj);
const style = {}; const style = {};
...@@ -115,7 +124,7 @@ export const transformStyle = function(styleObj = {}) { ...@@ -115,7 +124,7 @@ export const transformStyle = function(styleObj = {}) {
if ( typeof styleObj[key] === 'number') { if ( typeof styleObj[key] === 'number') {
style[key] = `${(styleObj[key] / 37.5).toFixed(3)}rem`; style[key] = `${(styleObj[key] / 37.5).toFixed(3)}rem`;
} else { } else {
style[key] = styleObj[key].includes('px') ? `${(+(styleObj[key].slice(0, -2)) / 37.5).toFixed(3)}rem` : styleObj[key]; style[key] = isPx(styleObj[key]) ? pxToRem(styleObj[key]) : styleObj[key];
} }
if (key === 'backgroundImage' && style.backgroundImage) { if (key === 'backgroundImage' && style.backgroundImage) {
style.background = `url(${style.backgroundImage}) no-repeat 0 0 / cover`; style.background = `url(${style.backgroundImage}) no-repeat 0 0 / cover`;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
"talosHost": "https://talos-test1.liangkebang.net", "talosHost": "https://talos-test1.liangkebang.net",
"kdspHost": "https://kdsp-api-test1.liangkebang.net", "kdspHost": "https://kdsp-api-test1.liangkebang.net",
"loginUrl": "", "loginUrl": "",
"newApolloFlag": true,
"h5ShopHost": "https://tenet-test1.liangkebang.net/#", "h5ShopHost": "https://tenet-test1.liangkebang.net/#",
"mallHost": "https://mall-test1.liangkebang.net", "mallHost": "https://mall-test1.liangkebang.net",
"xyqbH5Host": "https://mapi-test1.liangkebang.net", "xyqbH5Host": "https://mapi-test1.liangkebang.net",
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
}, },
"redis": { "redis": {
"port": "32625", "port": "32625",
"host": "172.17.5.3", "host": "172.17.5.22",
"password": "", "password": "",
"db": 0 "db": 0
}, },
......
{"apiHost":"https://quantum-blocks-test1.liangkebang.net","h5Host":"https://quantum-h5-test1.liangkebang.net","opapiHost":"https://opapi-test1.liangkebang.net","passportHost":"https://passportapi-test1.liangkebang.net","talosHost":"https://talos-test1.liangkebang.net","kdspHost":"https://kdsp-api-test1.liangkebang.net","loginUrl":"","h5ShopHost":"https://tenet-test1.liangkebang.net/#","mallHost":"https://mall-test1.liangkebang.net","xyqbH5Host":"https://mapi-test1.liangkebang.net","yxmTenantId":560761,"appIdMap":{"560761":"wxe16bf9293671506c","560867":"wxccb8435d68e8c7d6"},"qiniuUpHost":"https://up-z0.qiniup.com","qiniuHost":"https://appsync.lkbang.net"} {"apiHost":"https://quantum-blocks-test1.liangkebang.net","h5Host":"https://quantum-h5-test1.liangkebang.net","opapiHost":"https://opapi-test1.liangkebang.net","passportHost":"https://passportapi-test1.liangkebang.net","talosHost":"https://talos-test1.liangkebang.net","kdspHost":"https://kdsp-api-test1.liangkebang.net","loginUrl":"","newApolloFlag":true,"h5ShopHost":"https://tenet-test1.liangkebang.net/#","mallHost":"https://mall-test1.liangkebang.net","xyqbH5Host":"https://mapi-test1.liangkebang.net","yxmTenantId":560761,"appIdMap":{"560761":"wxe16bf9293671506c","560867":"wxccb8435d68e8c7d6"},"qiniuUpHost":"https://up-z0.qiniup.com","qiniuHost":"https://appsync.lkbang.net"}
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment