新增演示账号显示

This commit is contained in:
kuaifan 2021-12-10 22:22:19 +08:00
parent 8987a2d177
commit 4a451ad5ae
3 changed files with 62 additions and 16 deletions

View File

@ -37,8 +37,7 @@ class SystemController extends AbstractController
if (env("SYSTEM_SETTING") == 'disabled') { if (env("SYSTEM_SETTING") == 'disabled') {
return Base::retError('当前环境禁止修改'); return Base::retError('当前环境禁止修改');
} }
$user = User::auth(); User::auth('admin');
$user->isAdmin();
$all = Request::input(); $all = Request::input();
foreach ($all AS $key => $value) { foreach ($all AS $key => $value) {
if (!in_array($key, ['reg', 'login_code'])) { if (!in_array($key, ['reg', 'login_code'])) {
@ -56,6 +55,30 @@ class SystemController extends AbstractController
return Base::retSuccess('success', $setting ?: json_decode('{}')); return Base::retSuccess('success', $setting ?: json_decode('{}'));
} }
/**
* @api {get} api/system/demo 获取演示账号
*
* @apiVersion 1.0.0
* @apiGroup system
* @apiName demo
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function demo()
{
$demo_account = env('DEMO_ACCOUNT');
$demo_password = env('DEMO_PASSWORD');
if (empty($demo_account) || empty($demo_password)) {
return Base::retError('No demo account');
}
return Base::retSuccess('success', [
'account' => $demo_account,
'password' => $demo_password,
]);
}
/** /**
* @api {post} api/system/priority 02. 获取优先级、保存优先级 * @api {post} api/system/priority 02. 获取优先级、保存优先级
* *
@ -73,8 +96,7 @@ class SystemController extends AbstractController
{ {
$type = trim(Request::input('type')); $type = trim(Request::input('type'));
if ($type == 'save') { if ($type == 'save') {
$user = User::auth(); User::auth('admin');
$user->isAdmin();
$list = Base::getPostValue('list'); $list = Base::getPostValue('list');
$array = []; $array = [];
if (empty($list) || !is_array($list)) { if (empty($list) || !is_array($list)) {

View File

@ -9,10 +9,10 @@
<div v-if="loginType=='reg'" class="login-subtitle">{{$L('输入您的信息以创建帐户')}}</div> <div v-if="loginType=='reg'" class="login-subtitle">{{$L('输入您的信息以创建帐户')}}</div>
<div v-else class="login-subtitle">{{$L('输入您的凭证以访问您的帐户。')}}</div> <div v-else class="login-subtitle">{{$L('输入您的凭证以访问您的帐户。')}}</div>
<div class="login-testuser"> <ul v-if="demoAccount.account" class="login-demo">
{{$L('演示账号')}}: <em>admin@dootask.com</em>&nbsp;&nbsp; <li>{{$L('演示账号')}}: <em>{{demoAccount.account}}</em></li>
{{$L('密码')}}: <em>123456</em> <li>{{$L('密码')}}: <em>{{demoAccount.password}}</em></li>
</div> </ul>
<div class="login-input"> <div class="login-input">
<Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" /> <Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" />
@ -64,10 +64,13 @@ export default {
password2: '', password2: '',
code: '', code: '',
downList: [] demoAccount: {},
downList: [],
} }
}, },
mounted() { mounted() {
this.getDemoAccount();
if (!this.isElectron) { if (!this.isElectron) {
this.getAppInfo(); this.getAppInfo();
} }
@ -78,6 +81,20 @@ export default {
} }
}, },
methods: { methods: {
getDemoAccount() {
this.$store.dispatch("call", {
url: 'system/demo',
}).then(({data}) => {
this.demoAccount = data;
if (data.account) {
this.email = data.account;
this.password = data.password;
}
}).catch(() => {
this.demoAccount = {};
});
},
getAppInfo() { getAppInfo() {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'system/get/appinfo', url: 'system/get/appinfo',

View File

@ -42,18 +42,25 @@
padding: 0 12px; padding: 0 12px;
color: #AAAAAA; color: #AAAAAA;
} }
.login-testuser { .login-demo {
margin-top: 30px; margin-top: 30px;
margin-bottom: -36px; margin-bottom: -36px;
//display: flex; display: flex;
display: none;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: #888888; color: #888888;
> em { > li {
font-style: normal; list-style: none;
text-decoration: underline; padding: 0;
margin-left: 2px; margin-right: 6px;
&:last-child {
margin-right: 0;
}
> em {
font-style: normal;
text-decoration: underline;
margin-left: 2px;
}
} }
} }
.login-input { .login-input {