feat: 登录盐放local里&表格行hover显示编辑按钮

This commit is contained in:
RubyLiu 2023-09-07 11:39:54 +08:00 committed by 刘瑞斌
parent 93dd304453
commit c60f7ffc8d
6 changed files with 22 additions and 14 deletions

View File

@ -9,7 +9,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onBeforeMount, onMounted, watchEffect } from 'vue'; import { computed, onBeforeMount, onMounted } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import enUS from '@arco-design/web-vue/es/locale/lang/en-us'; import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn'; import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="ms-base-tale"> <div class="ms-base-table">
<select-all <select-all
v-if="attrs.selectable && attrs.showSelectAll" v-if="attrs.selectable && attrs.showSelectAll"
class="custom-action" class="custom-action"
@ -101,7 +101,7 @@
</slot> </slot>
</div> </div>
</a-tooltip> </a-tooltip>
<div> <div class="edit-icon">
<MsIcon <MsIcon
v-if="item.editType && editActiveKey !== `${item.dataIndex}${rowIndex}` && !record.deleted" v-if="item.editType && editActiveKey !== `${item.dataIndex}${rowIndex}` && !record.deleted"
class="ml-2 cursor-pointer" class="ml-2 cursor-pointer"
@ -201,7 +201,7 @@
const editActiveKey = ref<string>(''); const editActiveKey = ref<string>('');
// inputRef // inputRef
const currentInputRef = ref(); const currentInputRef = ref();
const { rowKey, editKey }: Partial<MsTableProps<any>> = attrs; const { rowKey }: Partial<MsTableProps<any>> = attrs;
// //
const currentSpanMethod = ({ const currentSpanMethod = ({
rowIndex, rowIndex,
@ -369,7 +369,7 @@
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.ms-base-tale { .ms-base-table {
position: relative; position: relative;
.custom-action { .custom-action {
position: absolute; position: absolute;
@ -386,5 +386,20 @@
.ms-table-edit-active { .ms-table-edit-active {
color: rgb(var(--primary-5)); color: rgb(var(--primary-5));
} }
.edit-icon {
color: rgb(var(--primary-7));
opacity: 0;
}
:deep(.arco-table-hover) {
:not(.arco-table-dragging) {
.arco-table-tr:not(.arco-table-tr-empty):not(.arco-table-tr-summary):hover {
.arco-table-td:not(.arco-table-col-fixed-left):not(.arco-table-col-fixed-right) {
.edit-icon {
opacity: 1;
}
}
}
}
}
} }
</style> </style>

View File

@ -22,7 +22,7 @@ export default function useUser() {
}; };
const setSalt = (salt: string) => { const setSalt = (salt: string) => {
userStore.setSalt(salt); localStorage.setItem('salt', salt);
}; };
const isLoginPage = () => { const isLoginPage = () => {

View File

@ -29,7 +29,6 @@ const useUserStore = defineStore('user', {
id: undefined, id: undefined,
certification: undefined, certification: undefined,
role: '', role: '',
salt: '',
}), }),
getters: { getters: {
@ -105,10 +104,6 @@ const useUserStore = defineStore('user', {
return false; return false;
} }
}, },
// 加盐
setSalt(salt: string) {
this.$patch({ salt });
},
}, },
}); });

View File

@ -18,6 +18,4 @@ export interface UserState {
role: RoleType; role: RoleType;
lastOrganizationId?: string; lastOrganizationId?: string;
lastProjectId?: string; lastProjectId?: string;
// 盐
salt: string;
} }

View File

@ -117,7 +117,7 @@
if (!errors) { if (!errors) {
setLoading(true); setLoading(true);
try { try {
const publicKey = userStore.salt; const publicKey = localStorage.getItem('salt') || '';
await userStore.login({ await userStore.login({
username: encrypted(values.username, publicKey), username: encrypted(values.username, publicKey),
password: encrypted(values.password, publicKey), password: encrypted(values.password, publicKey),