Tcsm
2023-03-30 96f548cbddff2a3cae98382f89e55af247089f55
3.30日提交
7个文件已修改
1个文件已添加
1个文件已删除
163 ■■■■ 已修改文件
ruoyi-ui/flexible.js 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/package.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/api/self/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/main.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/router/index.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/store/modules/user.js 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/login.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/new_test/index.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/vue.config.js 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/flexible.js
New file
@@ -0,0 +1,119 @@
//flexible.js
(function(win, lib) {
  var doc = win.document;
  var docEl = doc.documentElement;
  var metaEl = doc.querySelector('meta[name="viewport"]');
  var flexibleEl = doc.querySelector('meta[name="flexible"]');
  var dpr = 0;
  var scale = 0;
  var tid;
  var flexible = lib.flexible || (lib.flexible = {});
  if (metaEl) {
    console.warn('将根据已有的meta标签来设置缩放比例');
    var match = metaEl.getAttribute('content').match(/initial\-scale=([\d\.]+)/);
    if (match) {
      scale = parseFloat(match[1]);
      dpr = parseInt(1 / scale);
    }
  } else if (flexibleEl) {
    var content = flexibleEl.getAttribute('content');
    if (content) {
      var initialDpr = content.match(/initial\-dpr=([\d\.]+)/);
      var maximumDpr = content.match(/maximum\-dpr=([\d\.]+)/);
      if (initialDpr) {
        dpr = parseFloat(initialDpr[1]);
        scale = parseFloat((1 / dpr).toFixed(2));
      }
      if (maximumDpr) {
        dpr = parseFloat(maximumDpr[1]);
        scale = parseFloat((1 / dpr).toFixed(2));
      }
    }
  }
  if (!dpr && !scale) {
    var isAndroid = win.navigator.appVersion.match(/android/gi);
    var isIPhone = win.navigator.appVersion.match(/iphone/gi);
    var devicePixelRatio = win.devicePixelRatio;
    if (isIPhone) {
      // iOS下,对于2和3的屏,用2倍的方案,其余的用1倍方案
      if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) {
        dpr = 3;
      } else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)){
        dpr = 2;
      } else {
        dpr = 1;
      }
    } else {
      // 其他设备下,仍旧使用1倍的方案
      dpr = 1;
    }
    scale = 1 / dpr;
  }
  docEl.setAttribute('data-dpr', dpr);
  if (!metaEl) {
    metaEl = doc.createElement('meta');
    metaEl.setAttribute('name', 'viewport');
    metaEl.setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no');
    if (docEl.firstElementChild) {
      docEl.firstElementChild.appendChild(metaEl);
    } else {
      var wrap = doc.createElement('div');
      wrap.appendChild(metaEl);
      doc.write(wrap.innerHTML);
    }
  }
  function refreshRem(){
    var width = docEl.getBoundingClientRect().width;
    if (width / dpr > 540) {
      width = width * dpr;
    }
    var rem = width / 10;
    docEl.style.fontSize = rem + 'px';
    flexible.rem = win.rem = rem;
  }
  win.addEventListener('resize', function() {
    clearTimeout(tid);
    tid = setTimeout(refreshRem, 300);
  }, false);
  win.addEventListener('pageshow', function(e) {
    if (e.persisted) {
      clearTimeout(tid);
      tid = setTimeout(refreshRem, 300);
    }
  }, false);
  if (doc.readyState === 'complete') {
    doc.body.style.fontSize = 12 * dpr + 'px';
  } else {
    doc.addEventListener('DOMContentLoaded', function(e) {
      doc.body.style.fontSize = 12 * dpr + 'px';
    }, false);
  }
  refreshRem();
  flexible.dpr = win.dpr = dpr;
  flexible.refreshRem = refreshRem;
  flexible.rem2px = function(d) {
    var val = parseFloat(d) * this.rem;
    if (typeof d === 'string' && d.match(/rem$/)) {
      val += 'px';
    }
    return val;
  }
  flexible.px2rem = function(d) {
    var val = parseFloat(d) / this.rem;
    if (typeof d === 'string' && d.match(/px$/)) {
      val += 'rem';
    }
    return val;
  }
})(window, window['lib'] || (window['lib'] = {}));
ruoyi-ui/package.json
@@ -49,6 +49,7 @@
    "js-cookie": "3.0.1",
    "jsencrypt": "3.0.0-rc.1",
    "nprogress": "0.2.0",
    "postcss-px2rem": "^0.3.0",
    "quill": "1.3.7",
    "screenfull": "5.0.2",
    "sortablejs": "1.10.2",
ruoyi-ui/src/api/self/index.js
@@ -3,7 +3,7 @@
// 根据id查询个人详细信息
export function getIndividualInfo(id) {
  return request({
    url: '/self/user' + id,
    url: '/self/user' ,
    method: 'get',
  })
ruoyi-ui/src/main.js
@@ -37,6 +37,8 @@
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'
//屏幕分辨率适配
import '../flexible'
// 全局方法挂载
Vue.prototype.getDicts = getDicts
ruoyi-ui/src/router/index.js
@@ -74,6 +74,7 @@
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
ruoyi-ui/src/store/modules/user.js
ruoyi-ui/src/views/login.vue
@@ -139,7 +139,7 @@
  name: "Login",
  data() {
    return {
      codeUrl: "",
      codeUrl: "http://47.93.189.255:8080/captchaImage",
      loginForm: {
        username: "admin",
        password: "admin123",
ruoyi-ui/src/views/new_test/index.vue
File was deleted
ruoyi-ui/vue.config.js
@@ -47,8 +47,15 @@
  },
  css: {
    loaderOptions: {
      sass: {
        sassOptions: { outputStyle: "expanded" }
      // sass: {
      //   sassOptions: { outputStyle: "expanded" }
      // }
      postcss:{
        plugins:[
          require('postcss-px2rem')({
            remUnit:192
          })
        ]
      }
    }
  },
@@ -90,6 +97,17 @@
        symbolId: 'icon-[name]'
      })
      .end()
    //
    // config.module
    //   .rule("css")
    //   .test(/\.css$/)
    //   .oneOf("vue")
    //   .resourceQuery(/\?vue/)
    //   .use("px2rem")
    //   .loader("px2rem-loader")
    //   .options({
    //     remUnit: 192 // 设计稿大小比例 / 10
    //   });
    config
      .when(process.env.NODE_ENV !== 'development',
@@ -134,4 +152,5 @@
        }
      )
  }
}