fix and refactor code
This commit is contained in:
@@ -58,22 +58,18 @@
|
||||
<button type="submit" class="btn-primary">{{ t('settings.save') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div v-if="message" class="mt-4 p-3 rounded-lg" :class="messageClass">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue';
|
||||
import AppLayout from '../components/Layout/AppLayout.vue';
|
||||
import AppLayout from '@/components/Layout/AppLayout.vue';
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useNotification } from '../composables/useNotification'
|
||||
import { useNotification } from '@/composables/useNotification'
|
||||
|
||||
const { showNotification } = useNotification()
|
||||
const { t, locale } = useI18n()
|
||||
const { t } = useI18n()
|
||||
interface FieldMeta {
|
||||
key: string;
|
||||
label: string;
|
||||
@@ -86,11 +82,9 @@ interface FieldMeta {
|
||||
|
||||
const meta = ref<FieldMeta[]>([]);
|
||||
const values = ref<Record<string, string>>({});
|
||||
const message = ref('');
|
||||
const messageClass = ref('');
|
||||
|
||||
async function loadMeta() {
|
||||
const res = await fetch('/api/settings/meta');
|
||||
const res = await fetch('/api/admin/settings/meta');
|
||||
if (res.ok) {
|
||||
meta.value = await res.json();
|
||||
} else {
|
||||
@@ -99,7 +93,7 @@ async function loadMeta() {
|
||||
}
|
||||
|
||||
async function loadValues() {
|
||||
const res = await fetch('/api/settings/all');
|
||||
const res = await fetch('/api/admin/settings');
|
||||
if (res.ok) {
|
||||
values.value = await res.json();
|
||||
} else {
|
||||
@@ -128,13 +122,5 @@ async function saveSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage(text: string, cssClass: string) {
|
||||
message.value = text;
|
||||
messageClass.value = cssClass;
|
||||
setTimeout(() => {
|
||||
message.value = '';
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
onMounted(loadData);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user