1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-04 09:37:19 +00:00

Use shallowRef instead of ref in .vue files where possible (#34813)

This PR improves some `.vue` components by using `shallowRef instead of
ref`, which `should improve performance`. It's probably not significant,
but it's an improvement because Vue no longer deep watches the ref
(shallowRef). Also i used `useTemplateRef` instead of `ref`.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Kilisei
2025-06-22 15:37:03 +02:00
committed by GitHub
parent a46b16f10f
commit 181db69e0c
9 changed files with 51 additions and 51 deletions

View File

@ -23,7 +23,7 @@ import {
import {chartJsColors} from '../utils/color.ts';
import {sleep} from '../utils.ts';
import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm';
import {onMounted, ref} from 'vue';
import {onMounted, shallowRef} from 'vue';
const {pageData} = window.config;
@ -47,10 +47,10 @@ defineProps<{
};
}>();
const isLoading = ref(false);
const errorText = ref('');
const repoLink = ref(pageData.repoLink || []);
const data = ref<DayData[]>([]);
const isLoading = shallowRef(false);
const errorText = shallowRef('');
const repoLink = pageData.repoLink;
const data = shallowRef<DayData[]>([]);
onMounted(() => {
fetchGraphData();
@ -61,7 +61,7 @@ async function fetchGraphData() {
try {
let response: Response;
do {
response = await GET(`${repoLink.value}/activity/code-frequency/data`);
response = await GET(`${repoLink}/activity/code-frequency/data`);
if (response.status === 202) {
await sleep(1000); // wait for 1 second before retrying
}