refactor Setting
This commit is contained in:
@@ -5,7 +5,21 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { Copyright } from "timi-web";
|
||||
import {axios, Copyright, SettingMapper} from "timi-web";
|
||||
import CommonAPI from "../src/api/CommonAPI";
|
||||
|
||||
onMounted(async () => {
|
||||
const result = await CommonAPI.settingMap({
|
||||
"SYSTEM": [
|
||||
"SETTING_TTL"
|
||||
]
|
||||
});
|
||||
SettingMapper.appendSettingMap(result);
|
||||
|
||||
|
||||
console.log(SettingMapper.getValue("SYSTEM", "SETTING_TTL").value);
|
||||
})
|
||||
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.root {
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
import { createApp } from "vue";
|
||||
import {createApp} from "vue";
|
||||
import Root from "./Root.vue";
|
||||
import { VPopup } from "timi-web"; // 本地开发
|
||||
import {axios, Network, VPopup} from "timi-web";
|
||||
|
||||
axios.defaults.baseURL = import.meta.env.VITE_API;
|
||||
axios.interceptors.request.use((config) => {
|
||||
const token = "V8khmLKkec1ahtjzFm2kx65wvmHob8N5lonqfUy3SsfxJ2HevYi8tLrxrL1iprcl";
|
||||
if (token) {
|
||||
if (config.method === "get") {
|
||||
config.params = {
|
||||
token,
|
||||
...config.params
|
||||
};
|
||||
}
|
||||
config.headers.set({ "Token": token });
|
||||
}
|
||||
return config;
|
||||
}, (error: any) => {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
const app = createApp(Root);
|
||||
app.directive("popup", VPopup);
|
||||
|
||||
8
examples/vite-env.d.ts
vendored
8
examples/vite-env.d.ts
vendored
@@ -5,3 +5,11 @@ declare module "*.vue" {
|
||||
}
|
||||
|
||||
declare module "prismjs";
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user