refactor: welcome.setup.vue to composition api

This commit is contained in:
Norm 2022-08-01 16:57:34 -04:00 committed by Gitea
parent a615a76cf1
commit 30d8bc9259

View file

@ -21,50 +21,37 @@
</form> </form>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { } from 'vue';
import MkButton from '@/components/ui/button.vue'; import MkButton from '@/components/ui/button.vue';
import MkInput from '@/components/form/input.vue'; import MkInput from '@/components/form/input.vue';
import { host } from '@/config'; import { host } from '@/config';
import * as os from '@/os'; import * as os from '@/os';
import { login } from '@/account'; import { login } from '@/account';
import { i18n } from '@/i18n';
export default defineComponent({ let username = $ref('');
components: { let password = $ref('');
MkButton, let submitting = $ref(false);
MkInput,
},
data() { function submit(): void {
return { if (submitting) return;
username: '', submitting = true;
password: '',
submitting: false,
host,
};
},
methods: { os.api('admin/accounts/create', {
submit() { username,
if (this.submitting) return; password,
this.submitting = true; }).then(res => {
return login(res.token);
}).catch(() => {
submitting = false;
os.api('admin/accounts/create', { os.alert({
username: this.username, type: 'error',
password: this.password, text: i18n.ts.somethingHappened,
}).then(res => { });
return login(res.token); });
}).catch(() => { }
this.submitting = false;
os.alert({
type: 'error',
text: this.$ts.somethingHappened
});
});
}
}
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>