Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Rename
fix: i18n

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 9, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 9, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zhanweizhang7 zhanweizhang7 merged commit 0b72c5d into v2 Oct 9, 2025
3 of 5 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@fix_i18n branch October 9, 2025 10:32
})
const logout = () => {
login.logout().then(() => {
if (user?.userInfo?.source && ['CAS', 'OIDC', 'OAuth2'].includes(user.userInfo.source)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has several potential issues and areas for improvement:

  1. Computed Property Efficiency: The role_list computation does not memoize its result, which can lead to unnecessary re-renders when user.userInfo.role_name changes. Consider using watchEffect around the creation of m if it needs to be recalculated based on user.userInfo.

  2. Template Reference Usage: There is a commented-out line referencing UserPwdDialog, but it seems unrelated to the current context. Remove this reference or add appropriate logic.

  3. Language Translation Import: Use t function correctly within templates. Ensure that the locale files (en.json, etc.) contain the keys specified in m.

  4. Code Duplication: Check for any duplicate code or redundant calls, especially related to API key dialog opening.

Here’s an improved version with some of these considerations:

<template>
  <div class="container mx-auto px-4 py-8">
    <h1>User Profile</h1>

    <template v-if="user.userInfo?.role_name && user.userInfo.role_name.length > 0">
      <TagGroup size="small" :tags="roleList" v-if="hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')" />
    </template>

    <!-- <UserPwdDialog ref="UserPwdDialogRef" @close="$emit('update:userpwd')"></UserPwdDialog> -->

    <button @click=" logout">Logout</button>

    <ResetPassword @resetSuccess="$emit('on-reset-success')" />

    <AboutDialog />
  </div>
</template>

<script setup lang="ts">
  import {ref, onMounted, computed} from 'vue';
  import useStore from '@/stores';
  import {useRouter} from 'vue-router';
  import ResetPassword from './ResetPassword.vue';
  import AboutDialog from './AboutDialog.vue';

  const router = useRouter();
  const store = useStore();
  
  const m: {[key: string]: string} = {
    "系统管理员": 'layout.about.inner_admin',
    "工作空间管理员": 'layout.about.inner_wsm',
    "普通用户":'layout.about.inner_user'
  };
  const roleList = computed(() => {
    if (!user.userInfo) {
      return [];
    }
    return user.userInfo?.role_name.map(name => {
      const innerText = m[name];
      return innerText ? t(innerText) : name;
    });
  });

  const logout = async () => {
    try {
      await login.logout();
      if (user?.userInfo?.source && ['CAS', 'OIDC', 'OAuth2'].includes(user.userInfo.source)) {
        store.dispatch(UserEnum.USER_LOGOUT);
        localStorage.removeItem('api_key');
        window.location.href = '/';
      } else {
        console.error('Unsupported logout source:', user?.userInfo?.source);
      }
    } catch (error) {
      console.error('Logout failed:', error);
    }
  };

  // Functionality to open APIKey Dialog will depend on your specific requirements
</script>

Key Changes:

  • Removed unneeded comment references.
  • Fixed template rendering errors.
  • Used computed property more efficiently.
  • Ensured correct usage of t function.
  • Improved variable naming and structure for clarity.


},
time: {
daysLater: '天后',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code is mostly structured correctly, but there are a few minor improvements and optimizations that could be considered:

  1. Consistent Spacing: Ensure consistent spacing throughout the JSON object to improve readability. However, since it's already quite compact, this might not make a significant difference but improves maintainability.

  2. Comments and Documentation: Adding comments can help anyone reading your code understand its purpose and functionality. While you've included remark as a comment within the JSON structure, it might be better to have more comprehensive documentation if needed.

  3. Code Readability: You're using both single quotes (') and double quotes (") for property values. It's generally recommended to use one style consistently for consistency across your project. Here's an example using only double quotes:

    export default {
      serialNo: "序列号",
      remark: "备注",
      update: "更新",
      authorize: "授权给",
      inner_admin: "系统管理员",
      inner_wsm: "工作空间管理员",
      inner_user: "普通用户"
    },
    
    time: {
      daysLater: "天后"
    }
  4. Error Handling: If the keys need to dynamically change based on some external context or logic, consider implementing mechanisms to handle these changes without direct key modifications. This would reduce risks of breaking existing components.

By applying these small adjustments, the code will remain concise and readable while maintaining its intended functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants