mirror of https://github.com/halo-dev/halo
parent
82d966cba6
commit
84e4cae994
|
@ -174,6 +174,12 @@ async function loadCurrentUser() {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
async function initApp() {
|
async function initApp() {
|
||||||
|
// TODO 实验性特性
|
||||||
|
const theme = localStorage.getItem("theme");
|
||||||
|
if (theme) {
|
||||||
|
document.body.classList.add(theme);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadCoreModules();
|
loadCoreModules();
|
||||||
await loadPluginModules();
|
await loadPluginModules();
|
||||||
|
|
|
@ -15,7 +15,8 @@ import { apiClient } from "@halo-dev/admin-shared";
|
||||||
import type { Role, User } from "@halo-dev/api-client";
|
import type { Role, User } from "@halo-dev/api-client";
|
||||||
|
|
||||||
interface RoleTemplateGroup {
|
interface RoleTemplateGroup {
|
||||||
name: string | null | undefined;
|
module: string | null | undefined;
|
||||||
|
displayName: string | null | undefined;
|
||||||
roles: Role[];
|
roles: Role[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ const formState = ref<FormState>({
|
||||||
labels: {},
|
labels: {},
|
||||||
annotations: {
|
annotations: {
|
||||||
"rbac.authorization.halo.run/dependencies": "",
|
"rbac.authorization.halo.run/dependencies": "",
|
||||||
"plugin.halo.run/display-name": "",
|
"rbac.authorization.halo.run/display-name": "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rules: [],
|
rules: [],
|
||||||
|
@ -50,7 +51,9 @@ const formState = ref<FormState>({
|
||||||
|
|
||||||
const roleTemplates = computed<Role[]>(() => {
|
const roleTemplates = computed<Role[]>(() => {
|
||||||
return roles.value.filter(
|
return roles.value.filter(
|
||||||
(role) => role.metadata.labels?.["plugin.halo.run/role-template"] === "true"
|
(role) =>
|
||||||
|
role.metadata.labels?.["halo.run/role-template"] === "true" &&
|
||||||
|
role.metadata.labels?.["halo.run/hidden"] !== "true"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,13 +62,19 @@ const roleTemplateGroups = computed<RoleTemplateGroup[]>(() => {
|
||||||
roleTemplates.value.forEach((role) => {
|
roleTemplates.value.forEach((role) => {
|
||||||
const group = groups.find(
|
const group = groups.find(
|
||||||
(group) =>
|
(group) =>
|
||||||
group.name === role.metadata.annotations?.["plugin.halo.run/module"]
|
group.module ===
|
||||||
|
role.metadata.annotations?.["rbac.authorization.halo.run/module"]
|
||||||
);
|
);
|
||||||
if (group) {
|
if (group) {
|
||||||
group.roles.push(role);
|
group.roles.push(role);
|
||||||
} else {
|
} else {
|
||||||
groups.push({
|
groups.push({
|
||||||
name: role.metadata.annotations?.["plugin.halo.run/module"],
|
module:
|
||||||
|
role.metadata.annotations?.["rbac.authorization.halo.run/module"],
|
||||||
|
displayName:
|
||||||
|
role.metadata.annotations?.[
|
||||||
|
"rbac.authorization.halo.run/display-name"
|
||||||
|
],
|
||||||
roles: [role],
|
roles: [role],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -295,12 +304,12 @@ onMounted(() => {
|
||||||
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"
|
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"
|
||||||
>
|
>
|
||||||
<dt class="text-sm font-medium text-gray-900">
|
<dt class="text-sm font-medium text-gray-900">
|
||||||
{{ group.name }}
|
{{ group.displayName }}
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
|
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
|
||||||
<ul class="space-y-2">
|
<ul class="space-y-2">
|
||||||
<li v-for="(role, index) in group.roles" :key="index">
|
<li v-for="(role, index) in group.roles" :key="index">
|
||||||
<div
|
<label
|
||||||
class="inline-flex w-72 cursor-pointer flex-row items-center gap-4 rounded border p-5 hover:border-primary"
|
class="inline-flex w-72 cursor-pointer flex-row items-center gap-4 rounded border p-5 hover:border-primary"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
@ -309,11 +318,11 @@ onMounted(() => {
|
||||||
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
|
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
/>
|
/>
|
||||||
<div class="inline-flex flex-col gap-y-3">
|
<div class="flex flex-1 flex-col gap-y-3">
|
||||||
<span class="font-medium text-gray-900">
|
<span class="font-medium text-gray-900">
|
||||||
{{
|
{{
|
||||||
role.metadata.annotations?.[
|
role.metadata.annotations?.[
|
||||||
"plugin.halo.run/display-name"
|
"rbac.authorization.halo.run/display-name"
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -335,7 +344,7 @@ onMounted(() => {
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
|
@ -22,8 +22,7 @@ const roles = ref<Role[]>([]);
|
||||||
|
|
||||||
const basicRoles = computed(() => {
|
const basicRoles = computed(() => {
|
||||||
return roles.value.filter(
|
return roles.value.filter(
|
||||||
(role) =>
|
(role) => role.metadata?.labels?.["halo.run/role-template"] !== "true"
|
||||||
role.metadata?.labels?.["plugin.halo.run/role-template"] !== "true"
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ import { apiClient } from "@halo-dev/admin-shared";
|
||||||
import type { Role } from "@halo-dev/api-client";
|
import type { Role } from "@halo-dev/api-client";
|
||||||
|
|
||||||
interface RoleTemplateGroup {
|
interface RoleTemplateGroup {
|
||||||
name: string | null | undefined;
|
module: string | null | undefined;
|
||||||
|
displayName: string | null | undefined;
|
||||||
roles: Role[];
|
roles: Role[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ const creationFormState = ref<CreationFormState>({
|
||||||
labels: {},
|
labels: {},
|
||||||
annotations: {
|
annotations: {
|
||||||
"rbac.authorization.halo.run/dependencies": "",
|
"rbac.authorization.halo.run/dependencies": "",
|
||||||
"plugin.halo.run/display-name": "",
|
"rbac.authorization.halo.run/display-name": "",
|
||||||
}!,
|
}!,
|
||||||
},
|
},
|
||||||
rules: [],
|
rules: [],
|
||||||
|
@ -46,7 +47,9 @@ const creationFormState = ref<CreationFormState>({
|
||||||
|
|
||||||
const roleTemplates = computed<Role[]>(() => {
|
const roleTemplates = computed<Role[]>(() => {
|
||||||
return roles.value.filter(
|
return roles.value.filter(
|
||||||
(role) => role.metadata.labels?.["plugin.halo.run/role-template"] === "true"
|
(role) =>
|
||||||
|
role.metadata.labels?.["halo.run/role-template"] === "true" &&
|
||||||
|
role.metadata.labels?.["halo.run/hidden"] !== "true"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -55,13 +58,19 @@ const roleTemplateGroups = computed<RoleTemplateGroup[]>(() => {
|
||||||
roleTemplates.value.forEach((role) => {
|
roleTemplates.value.forEach((role) => {
|
||||||
const group = groups.find(
|
const group = groups.find(
|
||||||
(group) =>
|
(group) =>
|
||||||
group.name === role.metadata.annotations?.["plugin.halo.run/module"]
|
group.module ===
|
||||||
|
role.metadata.annotations?.["rbac.authorization.halo.run/module"]
|
||||||
);
|
);
|
||||||
if (group) {
|
if (group) {
|
||||||
group.roles.push(role);
|
group.roles.push(role);
|
||||||
} else {
|
} else {
|
||||||
groups.push({
|
groups.push({
|
||||||
name: role.metadata.annotations?.["plugin.halo.run/module"],
|
module:
|
||||||
|
role.metadata.annotations?.["rbac.authorization.halo.run/module"],
|
||||||
|
displayName:
|
||||||
|
role.metadata.annotations?.[
|
||||||
|
"rbac.authorization.halo.run/display-name"
|
||||||
|
],
|
||||||
roles: [role],
|
roles: [role],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -132,7 +141,7 @@ watch(
|
||||||
<FormKit
|
<FormKit
|
||||||
v-model="
|
v-model="
|
||||||
creationFormState.role.metadata.annotations[
|
creationFormState.role.metadata.annotations[
|
||||||
'plugin.halo.run/display-name'
|
'rbac.authorization.halo.run/display-name'
|
||||||
]
|
]
|
||||||
"
|
"
|
||||||
label="名称"
|
label="名称"
|
||||||
|
@ -156,13 +165,13 @@ watch(
|
||||||
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"
|
class="bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"
|
||||||
>
|
>
|
||||||
<dt class="text-sm font-medium text-gray-900">
|
<dt class="text-sm font-medium text-gray-900">
|
||||||
{{ group.name }}
|
{{ group.displayName }}
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
|
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
|
||||||
<ul class="space-y-2">
|
<ul class="space-y-2">
|
||||||
<li v-for="(role, index) in group.roles" :key="index">
|
<li v-for="(role, index) in group.roles" :key="index">
|
||||||
<div
|
<label
|
||||||
class="inline-flex w-72 cursor-pointer flex-row items-center gap-4 rounded border p-5 hover:border-primary"
|
class="inline-flex w-full cursor-pointer flex-row items-center gap-4 rounded border p-5 hover:border-primary"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="creationFormState.selectedRoleTemplates"
|
v-model="creationFormState.selectedRoleTemplates"
|
||||||
|
@ -170,11 +179,11 @@ watch(
|
||||||
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
|
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
/>
|
/>
|
||||||
<div class="inline-flex flex-col gap-y-3">
|
<div class="flex flex-1 flex-col gap-y-3">
|
||||||
<span class="font-medium text-gray-900">
|
<span class="font-medium text-gray-900">
|
||||||
{{
|
{{
|
||||||
role.metadata.annotations?.[
|
role.metadata.annotations?.[
|
||||||
"plugin.halo.run/display-name"
|
"rbac.authorization.halo.run/display-name"
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -196,7 +205,7 @@ watch(
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
Loading…
Reference in New Issue