1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-25 19:58:36 +00:00
This commit is contained in:
wxiaoguang
2024-04-30 00:19:40 +08:00
parent a21ca9b5a5
commit d90dd9d7f8
3 changed files with 11 additions and 23 deletions

View File

@@ -2177,7 +2177,10 @@ func GetIssueInfo(ctx *context.Context) {
} }
} }
ctx.JSON(http.StatusOK, convert.ToIssue(ctx, ctx.Doer, issue)) ctx.JSON(http.StatusOK, map[string]any{
"convertedIssue": convert.ToIssue(ctx, ctx.Doer, issue),
"renderedLabels": templates.RenderLabels(ctx, ctx.Locale, issue.Labels, ctx.Repo.RepoLink, issue),
})
} }
// UpdateIssueTitle change issue's title // UpdateIssueTitle change issue's title

View File

@@ -1,6 +1,5 @@
<script> <script>
import {SvgIcon} from '../svg.js'; import {SvgIcon} from '../svg.js';
import {contrastColor} from '../utils/color.js';
import {GET} from '../modules/fetch.js'; import {GET} from '../modules/fetch.js';
const {appSubUrl, i18n} = window.config; const {appSubUrl, i18n} = window.config;
@@ -10,6 +9,7 @@ export default {
data: () => ({ data: () => ({
loading: false, loading: false,
issue: null, issue: null,
renderedLabels: '',
i18nErrorOccurred: i18n.error_occurred, i18nErrorOccurred: i18n.error_occurred,
i18nErrorMessage: null, i18nErrorMessage: null,
}), }),
@@ -56,14 +56,6 @@ export default {
} }
return 'red'; // Closed Issue return 'red'; // Closed Issue
}, },
labels() {
return this.issue.labels.map((label) => ({
name: label.name,
color: `#${label.color}`,
textColor: contrastColor(`#${label.color}`),
}));
},
}, },
mounted() { mounted() {
this.$refs.root.addEventListener('ce-load-context-popup', (e) => { this.$refs.root.addEventListener('ce-load-context-popup', (e) => {
@@ -79,13 +71,14 @@ export default {
this.i18nErrorMessage = null; this.i18nErrorMessage = null;
try { try {
const response = await GET(`${appSubUrl}/${data.owner}/${data.repo}/issues/${data.index}/info`); const response = await GET(`${appSubUrl}/${data.owner}/${data.repo}/issues/${data.index}/info`); // backend: GetIssueInfo
const respJson = await response.json(); const respJson = await response.json();
if (!response.ok) { if (!response.ok) {
this.i18nErrorMessage = respJson.message ?? i18n.network_error; this.i18nErrorMessage = respJson.message ?? i18n.network_error;
return; return;
} }
this.issue = respJson; this.issue = respJson.convertedIssue;
this.renderedLabels = respJson.renderedLabels;
} catch { } catch {
this.i18nErrorMessage = i18n.network_error; this.i18nErrorMessage = i18n.network_error;
} finally { } finally {
@@ -102,16 +95,8 @@ export default {
<p><small>{{ issue.repository.full_name }} on {{ createdAt }}</small></p> <p><small>{{ issue.repository.full_name }} on {{ createdAt }}</small></p>
<p><svg-icon :name="icon" :class="['text', color]"/> <strong>{{ issue.title }}</strong> #{{ issue.number }}</p> <p><svg-icon :name="icon" :class="['text', color]"/> <strong>{{ issue.title }}</strong> #{{ issue.number }}</p>
<p>{{ body }}</p> <p>{{ body }}</p>
<div class="labels-list"> <!-- eslint-disable-next-line vue/no-v-html -->
<div <div v-html="renderedLabels" />
v-for="label in labels"
:key="label.name"
class="ui label"
:style="{ color: label.textColor, backgroundColor: label.color }"
>
{{ label.name }}
</div>
</div>
</div> </div>
<div v-if="!loading && issue === null"> <div v-if="!loading && issue === null">
<p><small>{{ i18nErrorOccurred }}</small></p> <p><small>{{ i18nErrorOccurred }}</small></p>

View File

@@ -53,7 +53,7 @@ export function initCommonIssueListQuickGoto() {
// try to check whether the parsed goto link is valid // try to check whether the parsed goto link is valid
let targetUrl = parseIssueListQuickGotoLink(repoLink, searchText); let targetUrl = parseIssueListQuickGotoLink(repoLink, searchText);
if (targetUrl) { if (targetUrl) {
const res = await GET(`${targetUrl}/info`); const res = await GET(`${targetUrl}/info`); // backend: GetIssueInfo, it only checks whether the issue exists by status code
if (res.status !== 200) targetUrl = ''; if (res.status !== 200) targetUrl = '';
} }
// if the input value has changed, then ignore the result // if the input value has changed, then ignore the result