mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: improve site global scripts
This commit is contained in:
parent
f7f5c6e9b5
commit
5ecf7460cf
@ -1,4 +1,4 @@
|
|||||||
<div class="card">
|
<div class="van-doc-card">
|
||||||
<div class="van-doc-intro">
|
<div class="van-doc-intro">
|
||||||
<img class="van-doc-intro__logo" style="width: 120px; height: 120px;" src="https://img.yzcdn.cn/vant/logo.png">
|
<img class="van-doc-intro__logo" style="width: 120px; height: 120px;" src="https://img.yzcdn.cn/vant/logo.png">
|
||||||
<h2 style="margin: 0; font-size: 36px; line-height: 60px;">Vant</h2>
|
<h2 style="margin: 0; font-size: 36px; line-height: 60px;">Vant</h2>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="card">
|
<div class="van-doc-card">
|
||||||
<div class="van-doc-intro">
|
<div class="van-doc-intro">
|
||||||
<img class="van-doc-intro__logo" style="width: 120px; height: 120px;" src="https://img.yzcdn.cn/vant/logo.png">
|
<img class="van-doc-intro__logo" style="width: 120px; height: 120px;" src="https://img.yzcdn.cn/vant/logo.png">
|
||||||
<h2 style="margin: 0; font-size: 36px; line-height: 60px;">Vant</h2>
|
<h2 style="margin: 0; font-size: 36px; line-height: 60px;">Vant</h2>
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
import Locale from '../../src/locale';
|
|
||||||
import enUS from '../../src/locale/lang/en-US';
|
|
||||||
|
|
||||||
export function initDemoLocale() {
|
|
||||||
Locale.add({
|
|
||||||
'en-US': enUS,
|
|
||||||
});
|
|
||||||
|
|
||||||
// switch lang after routing
|
|
||||||
if (window.vueRouter) {
|
|
||||||
window.vueRouter.afterEach((to) => {
|
|
||||||
const { lang } = to.meta || {};
|
|
||||||
|
|
||||||
if (lang) {
|
|
||||||
Locale.use(lang);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// add some basic locale messages
|
|
||||||
Locale.add({
|
|
||||||
'zh-CN': {
|
|
||||||
add: '增加',
|
|
||||||
decrease: '减少',
|
|
||||||
red: '红色',
|
|
||||||
orange: '橙色',
|
|
||||||
yellow: '黄色',
|
|
||||||
purple: '紫色',
|
|
||||||
tab: '标签',
|
|
||||||
tag: '标签',
|
|
||||||
desc: '描述信息',
|
|
||||||
back: '返回',
|
|
||||||
title: '标题',
|
|
||||||
status: '状态',
|
|
||||||
button: '按钮',
|
|
||||||
option: '选项',
|
|
||||||
search: '搜索',
|
|
||||||
content: '内容',
|
|
||||||
custom: '自定义',
|
|
||||||
username: '用户名',
|
|
||||||
password: '密码',
|
|
||||||
disabled: '禁用状态',
|
|
||||||
uneditable: '不可编辑',
|
|
||||||
basicUsage: '基础用法',
|
|
||||||
advancedUsage: '高级用法',
|
|
||||||
loadingStatus: '加载状态',
|
|
||||||
usernamePlaceholder: '请输入用户名',
|
|
||||||
passwordPlaceholder: '请输入密码',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
add: 'Add',
|
|
||||||
decrease: 'Decrease',
|
|
||||||
red: 'Red',
|
|
||||||
orange: 'Orange',
|
|
||||||
yellow: 'Yellow',
|
|
||||||
purple: 'Purple',
|
|
||||||
tab: 'Tab',
|
|
||||||
tag: 'Tag',
|
|
||||||
desc: 'Description',
|
|
||||||
back: 'Back',
|
|
||||||
title: 'Title',
|
|
||||||
status: 'Status',
|
|
||||||
button: 'Button',
|
|
||||||
option: 'Option',
|
|
||||||
search: 'Search',
|
|
||||||
content: 'Content',
|
|
||||||
custom: 'Custom',
|
|
||||||
username: 'Username',
|
|
||||||
password: 'Password',
|
|
||||||
loadingStatus: 'Loading',
|
|
||||||
disabled: 'Disabled',
|
|
||||||
uneditable: 'Uneditable',
|
|
||||||
basicUsage: 'Basic Usage',
|
|
||||||
advancedUsage: 'Advanced Usage',
|
|
||||||
usernamePlaceholder: 'Username',
|
|
||||||
passwordPlaceholder: 'Password',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
import { initDemoLocale } from './demo-locale';
|
|
||||||
import Lazyload from '../../src/lazyload';
|
|
||||||
|
|
||||||
initDemoLocale();
|
|
||||||
|
|
||||||
const { app } = window;
|
|
||||||
if (app) {
|
|
||||||
app.use(Lazyload, {
|
|
||||||
lazyComponent: true,
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,6 +1,95 @@
|
|||||||
import Locale from '../../src/locale';
|
import Locale from '../../src/locale';
|
||||||
|
import enUS from '../../src/locale/lang/en-US';
|
||||||
import { camelize } from '../../src/utils/format/string';
|
import { camelize } from '../../src/utils/format/string';
|
||||||
import { createTranslate } from '../../src/utils/create/translate';
|
import { createTranslate } from '../../src/utils/create/translate';
|
||||||
|
import type { App } from 'vue';
|
||||||
|
import type { Router } from 'vue-router';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
app: App;
|
||||||
|
vueRouter: Router;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initDemoLocale() {
|
||||||
|
Locale.add({
|
||||||
|
'en-US': enUS,
|
||||||
|
});
|
||||||
|
|
||||||
|
// switch lang after routing
|
||||||
|
if (window.vueRouter) {
|
||||||
|
window.vueRouter.afterEach((to) => {
|
||||||
|
const { lang } = to.meta || {};
|
||||||
|
|
||||||
|
if (lang) {
|
||||||
|
Locale.use(lang as string);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// add some basic locale messages
|
||||||
|
Locale.add({
|
||||||
|
'zh-CN': {
|
||||||
|
add: '增加',
|
||||||
|
decrease: '减少',
|
||||||
|
red: '红色',
|
||||||
|
orange: '橙色',
|
||||||
|
yellow: '黄色',
|
||||||
|
purple: '紫色',
|
||||||
|
tab: '标签',
|
||||||
|
tag: '标签',
|
||||||
|
desc: '描述信息',
|
||||||
|
back: '返回',
|
||||||
|
title: '标题',
|
||||||
|
status: '状态',
|
||||||
|
button: '按钮',
|
||||||
|
option: '选项',
|
||||||
|
search: '搜索',
|
||||||
|
content: '内容',
|
||||||
|
custom: '自定义',
|
||||||
|
username: '用户名',
|
||||||
|
password: '密码',
|
||||||
|
disabled: '禁用状态',
|
||||||
|
uneditable: '不可编辑',
|
||||||
|
basicUsage: '基础用法',
|
||||||
|
advancedUsage: '高级用法',
|
||||||
|
loadingStatus: '加载状态',
|
||||||
|
usernamePlaceholder: '请输入用户名',
|
||||||
|
passwordPlaceholder: '请输入密码',
|
||||||
|
},
|
||||||
|
'en-US': {
|
||||||
|
add: 'Add',
|
||||||
|
decrease: 'Decrease',
|
||||||
|
red: 'Red',
|
||||||
|
orange: 'Orange',
|
||||||
|
yellow: 'Yellow',
|
||||||
|
purple: 'Purple',
|
||||||
|
tab: 'Tab',
|
||||||
|
tag: 'Tag',
|
||||||
|
desc: 'Description',
|
||||||
|
back: 'Back',
|
||||||
|
title: 'Title',
|
||||||
|
status: 'Status',
|
||||||
|
button: 'Button',
|
||||||
|
option: 'Option',
|
||||||
|
search: 'Search',
|
||||||
|
content: 'Content',
|
||||||
|
custom: 'Custom',
|
||||||
|
username: 'Username',
|
||||||
|
password: 'Password',
|
||||||
|
loadingStatus: 'Loading',
|
||||||
|
disabled: 'Disabled',
|
||||||
|
uneditable: 'Uneditable',
|
||||||
|
basicUsage: 'Basic Usage',
|
||||||
|
advancedUsage: 'Advanced Usage',
|
||||||
|
usernamePlaceholder: 'Username',
|
||||||
|
passwordPlaceholder: 'Password',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initDemoLocale();
|
||||||
|
|
||||||
let demoUid = 0;
|
let demoUid = 0;
|
||||||
|
|
||||||
|
@ -6,7 +6,4 @@ module.exports = {
|
|||||||
'!**/test/**',
|
'!**/test/**',
|
||||||
'!**/lang/**',
|
'!**/lang/**',
|
||||||
],
|
],
|
||||||
moduleNameMapper: {
|
|
||||||
'^@demo(.*)$': '<rootDir>/docs/site$1',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import Lazyload from '..';
|
||||||
import { useTranslate } from '../../../docs/site/use-translate';
|
import { useTranslate } from '../../../docs/site/use-translate';
|
||||||
|
|
||||||
|
if (window.app) {
|
||||||
|
window.app.use(Lazyload, { lazyComponent: true });
|
||||||
|
}
|
||||||
|
|
||||||
const t = useTranslate({
|
const t = useTranslate({
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
title2: '背景图懒加载',
|
title2: '背景图懒加载',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user