This commit is contained in:
Zyronon
2025-10-19 03:55:13 +08:00
parent ad1bdf4690
commit 03e38d1ce6
6 changed files with 37 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import http from "@/utils/http.ts";
import http, { axiosInstance } from "@/utils/http.ts";
import { Dict } from "@/types/types.ts";
import { cloneDeep } from "@/utils";
@@ -47,3 +47,14 @@ export function getSetting(params?, data?) {
export function addDict(params?, data?) {
return http<Dict>('dict/addDict', remove(data), remove(params), 'post')
}
export function uploadImportData(data) {
return axiosInstance({
url: 'dict/uploadImportData',
method: 'post',
headers: {
contentType: 'formdata',
},
data,
})
}

View File

@@ -18,7 +18,7 @@ const map = {
export const ENV = Object.assign(map['DEV'], common)
export const IS_OFFICIAL = import.meta.env.DEV
// export const IS_OFFICIAL = false
export let IS_LOGIN = false
export let IS_LOGIN = true
export const CAN_REQUEST = IS_LOGIN && IS_OFFICIAL
export const RESOURCE_PATH = ENV.API + 'static'

View File

@@ -6,8 +6,9 @@ import router from "@/router.ts";
onMounted(() => {
if (!IS_LOGIN) {
router.push({path: "/login"});
}
router.push({path: "/login"});
})
</script>

View File

@@ -2,16 +2,26 @@
import BaseInput from "@/components/base/BaseInput.vue";
import BaseButton from "@/components/BaseButton.vue";
import { APP_NAME } from "@/config/env.ts";
import { uploadImportData } from "@/apis";
function sync() {
}
function handleAudioChange(e) {
let uploadFile = e.target?.files?.[0]
if (!uploadFile) return
let data = new FormData();
data.append("file", uploadFile);
uploadImportData(data)
console.log(uploadFile)
}
</script>
<template>
<div class="center h-screen">
<div class="center flex flex-col gap-6">
<h1 class="mb-0">{{ APP_NAME }}</h1>
<div class=" flex flex-col gap-6 w-100">
<h1 class="mb-0 text-align-center">{{ APP_NAME }}</h1>
<div class="flex center">
<span class="shrink-0">账户</span>
<BaseInput type="text"/>
@@ -22,6 +32,13 @@ function sync() {
</div>
<BaseButton class="w-full">登录</BaseButton>
<BaseButton class="w-full" @click="sync">同步</BaseButton>
<div class="upload relative">
<BaseButton>上传</BaseButton>
<input type="file"
accept=".zip,.json"
@change="handleAudioChange"
class="w-full h-full absolute left-0 top-0 opacity-0"/>
</div>
<div class="w-full flex justify-end gap-4">
<div>注册</div>

View File

@@ -26,9 +26,8 @@ import { getCurrentStudyWord } from "@/hooks/dict.ts";
import PracticeSettingDialog from "@/pages/word/components/PracticeSettingDialog.vue";
import { useSettingStore } from "@/stores/setting.ts";
import { MessageBox } from "@/utils/MessageBox.tsx";
import { CAN_REQUEST, Origin } from "@/config/env.ts";
import { CAN_REQUEST, Origin, PracticeSaveWordKey } from "@/config/env.ts";
import { detail } from "@/apis";
import { PracticeSaveWordKey } from "@/utils/const.ts";
const runtimeStore = useRuntimeStore()
const base = useBaseStore()
@@ -369,7 +368,7 @@ async function exportData() {
}
function searchWord() {
console.log('wordForm.word',wordForm.word)
console.log('wordForm.word', wordForm.word)
}
defineRender(() => {

View File

@@ -90,7 +90,7 @@ type AxiosResponse<T> = { code: number, data: T, success: boolean, msg: string }
async function request<T>(url, data = {}, params = {}, method): Promise<AxiosResponse<T>> {
return axiosInstance({
url: '/v1/' + url,
url: url,
method,
data,
params,