mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-09-17 08:46:39 +08:00
后台界面
1. 演示帐号动态配置 2. vite 动态加载异常问题修复
This commit is contained in:
parent
c9af5ae093
commit
6f8761756a
@ -11,7 +11,7 @@ VITE_DROP_CONSOLE=true
|
|||||||
|
|
||||||
# 跨域代理,可以配置多个,请注意不要换行,如果是公网运行,请改成公网IP:服务端运行端口
|
# 跨域代理,可以配置多个,请注意不要换行,如果是公网运行,请改成公网IP:服务端运行端口
|
||||||
#VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]]
|
#VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]]
|
||||||
VITE_PROXY=[["/admin","http://localhost:8000/admin"]]
|
VITE_PROXY=[["/admin","http://api-breeding.dap.5gfd.com.cn/admin"]]
|
||||||
|
|
||||||
# API 接口地址
|
# API 接口地址
|
||||||
VITE_GLOB_API_URL=
|
VITE_GLOB_API_URL=
|
||||||
@ -24,3 +24,10 @@ VITE_GLOB_IMG_URL=
|
|||||||
|
|
||||||
# 接口前缀
|
# 接口前缀
|
||||||
VITE_GLOB_API_URL_PREFIX=/admin
|
VITE_GLOB_API_URL_PREFIX=/admin
|
||||||
|
|
||||||
|
# 快速登录账号密码配置,没有配置则不开启快速登录
|
||||||
|
## 格式为 [["账号名称","账号密码","角色名称"],["账号名称","账号密码"],["账号名称"]]
|
||||||
|
## 帐号名称不能为空,密码为空则和帐号名称相同
|
||||||
|
## 角色名称可选,如果不填写则默认使用账号名称作为角色名称
|
||||||
|
## 账号名称和角色名称可以重复,账号名称和密码可以重复
|
||||||
|
VITE_APP_DEMO_ACCOUNT=[["admin","123456","超管"],["test","123456","管理员"],["ameng","123456","租户"],["abai","123456","商户"],["asong","123456","用户"]]
|
@ -34,7 +34,7 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
|||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
ret[envName] = realName;
|
ret[envName] = realName;
|
||||||
process.env[envName] = realName;
|
// process.env[envName] = realName;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
43
web/src/debug/account.ts
Normal file
43
web/src/debug/account.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { isArray } from "@/utils/is";
|
||||||
|
|
||||||
|
interface Account {
|
||||||
|
/**
|
||||||
|
* 账号名称
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
username: string;
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取配置的账号信息
|
||||||
|
* @returns {[]Account} 返回账号信息数组
|
||||||
|
*/
|
||||||
|
export function getDemoAccounts() {
|
||||||
|
|
||||||
|
let envConf = import.meta.env.VITE_APP_DEMO_ACCOUNT || "";
|
||||||
|
// 帐号密码一样
|
||||||
|
// [["username"],["username","password"],["username","password","name"]]
|
||||||
|
try {
|
||||||
|
let accounts = JSON.parse(envConf);
|
||||||
|
if (accounts && isArray(accounts)) {
|
||||||
|
return accounts.map((item: String[]) => {
|
||||||
|
let [username = "", password = "", name = ""] = item;
|
||||||
|
username = username;
|
||||||
|
password = password || username;
|
||||||
|
name = name || username;
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
} as Account;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
return [] as Account[];
|
||||||
|
}
|
@ -1,60 +1,37 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-space :vertical="true">
|
<template v-if="accounts && accounts.length > 0">
|
||||||
<n-divider>演示角色登录</n-divider>
|
<n-space :vertical="true">
|
||||||
<n-space justify="center">
|
<n-divider>演示角色登录</n-divider>
|
||||||
<n-button
|
<n-space justify="center">
|
||||||
v-for="item in accounts"
|
<n-button
|
||||||
:key="item.username"
|
v-for="item in accounts"
|
||||||
type="primary"
|
:key="item.username"
|
||||||
@click="login(item.username, item.password)"
|
type="primary"
|
||||||
>
|
@click="login(item.username, item.password)"
|
||||||
{{ item.label }}
|
>
|
||||||
</n-button>
|
{{ item.name }}
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
<n-space justify="center" class="mt-2">
|
||||||
|
<n-text depth="3">SaaS系统多租户多应用设计</n-text>
|
||||||
|
</n-space>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-space justify="center" class="mt-2">
|
</template>
|
||||||
<n-text depth="3">SaaS系统多租户多应用设计</n-text>
|
|
||||||
</n-space>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
interface Emits {
|
import { getDemoAccounts } from "@/debug/account";
|
||||||
(e: 'login', param: { username: string; password: string }): void;
|
interface Emits {
|
||||||
}
|
(e: "login", param: { username: string; password: string }): void;
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
const accounts = [
|
const accounts = getDemoAccounts();
|
||||||
{
|
|
||||||
label: '超管',
|
|
||||||
username: 'admin',
|
|
||||||
password: '123456',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '管理员',
|
|
||||||
username: 'test',
|
|
||||||
password: '123456',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '租户',
|
|
||||||
username: 'ameng',
|
|
||||||
password: '123456',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '商户',
|
|
||||||
username: 'abai',
|
|
||||||
password: '123456',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '用户',
|
|
||||||
username: 'asong',
|
|
||||||
password: '123456',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
function login(username: string, password: string) {
|
function login(username: string, password: string) {
|
||||||
emit('login', { username, password });
|
emit("login", { username, password });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
Loading…
Reference in New Issue
Block a user