-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21852 from mshima/skip_ci-vue-composition-api
Start converting vue to composition api.
- Loading branch information
Showing
57 changed files
with
784 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 33 additions & 30 deletions
63
generators/vue/templates/src/main/webapp/app/account/activate/activate.component.ts.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
import Component from 'vue-class-component'; | ||
import { Vue, Inject } from 'vue-property-decorator'; | ||
import { defineComponent, inject, ref, Ref } from 'vue'; | ||
import LoginService from '@/account/login.service'; | ||
import ActivateService from './activate.service'; | ||
import { useRouter } from 'vue-router/composables'; | ||
|
||
@Component | ||
export default class Activate extends Vue { | ||
@Inject('activateService') | ||
private activateService: () => ActivateService; | ||
@Inject('loginService') | ||
private loginService: () => LoginService; | ||
success = false; | ||
error = false; | ||
export default defineComponent({ | ||
setup() { | ||
const activateService = inject('activateService', () => new ActivateService(), true); | ||
const loginService = inject('loginService', () => new LoginService()); | ||
const router = useRouter(); | ||
|
||
beforeRouteEnter(to, from, next) { | ||
next(vm => { | ||
if (to.query.key) { | ||
vm.init(to.query.key); | ||
const success: Ref<boolean> = ref(false); | ||
const error: Ref<boolean> = ref(false); | ||
|
||
router.beforeEach(async (to) => { | ||
const key = Array.isArray(to.query.key) ? to.query.key[0] : to.query.key; | ||
try { | ||
await activateService.activateAccount(key); | ||
success.value = true; | ||
error.value = false; | ||
} catch { | ||
error.value = true; | ||
success.value = false; | ||
} | ||
}); | ||
} | ||
|
||
public init(key: string): void { | ||
this.activateService().activateAccount(key) | ||
.then(() => { | ||
this.success = true; | ||
this.error = false; | ||
}, () => { | ||
this.error = true; | ||
this.success = false; | ||
}); | ||
} | ||
|
||
public openLogin(): void { | ||
this.loginService().openLogin((<any>this).$root); | ||
} | ||
} | ||
return { | ||
router, | ||
activateService, | ||
loginService, | ||
success, | ||
error, | ||
}; | ||
}, | ||
methods: { | ||
openLogin(): void { | ||
this.loginService.openLogin((<any>this).$root); | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.