perf: 企业模式下面增加个人数据迁移的引导

This commit is contained in:
xiaojunnuo
2026-03-22 00:49:54 +08:00
parent 6d5e5bd692
commit 431afd618f
6 changed files with 79 additions and 56 deletions

View File

@@ -795,6 +795,8 @@ export default {
reverseProxyEmpty: "No reverse proxy list configured",
environmentVars: "Environment Variables",
environmentVarsHelper: "configure the runtime environment variables, one per line, format: KEY=VALUE",
bindUrl: "Bind URL",
},
},
modal: {

View File

@@ -804,6 +804,7 @@ export default {
reverseProxyEmpty: "未配置反向代理",
environmentVars: "环境变量",
environmentVarsHelper: "配置运行时环境变量每行一个格式KEY=VALUE",
bindUrl: "绑定URL",
},
},
modal: {

View File

@@ -272,14 +272,27 @@ export const useSettingStore = defineStore({
},
async checkUrlBound() {
const userStore = useUserStore();
const settingStore = useSettingStore();
if (!userStore.isAdmin) {
return;
}
const bindUrl = this.installInfo.bindUrl;
const bindUrl2 = this.installInfo.bindUrl2;
if (!bindUrl) {
//绑定url
await this.doBindUrl("url");
} else {
//检查当前url 是否与绑定的url一致
const url = window.location.href;
if (!url.startsWith(bindUrl) && !url.startsWith(bindUrl2)) {
this.openBindUrlModal();
}
}
},
openBindUrlModal() {
const event: any = { ModalRef: null };
mitter.emit("getModal", event);
const Modal = event.ModalRef;
let modalRef: any = null;
const bindUrl = this.installInfo.bindUrl;
const bindUrl2 = this.installInfo.bindUrl2;
@@ -289,57 +302,47 @@ export const useSettingStore = defineStore({
modalRef.destroy();
}
};
if (!bindUrl) {
//绑定url
await this.doBindUrl("url");
} else {
//检查当前url 是否与绑定的url一致
const url = window.location.href;
if (!url.startsWith(bindUrl) && !url.startsWith(bindUrl2)) {
modalRef = Modal.warning({
title: "URL地址未绑定是否绑定此地址",
width: 500,
keyboard: false,
content: () => {
return (
<div class="p-4">
<div class="flex items-center justify-between">
<span>
1
<a-tag color="green">{bindUrl || "未占用"}</a-tag>
</span>
<a-button type="primary" onClick={() => doBindRequest("url")}>
1
</a-button>
</div>
<div class="flex items-center justify-between mt-3">
<span>
2
<a-tag color="green">{bindUrl2 || "未占用"}</a-tag>
</span>
<a-button type="primary" onClick={() => doBindRequest("url2")}>
2
</a-button>
</div>
</div>
);
},
onOk: async () => {
// await this.doBindUrl();
window.location.href = bindUrl;
},
okButtonProps: {
danger: true,
},
okText: "不,回到原来的地址",
cancelText: "不,回到原来的地址",
onCancel: () => {
window.location.href = bindUrl;
},
});
}
}
const modalRef: any = Modal.warning({
title: "URL地址未绑定是否绑定此地址",
width: 500,
keyboard: false,
content: () => {
return (
<div class="p-4">
<div class="flex items-center justify-between">
<span>
1
<a-tag color="green">{bindUrl || "未占用"}</a-tag>
</span>
<a-button type="primary" onClick={() => doBindRequest("url")}>
1
</a-button>
</div>
<div class="flex items-center justify-between mt-3">
<span>
2
<a-tag color="green">{bindUrl2 || "未占用"}</a-tag>
</span>
<a-button type="primary" onClick={() => doBindRequest("url2")}>
2
</a-button>
</div>
</div>
);
},
onOk: async () => {
// await this.doBindUrl();
window.location.href = bindUrl;
},
okButtonProps: {
danger: true,
},
okText: "不,回到原来的地址",
cancelText: "不,回到原来的地址",
onCancel: () => {
window.location.href = bindUrl;
},
});
},
async loadProductInfo() {
try {

View File

@@ -49,6 +49,7 @@ defineOptions({
const route = useRoute();
const projectIdStr = route.query.projectId as string;
const migrate = route.query.migrate as string;
let projectId = Number(projectIdStr);
const projectStore = useProjectStore();
if (!projectId) {
@@ -116,7 +117,11 @@ onMounted(async () => {
return;
}
await loadProjectDetail();
crudExpose.doRefresh();
await crudExpose.doRefresh();
if (migrate === "true") {
openTransferDialog();
}
});
onActivated(async () => {
await crudExpose.doRefresh();

View File

@@ -8,9 +8,10 @@
</div>
<div class="helper">SaaS模式每个用户管理自己的流水线和授权资源独立使用</div>
<div class="helper">企业模式通过项目合作管理流水线证书和授权资源所有用户视为企业内部员工</div>
<div class="helper"><a @click="adminModeIntroOpen = true">更多管理模式介绍</a></div>
<div class="helper text-red-500">建议在开始使用时固定一个合适的模式之后就不要随意切换了</div>
<div v-if="formState.public.adminMode === 'enterprise'" class="helper">设置为企业模式之后,之前创建的个人数据不会显示,您可以选择<a @click="goCurrentProject"> 将个人数据迁移到项目</a></div>
<div v-if="settingsStore.isComm" class="helper text-red-500">商业版不建议设置为企业模式除非你确定要转成企业内部使用</div>
<div><a @click="adminModeIntroOpen = true"> 更多管理模式介绍</a></div>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
@@ -33,6 +34,7 @@ import { useI18n } from "/src/locales";
import { dict } from "@fast-crud/fast-crud";
import { useProjectStore } from "/@/store/project";
import AdminModeIntro from "/@/views/sys/enterprise/project/intro.vue";
import { useRouter } from "vue-router";
const { t } = useI18n();
defineOptions({
@@ -82,5 +84,15 @@ const onFinish = async (form: any) => {
saveLoading.value = false;
}
};
const router = useRouter();
const goCurrentProject = () => {
router.push({
path: "/certd/project/detail",
query: {
migrate: "true",
},
});
};
</script>
<style lang="less"></style>

View File

@@ -8,7 +8,7 @@
</div>
<pre class="helper pre">{{ t("certd.sys.setting.passkeyEnabledHelper", [bindDomain]) }}</pre>
<div v-if="!bindDomainIsSame" class="text-red-500 text-sm mt-2">
{{ t("certd.sys.setting.passkeyHostnameNotSame") }}
{{ t("certd.sys.setting.passkeyHostnameNotSame") }} <a-button class="ml-2" size="small" type="primary" @click="settingsStore.openBindUrlModal()">{{ t("certd.sys.setting.bindUrl") }}</a-button>
</div>
</a-form-item>
<a-form-item :label="t('certd.sys.setting.enableOauth')" :name="['public', 'oauthEnabled']">