-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: About permission #4228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: About permission #4228
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8869,3 +8869,6 @@ msgstr "下载原文档" | |
|
|
||
| msgid "Replace Original Document" | ||
| msgstr "替换原文档" | ||
|
|
||
| msgid "Update License" | ||
| msgstr "更新许可证" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8869,3 +8869,6 @@ msgstr "下載原文件" | |
|
|
||
| msgid "Replace Original Document" | ||
| msgstr "替換原文件" | ||
|
|
||
| msgid "Update License" | ||
| msgstr "更新許可證" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,10 @@ | |
| :auto-upload="false" | ||
| :show-file-list="false" | ||
| :on-change="onChange" | ||
| v-hasPermission="new Role('ADMIN')" | ||
| v-if="hasPermission([ | ||
| RoleConst.ADMIN, | ||
| PermissionConst.ABOUT_UPDATE | ||
| ],'OR')" | ||
| > | ||
| <el-button class="border-primary mr-16" | ||
| >{{ $t('layout.about.update') }} License | ||
|
|
@@ -70,6 +73,8 @@ import {fromNowDate} from '@/utils/time' | |
| import {Role} from '@/utils/permission/type' | ||
| import useStore from '@/stores' | ||
| import { t } from '@/locales' | ||
| import { hasPermission } from '@/utils/permission' | ||
| import { PermissionConst, RoleConst } from '@/utils/permission/data' | ||
| const {user, theme} = useStore() | ||
| const isDefaultTheme = computed(() => { | ||
| return theme.isDefaultTheme() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There appears to be an issue with line 49 of the provided code snippet. The Additionally, lines 68-73 should be moved outside of the For optimization, remove the unnecessary import statements for the roles like 'USER' before importing from <template>
<!-- Your template content here -->
</template>
<script lang="ts">
import {defineComponent} from "vue";
// import {RoleConst, PermissionConst} from "@/utils/permission/data"; // Remove this line
import userStore from "@/stores/userStore";
export default defineComponent({
data() {
return {};
},
computed: {
isDefaultTheme() {
return this.user.theme.isDefaultTheme();
}
}
});
</script>
This approach keeps the scope clean while ensuring all necessary imports are included where needed. Make sure each component has the appropriate role checks based on your application's security requirements. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,6 +320,7 @@ const PermissionConst = { | |
| OPERATION_LOG_CLEAR_POLICY: new Permission('OPERATION_LOG:READ+CLEAR_POLICY'), | ||
|
|
||
| ABOUT_READ: new Permission('OTHER:READ'), | ||
| ABOUT_UPDATE: new Permission('OTHER:READ+UPDATE'), | ||
| SWITCH_LANGUAGE: new Permission('OTHER:READ+EDIT'), | ||
| CHANGE_PASSWORD: new Permission('OTHER:READ+CREATE'), | ||
| SYSTEM_API_KEY_EDIT: new Permission('OTHER:READ+DELETE'), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet for
Overall, the existing permissions seem logically organized and don't contain known issues. If there are additional requirements or security concerns, consider consulting them further. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks mostly correct, but there are some suggestions to improve it:
Remove Redundant
READEnum Member:The
READmember is repeated in bothOperateandPermissionConstants. This redundancy can remove the need for duplicate values.Separate Permissions into Classes (Optional):
If your application requires more complex permission checks or organization, consider separating permissions into separate classes.
By making these adjustments, the code will be cleaner, more readable, and potentially easier to maintain.