init: UserBaseFront (frontend)

This commit is contained in:
chenxing
2026-08-10 14:41:13 +08:00
commit eea881b616
174 changed files with 32833 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import config from "./host.config";
import { AxiosRequestConfig } from "axios";
import { PcDebugUser } from "@/types/Basics";
const serviceUrl = config.isMock ? "" : config.serviceHost,
timeout: number = 15000;
let baseConfig: AxiosRequestConfig = {
baseURL: serviceUrl + "/",
headers: {
// "Content-Type": "application/x-www-form-urlencoded",
"Content-Type": "application/json;charset=urf-8",
yschapirequest: "1",
"Access-Control-Allow-Headers": "Set-Cookie",
"X-Requested-With": "XMLHttpRequest",
},
params: {},
data: {},
timeout, // 接口超时限制(ms)
withCredentials: true,
responseType: "json",
// transformRequest: [
// function (data) {
// if (typeof data == "string") return data;
// let ret = "";
// for (let it in data) {
// ret += encodeURIComponent(it) + "=" + encodeURIComponent(data[it]) + "&";
// }
// return ret;
// },
// ],
// maxContentLength: 2000,
validateStatus(status) {
return status >= 200 && status < 300; // default
},
};
let debugUser: PcDebugUser = {
DebugUser: "zhd",
AppType: "ChildOptCourse",
};
export { baseConfig, debugUser };
+40
View File
@@ -0,0 +1,40 @@
import { BaseConf } from "@/types/Basics";
/**
* 通过 Vite 环境变量管理配置,不再依赖 window.conf / config.js
* 环境变量定义在项目根目录的 .env.dev / .env.base / .env.ld 中
*/
const env = import.meta.env;
let conf: BaseConf = {
baseHost: env.VITE_BASE_HOST,
ssoHost: env.VITE_SSO_HOST,
serviceHost: env.VITE_SERVICE_HOST,
relayConf: {
ziyuankuHost: env.VITE_ZIYUANKU_HOST,
zhuanxiangHost: env.VITE_ZHUANXIANG_HOST,
},
isMock: env.VITE_IS_MOCK === "true",
isDebug: env.DEV,
};
// HTTPS 自动升级:当前页面是 https 时,将所有 http:// 配置项升级为 https://
var ishttps = "https:" == document.location.protocol ? true : false;
if (ishttps) {
Object.keys(conf).forEach(element => {
if (typeof conf[element] === "string" && conf[element].indexOf("http://") > -1) {
conf[element] = conf[element].replace("http://", "https://");
}
});
// relayConf 内部也需要处理
if (conf.relayConf) {
Object.keys(conf.relayConf).forEach(key => {
const val = (conf.relayConf as any)[key];
if (typeof val === "string" && val.indexOf("http://") > -1) {
(conf.relayConf as any)[key] = val.replace("http://", "https://");
}
});
}
}
export default conf;
+100
View File
@@ -0,0 +1,100 @@
import { RootNodeDict } from "@/types";
import { cloneDeep } from "lodash";
const beforeCount = 7;
const ROUTE_MAP: any = {
0: {
superAdmin: [{ page: "/", name: "学习中心管理", icon: "home", modId: 1001 }],
school: [{ page: "/", name: "学习中心管理", icon: "home", modId: 1001 }],
teacher: [{ page: "/", name: "学习中心管理", icon: "home", modId: 1001 }],
},
1: {
superAdmin: [{ page: "/subject", name: "学段学科设置", icon: "home", modId: 1002 }],
school: [{ page: "/subject", name: "学段学科设置", icon: "home", modId: 1002 }],
teacher: [],
},
2: {
superAdmin: [
{ page: "/textbook/list", name: "基础教材设置", icon: "home", modId: 2001 },
{ page: "/textbook/school", name: "学校教材设置", icon: "home", modId: 2002 },
{ page: "/textbook/manage", name: "教材管理", icon: "home", modId: 2004 },
],
school: [
{ page: "/textbook", name: "教材设置", icon: "home", modId: 2003 },
{ page: "/textbook/manage", name: "教材管理", icon: "home", modId: 2004 },
],
teacher: [],
},
3: {
superAdmin: [
{ page: "/tutorboox/list", name: "基础教辅设置", icon: "home", modId: 3001 },
{ page: "/tutorboox/school", name: "学校教辅设置", icon: "home", modId: 3002 },
{ page: "/tutorboox/manage", name: "教辅管理", icon: "home", modId: 3004 },
],
school: [
{ page: "/tutorboox", name: "教辅设置", icon: "home", modId: 3003 },
{ page: "/tutorboox/manage", name: "教辅管理", icon: "home", modId: 3004 },
],
teacher: [],
},
4: {
superAdmin: [
{ page: "/knowbook/list", name: "基础知识点设置", icon: "home", modId: 4001 },
{ page: "/knowbook/school", name: "学校知识点设置", icon: "home", modId: 4002 },
{ page: "/knowbook/manage", name: "知识点管理", icon: "home", modId: 4004 },
],
school: [
{ page: "/knowbook", name: "知识点设置", icon: "home", modId: 4003 },
{ page: "/knowbook/manage", name: "知识点管理", icon: "home", modId: 4004 },
],
teacher: [],
},
5: {
superAdmin: [{ page: "/nodeauthorize", name: "开通设置", icon: "home", modId: 5001 }],
school: [{ page: "/nodeauthorize", name: "开通设置", icon: "home", modId: 5001 }],
teacher: [],
},
6: {
superAdmin: [{ page: "/interacttask", name: "交互设置", icon: "home", modId: 6001 }],
school: [{ page: "/interacttask", name: "交互设置", icon: "home", modId: 6001 }],
teacher: [],
},
};
export function getLeftMenuRoutes(entranceId: number, identity: number) {
const tempMap: any = cloneDeep(ROUTE_MAP);
RootNodeDict.forEach((element, index) => {
const idx = beforeCount + 1 + index;
const item = {
superAdmin: [
{
page: `/${element.path}/tree`,
name: element.v + "目录树",
icon: "home",
modId: idx * 1000 + 1,
},
{ page: "/enable/" + (index + 1), name: element.v + "目录开通", modId: idx * 1000 + 2 },
],
school: [{ page: `/${element.path}/tree`, name: "目录树列表", icon: "home", modId: idx * 1000 + 1 }],
teacher: [],
};
tempMap[idx] = item;
});
const entrance = tempMap[entranceId];
if (!entrance) return [];
let key: any = {
1: "superAdmin",
2: "school",
3: "teacher",
};
const list = entrance[key[identity]];
return list || [];
}
export function getRoutes(entranceId: number, identity: number, modId: number) {
const list = getLeftMenuRoutes(entranceId, identity);
return list.find((item: any) => item.modId === modId);
}
export { beforeCount };
+68
View File
@@ -0,0 +1,68 @@
import type { IModule } from "@/store";
/**
* 左侧菜单数据(系统管理功能分组)
* ----------------------------------------------------------------
* 当前直接 Promise.resolve 返回写死数据;后续接入真实接口时,
* 只需把 `return Promise.resolve(menu)` 替换为
* `return alovaInstance.Request(Apis.xxx.getMenu())`
* 即可无缝对接,调用方(store.fetchModules)无需任何改动。
*
* 分组结构:
* 1. 组,用户管理 —— 顶层独立选项卡(单页)
* 2. 应用管理 —— 顶层独立选项卡(= 应用列表主页 /app-manage/list);
* 页内按钮跳转「应用类别管理」子页(/app-manage/category,不在菜单里,
* 由 routes.ts 的 meta.parentId=1102 关联,面包屑「应用管理>应用类别管理」)
* 3. 权限管理 —— 父目录:应用开通 / 组授权 / 权限一览
* 4. 日志管理 —— 父目录:接口日志 / 系统日志
*
* 每个节点带唯一 id;子节点的 pid 由 layout.vue 的 flaten() 扁平化时
* 依据父节点 id 自动推导,用于「高亮自身 + 面包屑展示父级」联动。
* 菜单项不再渲染 icon。
*/
export function getMenuList(): Promise<IModule[]> {
const menu: IModule[] = [
// 1. 组,用户管理(顶层独立选项卡)
{
id: 1,
modId: 1101,
name: "组,用户管理",
page: "/group-user",
},
// 2. 应用管理(顶层独立选项卡,= 应用列表主页;页内按钮跳转应用类别管理子页)
{
id: 2,
modId: 1102,
name: "应用管理",
page: "/app-manage/list",
},
// 3. 权限管理(父目录)
{
id: 4,
modId: 1108,
name: "权限管理",
page: "",
childState: true,
children: [
{ id: 41, modId: 1103, name: "应用开通", page: "/app-open" },
{ id: 42, modId: 1104, name: "组授权", page: "/group-auth" },
{ id: 44, modId: 1110, name: "角色授权", page: "/role-authz/list" },
{ id: 43, modId: 1105, name: "权限一览", page: "/permission-view" },
],
},
// 4. 日志管理(父目录)
{
id: 5,
modId: 1109,
name: "日志管理",
page: "",
childState: true,
children: [
{ id: 51, modId: 1106, name: "接口日志", page: "/api-log" },
{ id: 52, modId: 1107, name: "系统日志", page: "/sys-log" },
{ id: 53, modId: 1111, name: "操作日志", page: "/oplog" },
],
},
];
return Promise.resolve(menu);
}