fix
This commit is contained in:
parent
43cc89dc15
commit
90fecfc8c9
@ -3,7 +3,6 @@ import App from "./App.vue";
|
||||
import uviewPlus from "uview-plus";
|
||||
import globalComponents from "./components";
|
||||
import VConsole from "vconsole";
|
||||
import permission from "../utils/permission.js";
|
||||
|
||||
if (import.meta.env.VITE_APP_MODE === "dev") {
|
||||
new VConsole();
|
||||
@ -11,7 +10,6 @@ if (import.meta.env.VITE_APP_MODE === "dev") {
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App);
|
||||
globalComponents(app);
|
||||
permission(app);
|
||||
app.use(uviewPlus);
|
||||
return {
|
||||
app,
|
||||
|
@ -74,7 +74,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onBeforeMount } from "vue";
|
||||
import { closeWebview } from "../../../utils/index.js";
|
||||
import { closeWebview, hasPermission } from "../../../utils/index.js";
|
||||
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import useToast from "@/hooks/toast/useToast.js";
|
||||
|
@ -87,6 +87,7 @@
|
||||
:loading="loading"
|
||||
:disabled="isButtonDisabled"
|
||||
@click="doneSet"
|
||||
v-if="hasPermission('APP-scanAdd')"
|
||||
>
|
||||
{{ buttonText }}</up-button
|
||||
>
|
||||
@ -98,7 +99,7 @@ import { ref, reactive, onBeforeMount } from "vue";
|
||||
import useToast from "@/hooks/toast/useToast.js";
|
||||
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
|
||||
import { creChangepainting, add } from "@/api/login.js";
|
||||
import { closeWebview } from "../../../utils/index";
|
||||
import { closeWebview, hasPermission } from "../../../utils/index";
|
||||
|
||||
const { showMessage } = useToast();
|
||||
const loading = ref(false);
|
||||
|
@ -245,10 +245,10 @@ const logining = async () => {
|
||||
loading.value = false;
|
||||
};
|
||||
const getBtngetRules = async () => {
|
||||
const res = await getRules();
|
||||
const res = await getRules({});
|
||||
if (res.status === 0) {
|
||||
const ruleBtn =
|
||||
res.data.data.MyButtonAuths?.map((button) => button.Url) || [];
|
||||
const ruleBtn = res.data.MyButtonAuths?.map((button) => button.Url) || [];
|
||||
console.log(123, ruleBtn);
|
||||
uni.setStorageSync("ruleBtn", ruleBtn);
|
||||
} else {
|
||||
showMessage({ type: "error", message: res.msg });
|
||||
|
@ -43,6 +43,7 @@
|
||||
@click="doneSet"
|
||||
:disabled="isButtonDisabled"
|
||||
:loading="loading"
|
||||
v-if="hasPermission('APP-scanEnteringwarehouse')"
|
||||
>{{ buttonText }}</up-button
|
||||
>
|
||||
</view>
|
||||
@ -53,7 +54,7 @@ import { ref, reactive, onBeforeMount } from "vue";
|
||||
import useToast from "@/hooks/toast/useToast.js";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { freebox, bind, check_freebox, cancel } from "@/api/login.js";
|
||||
import { closeWebview } from "../../../utils/index";
|
||||
import { closeWebview, hasPermission } from "../../../utils/index";
|
||||
const { showMessage } = useToast();
|
||||
const loading = ref(false);
|
||||
const isButtonDisabled = ref(false);
|
||||
@ -142,12 +143,12 @@ const check = async () => {
|
||||
}
|
||||
};
|
||||
const runTimeEnv = () => {
|
||||
if (plus) {
|
||||
const currentWebView = plus.webview.getWebviewById("wv");
|
||||
return currentWebView.RunTime === "app";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (plus) {
|
||||
const currentWebView = plus.webview.getWebviewById("wv");
|
||||
return currentWebView.RunTime === "app";
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -24,3 +24,11 @@ export const OAorMc = () => {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
export const hasPermission = (userPermission) => {
|
||||
let userPermissionList = Array.isArray(userPermission)
|
||||
? userPermission
|
||||
: [userPermission];
|
||||
// 当前用户的权限列表
|
||||
let permissionList = Local.get("ruleBtn") ? Local.get("ruleBtn") : [];
|
||||
return userPermissionList.some((e) => permissionList.includes(e));
|
||||
};
|
||||
|
@ -1,22 +0,0 @@
|
||||
export default (app) => {
|
||||
// 按钮权限/show-btn
|
||||
app.directive("permission", {
|
||||
beforeMount(el, binding) {
|
||||
const btnList = uni.getStorageSync("ruleBtn")
|
||||
? uni.getStorageSync("ruleBtn")
|
||||
: [];
|
||||
if (
|
||||
(binding.value &&
|
||||
btnList.length > 0 &&
|
||||
!btnList.includes(binding.value)) ||
|
||||
btnList.length == 0
|
||||
) {
|
||||
// 解决进入页面按钮会闪一下再消失问题
|
||||
el.style.display = "none";
|
||||
setTimeout(() => {
|
||||
el.parentNode.removeChild(el);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user