feat(admin): scope page

This commit is contained in:
FoskyM 2023-10-01 19:53:59 +08:00
parent 8bf8ab40ab
commit 811957b468
No known key found for this signature in database
GPG key ID: 42C0ED6994AD7E9C
6 changed files with 17 additions and 3 deletions

BIN
js/dist/admin.js generated vendored

Binary file not shown.

BIN
js/dist/admin.js.map generated vendored

Binary file not shown.

BIN
js/dist/forum.js generated vendored

Binary file not shown.

BIN
js/dist/forum.js.map generated vendored

Binary file not shown.

View file

@ -82,7 +82,9 @@ export default class ScopesPage extends Page {
className: 'Button Button--block', className: 'Button Button--block',
onclick: () => { onclick: () => {
const scope = app.store.createRecord('oauth-scopes'); const scope = app.store.createRecord('oauth-scopes');
scope.save({}).then(this.scopes.push(scope)); scope.save({
'scope': 'Scope.' + this.randomString(8),
}).then(this.scopes.push(scope));
}, },
}, app.translator.trans(this.translationPrefix + 'add_button')))), }, app.translator.trans(this.translationPrefix + 'add_button')))),
]), ]),
@ -92,7 +94,17 @@ export default class ScopesPage extends Page {
</div> </div>
); );
} }
randomString(len) {
len = len || 8;
let $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let maxPos = $chars.length;
let str = '';
for (let i = 0; i < len; i++) {
//0~32的整数
str += $chars.charAt(Math.floor(Math.random() * (maxPos + 1)));
}
return str;
}
saveScopeInfo(index, key, value) { saveScopeInfo(index, key, value) {
console.log(index, key, value); console.log(index, key, value);
this.scopes[index].save({ this.scopes[index].save({

View file

@ -20,6 +20,8 @@ class CreateScopeController extends AbstractListController
$attributes = Arr::get($request->getParsedBody(), 'data.attributes'); $attributes = Arr::get($request->getParsedBody(), 'data.attributes');
return Scope::create([]); return Scope::create([
'scope' => Arr::get($attributes, 'scope'),
]);
} }
} }