1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-07-02 17:29:23 +00:00
Classworks/src/pages/ServerSelection.vue
孙悟元 58e286d80b Add server selection page
Add a new page for server selection and update backend URL handling.

* **ServerSelection.vue**: Create a new Vue component with a form to input and save the backend server URL to `localStorage`. Add methods to handle form submission and load the saved URL on component mount.
* **index.vue**: Update the `data` method to retrieve the backend URL from `localStorage`. Remove the hardcoded `backurl` value. Add a method to update the backend URL from `localStorage` on component mount. Update API requests to use the dynamic backend URL.
* **router/index.js**: Add a new route for the `ServerSelection` component.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/SunWuyuan/homeworkpage-frontend?shareId=XXXX-XXXX-XXXX-XXXX).
2024-11-24 08:55:05 +08:00

38 lines
723 B
Vue

<template>
<v-container>
<v-form @submit.prevent="saveServerUrl">
<v-text-field
v-model="serverUrl"
label="Backend Server URL"
required
/>
<v-btn type="submit" color="primary">Save</v-btn>
</v-form>
</v-container>
</template>
<script>
export default {
data() {
return {
serverUrl: ''
};
},
methods: {
saveServerUrl() {
localStorage.setItem('backendServerUrl', this.serverUrl);
alert('Server URL saved!');
},
loadServerUrl() {
const savedUrl = localStorage.getItem('backendServerUrl');
if (savedUrl) {
this.serverUrl = savedUrl;
}
}
},
mounted() {
this.loadServerUrl();
}
};
</script>