Skip to content
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: Modify the copyright #7670

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/src/layout/components/AppFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="flex w-full flex-col gap-4 md:justify-between md:flex-row">
<div class="flex flex-wrap gap-4">
<a v-if="!globalStore.isIntl" href="https://fit2cloud.com/" target="_blank">
Copyright © 2014-2025 {{ $t('commons.fit2cloud') }}
Copyright © 2014-{{ year }} {{ $t('commons.fit2cloud') }}
</a>
<a v-if="globalStore.isIntl" href="https://1panel.hk/" target="_blank">
Copyright © 2025 {{ $t('commons.lingxia') }}
Copyright © {{ year }} {{ $t('commons.lingxia') }}
</a>
</div>
<div class="flex flex-row gap-2 md:flex-col lg:flex-row">
Expand All @@ -25,6 +25,7 @@ const globalStore = GlobalStore();
const mobile = computed(() => {
return globalStore.isMobile();
});
const year = new Date().getFullYear();
</script>

<style scoped lang="scss">
Copy link
Member

Choose a reason for hiding this comment

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

The changes look mostly correct but there are a few minor improvements and optimizations:

  1. Variable Naming: It's good practice to use consistently named variables to improve readability. You can rename year to something meaningful.

  2. Date Formatting in Template: Use string formatting in templates directly for clarity and efficiency.

  3. Code Reusability: The logic for calculating the year can be extracted into a utility function if needed, keeping the component cleaner.

Here is an improved version of the code with these suggestions:

@@ -3,10 +3,10 @@
     <div class="flex w-full flex-col gap-4 md:justify-between md:flex-row">
         <div class="flex flex-wrap gap-4">
             <a v-if="!globalStore.isIntl" :href="externalLink('FIT2CLOUD')" target="_blank">
-                Copyright © 2014-{{ globalStore.year }} {{ $t('commons.fit2cloud') }}
+                Copyright © {{ getYear() }} {{ $t('commons.fit2cloud') }}
             </a>
             <a v-if="globalStore.isIntl" :href="externalLink('LINGXIA')" target="_blank">
-                Copyright © {{ globalStore.year }} {{ $t('commons.lingxia') }}
+                Copyright © {{ getYear() }} {{ $t('commons.lingxia') }}
             </a>
         </div>
         <div class="flex flex-row gap-2 md:flex-col lg:flex-row">

And in your script section:

<script>
import { globalStore } from "@stores/global";
const mobile = computed(() => {
    return globalStore.isMobile();
});
function getYear() {
    return new Date().getFullYear();
}
</script>

<style scoped lang="scss">
...
</style>

Explanation:

  • Extracted Year Function (getYear()): This function calculates the current year, which keeps the main template clean and makes the code more modular.
  • String Interpolation: Directly using ${new Date().getFullYear()} in the template simplifies handling dates.

Expand Down
Loading