Skip to content

Commit

Permalink
新增演示账号显示
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 10, 2021
1 parent 8987a2d commit 4a451ad
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 16 deletions.
30 changes: 26 additions & 4 deletions app/Http/Controllers/Api/SystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function setting()
if (env("SYSTEM_SETTING") == 'disabled') {
return Base::retError('当前环境禁止修改');
}
$user = User::auth();
$user->isAdmin();
User::auth('admin');
$all = Request::input();
foreach ($all AS $key => $value) {
if (!in_array($key, ['reg', 'login_code'])) {
Expand All @@ -56,6 +55,30 @@ public function setting()
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. 获取优先级、保存优先级
*
Expand All @@ -73,8 +96,7 @@ public function priority()
{
$type = trim(Request::input('type'));
if ($type == 'save') {
$user = User::auth();
$user->isAdmin();
User::auth('admin');
$list = Base::getPostValue('list');
$array = [];
if (empty($list) || !is_array($list)) {
Expand Down
27 changes: 22 additions & 5 deletions resources/assets/js/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<div v-if="loginType=='reg'" class="login-subtitle">{{$L('输入您的信息以创建帐户。')}}</div>
<div v-else class="login-subtitle">{{$L('输入您的凭证以访问您的帐户。')}}</div>

<div class="login-testuser">
{{$L('演示账号')}}: <em>admin@dootask.com</em>&nbsp;&nbsp;
{{$L('密码')}}: <em>123456</em>
</div>
<ul v-if="demoAccount.account" class="login-demo">
<li>{{$L('演示账号')}}: <em>{{demoAccount.account}}</em></li>
<li>{{$L('密码')}}: <em>{{demoAccount.password}}</em></li>
</ul>

<div class="login-input">
<Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" />
Expand Down Expand Up @@ -64,10 +64,13 @@ export default {
password2: '',
code: '',
downList: []
demoAccount: {},
downList: [],
}
},
mounted() {
this.getDemoAccount();
if (!this.isElectron) {
this.getAppInfo();
}
Expand All @@ -78,6 +81,20 @@ export default {
}
},
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() {
this.$store.dispatch("call", {
url: 'system/get/appinfo',
Expand Down
21 changes: 14 additions & 7 deletions resources/assets/sass/pages/page-login.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,25 @@
padding: 0 12px;
color: #AAAAAA;
}
.login-testuser {
.login-demo {
margin-top: 30px;
margin-bottom: -36px;
//display: flex;
display: none;
display: flex;
align-items: center;
justify-content: center;
color: #888888;
> em {
font-style: normal;
text-decoration: underline;
margin-left: 2px;
> li {
list-style: none;
padding: 0;
margin-right: 6px;
&:last-child {
margin-right: 0;
}
> em {
font-style: normal;
text-decoration: underline;
margin-left: 2px;
}
}
}
.login-input {
Expand Down

0 comments on commit 4a451ad

Please sign in to comment.