功能变化: 1.允许动态修改网站小图标;
2.允许动态修改网站标题;
This commit is contained in:
@@ -12,6 +12,34 @@
|
|||||||
"placeholder": null,
|
"placeholder": null,
|
||||||
"setting": null,
|
"setting": null,
|
||||||
"children": [
|
"children": [
|
||||||
|
{
|
||||||
|
"parent": 10,
|
||||||
|
"title": "网页标题",
|
||||||
|
"key": "web_title",
|
||||||
|
"value": "DVAdmin",
|
||||||
|
"sort": 1,
|
||||||
|
"status": true,
|
||||||
|
"data_options": null,
|
||||||
|
"form_item_type": 0,
|
||||||
|
"rule": [],
|
||||||
|
"placeholder": "请输入网站标题",
|
||||||
|
"setting": null,
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parent": 10,
|
||||||
|
"title": "网站小图标",
|
||||||
|
"key": "web_favicon",
|
||||||
|
"value": "",
|
||||||
|
"sort": 1,
|
||||||
|
"status": true,
|
||||||
|
"data_options": null,
|
||||||
|
"form_item_type": 0,
|
||||||
|
"rule": [],
|
||||||
|
"placeholder": "请输入网站小图标",
|
||||||
|
"setting": null,
|
||||||
|
"children": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"parent": 10,
|
"parent": 10,
|
||||||
"title": "开启验证码",
|
"title": "开启验证码",
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ watch(
|
|||||||
() => route.path,
|
() => route.path,
|
||||||
() => {
|
() => {
|
||||||
other.useTitle();
|
other.useTitle();
|
||||||
|
other.useFavicon();
|
||||||
if (!websocket.websocket) {
|
if (!websocket.websocket) {
|
||||||
//websockt 模块
|
//websockt 模块
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { useThemeConfig } from '/@/stores/themeConfig';
|
|||||||
import { i18n } from '/@/i18n/index';
|
import { i18n } from '/@/i18n/index';
|
||||||
import { Local } from '/@/utils/storage';
|
import { Local } from '/@/utils/storage';
|
||||||
import { verifyUrl } from '/@/utils/toolsValidate';
|
import { verifyUrl } from '/@/utils/toolsValidate';
|
||||||
|
import {SystemConfigStore} from "/@/stores/systemConfig";
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const SvgIcon = defineAsyncComponent(() => import('/@/components/svgIcon/index.vue'));
|
const SvgIcon = defineAsyncComponent(() => import('/@/components/svgIcon/index.vue'));
|
||||||
@@ -30,18 +31,43 @@ export function elSvg(app: App) {
|
|||||||
* @method const title = useTitle(); ==> title()
|
* @method const title = useTitle(); ==> title()
|
||||||
*/
|
*/
|
||||||
export function useTitle() {
|
export function useTitle() {
|
||||||
const stores = useThemeConfig(pinia);
|
const stores = SystemConfigStore(pinia);
|
||||||
const { themeConfig } = storeToRefs(stores);
|
const { systemConfig } = storeToRefs(stores);
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
let webTitle = '';
|
let webTitle = '';
|
||||||
let globalTitle: string = themeConfig.value.globalTitle;
|
let globalTitle: string = systemConfig['base.web_title'];
|
||||||
const { path, meta } = router.currentRoute.value;
|
const { path, meta } = router.currentRoute.value;
|
||||||
if (path === '/login') {
|
if (path === '/login') {
|
||||||
webTitle = <string>meta.title;
|
webTitle = <string>meta.title;
|
||||||
} else {
|
} else {
|
||||||
webTitle = setTagsViewNameI18n(router.currentRoute.value);
|
webTitle = setTagsViewNameI18n(router.currentRoute.value);
|
||||||
}
|
}
|
||||||
document.title = `${webTitle} - ${globalTitle}` || globalTitle;
|
document.title = `${webTitle} - ${globalTitle}` || "DVAdmin";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 设置网站favicon图标
|
||||||
|
*/
|
||||||
|
export function useFavicon() {
|
||||||
|
const stores = SystemConfigStore(pinia);
|
||||||
|
const { systemConfig } = storeToRefs(stores);
|
||||||
|
nextTick(() => {
|
||||||
|
const iconUrl = systemConfig.value['base.web_favicon']
|
||||||
|
if(iconUrl){
|
||||||
|
// 动态设置 favicon,这里假设 favicon 的 URL 是动态获取的或从变量中来
|
||||||
|
const faviconUrl = `${iconUrl}?t=${new Date().getTime()}`;
|
||||||
|
const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
|
||||||
|
if (!link) {
|
||||||
|
const newLink = document.createElement('link') as HTMLLinkElement;
|
||||||
|
newLink.rel = 'shortcut icon';
|
||||||
|
newLink.href = faviconUrl;
|
||||||
|
document.head.appendChild(newLink);
|
||||||
|
} else {
|
||||||
|
link.href = faviconUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +217,9 @@ const other = {
|
|||||||
useTitle: () => {
|
useTitle: () => {
|
||||||
useTitle();
|
useTitle();
|
||||||
},
|
},
|
||||||
|
useFavicon:()=>{
|
||||||
|
useFavicon()
|
||||||
|
},
|
||||||
setTagsViewNameI18n(route: RouteToFrom) {
|
setTagsViewNameI18n(route: RouteToFrom) {
|
||||||
return setTagsViewNameI18n(route);
|
return setTagsViewNameI18n(route);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user