@@ -151,6 +151,7 @@ defineOptions({
});
const userStore = useUserStore();
+const router = useRouter();
const pageSize = 100;
const keyword = ref("");
@@ -159,7 +160,7 @@ const isLoading = ref(false);
const isSaving = ref(false);
const isRefreshing = ref(false);
const isNoMore = ref(false);
-const editDialogVisible = ref(false);
+const createDialogVisible = ref(false);
const total = ref(0);
const page = reactive
>({
index: 0,
@@ -168,13 +169,10 @@ const page = reactive>({
let keywordTimer: number | undefined;
let requestToken = 0;
const formModel = reactive({
- id: "",
name: ""
});
-const canUpdateTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.update));
const canDeleteTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.delete));
-const isCreateMode = computed(() => !formModel.id);
const emptyText = computed(() => {
if (isLoading.value) {
return "正在加载标签";
@@ -241,22 +239,19 @@ async function reload(): Promise {
}
function openCreateDialog(): void {
- formModel.id = "";
formModel.name = "";
- editDialogVisible.value = true;
+ createDialogVisible.value = true;
}
-function openEditDialog(tag: Tag): void {
- if (!canUpdateTag.value) {
+async function openDetail(tag: Tag): Promise {
+ if (!tag.id) {
return;
}
- formModel.id = tag.id || "";
- formModel.name = getTagName(tag);
- editDialogVisible.value = true;
+ await router.push({ name: "TagDetail", params: { id: tag.id } });
}
-function closeEditDialog(): void {
- editDialogVisible.value = false;
+function closeCreateDialog(): void {
+ createDialogVisible.value = false;
}
function validateForm(): boolean {
@@ -274,16 +269,11 @@ async function saveTag(): Promise {
isSaving.value = true;
try {
const payload: Tag = {
- id: formModel.id || undefined,
name: formModel.name.trim(),
zhCN: formModel.name.trim()
};
- if (isCreateMode.value) {
- await TagAPI.create(payload);
- } else {
- await TagAPI.update(payload);
- }
- editDialogVisible.value = false;
+ await TagAPI.create(payload);
+ createDialogVisible.value = false;
await reload();
Message.success("标签已保存");
} catch {
@@ -362,14 +352,14 @@ onUnmounted(() => {
.item {
flex: 1 1 auto;
color: var(--td-brand-color);
+ width: fit-content;
+ border: 1px solid var(--td-brand-color);
+ cursor: pointer;
margin: 0;
display: flex;
- min-width: 5rem;
- max-width: 100%;
padding: .25rem .5rem;
+ min-width: 0;
font-size: 1rem;
- min-height: 2rem;
- border: 1px solid var(--td-brand-color);
align-items: center;
border-radius: .5rem;
justify-content: center;
diff --git a/src/types/Tag.ts b/src/types/Tag.ts
index 3049ffb..c046670 100644
--- a/src/types/Tag.ts
+++ b/src/types/Tag.ts
@@ -9,6 +9,7 @@ export type Tag = {
nameLangId?: string;
name?: string;
zhCN?: string;
+ useCount?: number;
} & Model;
export type TagApply = {