helper.js
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2022-03-25 09:54:08
* @LastEditors: limin
* @LastEditTime: 2022-12-19 09:36:48
* @FilePath: \scrm-base\src\common\helper.js
*/
import constants from './constants'
export function customized(cdn, { assets, title }) {
var link = document.querySelector("link[rel*='icon']") || document.createElement('link')
link.type = 'image/x-icon'
link.rel = 'shortcut icon'
link.href = `${cdn}/assets/${assets}/favicon.ico`
document.getElementsByTagName('head')[0].appendChild(link)
document.title = title
if (assets === 'sc') {
setTheme('#08C489')
}
}
export function setTheme(color) {
if (!color) return
document.documentElement.style.setProperty('--main-color', color)
document.documentElement.style.setProperty('--base-border', color)
}
export function getIcon(iconName) {
const { ICONS, DEFAULT_ICON_NAME } = constants
return ICONS.includes(iconName) && ICONS.includes(iconName + '-active') ? iconName : DEFAULT_ICON_NAME
}
export function locationPath() {
return new Map(
location.search
.slice(1)
.split('&')
.map(kv => kv.split('='))
)
}