beelink/src/App.vue
2020-12-11 14:09:16 +08:00

90 lines
2.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!-- <div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div> -->
<a-config-provider :locale="len.$s() == 'zh' ? zh : en">
<router-view />
</a-config-provider>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import router from "./router";
import store from "./store";
import { getValue, toindex } from "./utils/common";
import { provideI18n } from "@/utils/i18n";
import i18ninit from "@/i18n/init";
import enUS from "ant-design-vue/es/locale/en_US";
import zhCN from "ant-design-vue/es/locale/zh_CN";
import dayjs, { locale } from "dayjs";
import { getaddr } from "./api";
import { useRoute } from "vue-router";
export default defineComponent({
setup() {
console.log(i18ninit);
const len = provideI18n(i18ninit);
function GetUrlRelativePath() {
const url = document.location.toString();
const arrUrl = url.split("//");
const start = arrUrl[1].indexOf("/");
let relUrl = arrUrl[1].substring(start); //stop省略截取从start开始到结尾的所有字符
if (relUrl.indexOf("?") != -1) {
relUrl = relUrl.split("?")[0];
}
return relUrl;
}
// len.locale.value = !getValue("Lanvuage") ? 'zh' : getValue("Lanvuage");
if (getValue("token")) {
console.log("token");
store.commit("login", true);
store.dispatch("getcode");
store.dispatch("setUserInfo");
const patn = useRoute().path;
console.log(GetUrlRelativePath(), 444);
if (GetUrlRelativePath() == "/") {
router.push("/mine/archives").then(() => {
location.reload();
});
}
} else {
console.log("ip");
store.dispatch("getip");
store.commit("setWlan");
toindex()
}
store.dispatch("getinfotext");
store.dispatch("getindexarr");
const zh = zhCN;
const en = enUS;
return {
zh,
en,
len,
};
},
});
</script>
<style lang="scss">
div {
user-select: none;
}
.one-line-hide {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input[type="number"] {
-moz-appearance: textfield;
}
</style>