zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
import Cookies from 'js-cookie'
import config from '@/config/index.js'
 
// 全局函数 - 公共操作相关
const commonFunction = {
    // 跳转到奇文账户域名下的某个路径,默认在当前标签页打开
    goAccount(path, target = '_self') {
        open(`https://account.qiwenshare.com${path}?Rurl=${location.href}`, target)
    },
    /**
     * 设置 Cookies
     * @param {string} name 名称
     * @param {string} value 值
     * @param {object} others 域名、路径、有效期等,封装到对象中
     */
    setCookies(name, value, others = null) {
        Cookies.set(name, value, { domain: config.domain, ...others })
    },
    /**
     * 获取 Cookies
     * @param {string} name 名称
     * @param {object} others 域名、路径等,封装到对象中
     * @returns {string} Cookies 值
     */
    getCookies(name, others = null) {
        return Cookies.get(name, { domain: config.domain, ...others })
    },
    /**
     * 移除 Cookies
     * @param {string} name 名称
     * @param {object} others 域名、路径等,封装到对象中
     */
    removeCookies(name, others = null) {
        Cookies.remove(name, { domain: config.domain, ...others })
    }
}
export default commonFunction