From 96f548cbddff2a3cae98382f89e55af247089f55 Mon Sep 17 00:00:00 2001
From: Tcsm <1377977403@qq.com>
Date: 星期四, 30 三月 2023 18:30:35 +0800
Subject: [PATCH] 3.30日提交
---
/dev/null | 13 ----
ruoyi-ui/package.json | 1
ruoyi-ui/src/store/modules/user.js | 2
ruoyi-ui/src/main.js | 2
ruoyi-ui/flexible.js | 119 +++++++++++++++++++++++++++++++++++++++
ruoyi-ui/vue.config.js | 23 +++++++
ruoyi-ui/src/api/self/index.js | 2
ruoyi-ui/src/router/index.js | 1
ruoyi-ui/src/views/login.vue | 2
9 files changed, 147 insertions(+), 18 deletions(-)
diff --git a/ruoyi-ui/flexible.js b/ruoyi-ui/flexible.js
new file mode 100644
index 0000000..5224730
--- /dev/null
+++ b/ruoyi-ui/flexible.js
@@ -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'] = {}));
+
diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json
index 8bbecbf..26b9eea 100644
--- a/ruoyi-ui/package.json
+++ b/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",
diff --git a/ruoyi-ui/src/api/self/index.js b/ruoyi-ui/src/api/self/index.js
index ba6cebe..0361f6d 100644
--- a/ruoyi-ui/src/api/self/index.js
+++ b/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',
})
diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js
index 13c6cf2..6bc243f 100644
--- a/ruoyi-ui/src/main.js
+++ b/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
diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js
index b370bdd..3281ddb 100644
--- a/ruoyi-ui/src/router/index.js
+++ b/ruoyi-ui/src/router/index.js
@@ -74,6 +74,7 @@
}
]
},
+
{
path: '/user',
component: Layout,
diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js
index 0b0aa99..2816332 100644
--- a/ruoyi-ui/src/store/modules/user.js
+++ b/ruoyi-ui/src/store/modules/user.js
@@ -31,7 +31,7 @@
actions: {
// 鐧诲綍
Login({ commit }, userInfo) {
-
+
const username = userInfo.username.trim()
const password = userInfo.password
const code = userInfo.code
diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue
index 0e4dcd8..e841f52 100644
--- a/ruoyi-ui/src/views/login.vue
+++ b/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",
diff --git a/ruoyi-ui/src/views/new_test/index.vue b/ruoyi-ui/src/views/new_test/index.vue
deleted file mode 100644
index faaa065..0000000
--- a/ruoyi-ui/src/views/new_test/index.vue
+++ /dev/null
@@ -1,13 +0,0 @@
-<template>
- <h1>浣犲ソ</h1>
-</template>
-
-<script>
-export default {
- name: 'index'
-}
-</script>
-
-<style scoped>
-
-</style>
diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js
index 5537a41..767a3eb 100644
--- a/ruoyi-ui/vue.config.js
+++ b/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 @@
}
)
}
+
}
--
Gitblit v1.9.1