💥 破坏性更新 咱不推荐更新

This commit is contained in:
7836246
2024-03-25 06:55:06 +08:00
parent 9bb0fbd9a6
commit 410dc1ac58
52 changed files with 3645 additions and 1337 deletions
+27
View File
@@ -0,0 +1,27 @@
import { defineStore } from 'pinia'
import { defaultLayout, naiveThemeOverrides } from '@/settings/settings'
import { useDark } from '@vueuse/core'
export const useAppStore = defineStore('app', {
state: () => ({
collapsed: false,
// 直接在状态初始化时判断是否为暗模式
isDark: useDark(),
layout: defaultLayout,
naiveThemeOverrides,
}),
actions: {
switchCollapsed() {
this.collapsed = !this.collapsed
},
setCollapsed(b:any) {
this.collapsed = b
},
toggleDark() {
this.isDark = !this.isDark
},
setLayout(v:any) {
this.layout = v
},
},
persist: true,
})
+73
View File
@@ -0,0 +1,73 @@
import { defineStore } from 'pinia'
interface Tab {
icon: any
path: any
name: any
title: any
}
export const useTabStore = defineStore('tab', {
state: () => ({
tabs: [] as any,
activeTab: '',
reloading: false,
}),
actions: {
setActiveTab(path:string) {
this.activeTab = path
},
setTabs(tabs:any) {
this.tabs = tabs
},
addTab(tab: Tab) {
const findIndex = this.tabs.findIndex((item:any) => item.path === tab.path);
if (findIndex !== -1) {
// Replace the existing tab with the new one
this.tabs.splice(findIndex, 1, tab);
} else {
// Add the new tab
this.tabs.push(tab);
}
// Assuming `setActiveTab` is correctly typed to accept a string
this.setActiveTab(tab.path);
},
async removeTab(path:string) {
this.setTabs(this.tabs.filter((tab:any) => tab.path !== path))
if (path === this.activeTab) {
const router = useRouter();
await router.push(this.tabs[this.tabs.length - 1].path)
}
},
async removeOther(curPath: string) {
this.setTabs(this.tabs.filter((tab: any) => tab.path === curPath));
if (curPath !== this.activeTab) {
const router = useRouter();
await router.push(this.tabs[this.tabs.length - 1].path);
}
},
async removeLeft(curPath: string) {
const curIndex = this.tabs.findIndex((item: any) => item.path === curPath);
const filterTabs = this.tabs.filter((_: any, index: any) => index >= curIndex);
this.setTabs(filterTabs);
if (!filterTabs.find((item: any) => item.path === this.activeTab)) {
const router = useRouter();
await router.push(filterTabs[filterTabs.length - 1].path);
}
},
async removeRight(curPath: string) {
const curIndex = this.tabs.findIndex((item: any) => item.path === curPath);
const filterTabs = this.tabs.filter((_: any, index: any) => index <= curIndex);
this.setTabs(filterTabs);
if (!filterTabs.find((item: any) => item.path === this.activeTab)) {
const router = useRouter();
await router.push(filterTabs[filterTabs.length - 1].path);
}
},
async reloadTab(path: string) {
const findItem = this.tabs.find((item:any) => item.path === path);
if (!findItem) return;
await refreshNuxtData()
},
},
persist:true
})
+245
View File
@@ -0,0 +1,245 @@
import {defineStore} from 'pinia'
export const useApisStore = defineStore('apis', {
state: () => {
const {t} = useI18n()
return {
defaultWhoisArr: [
{
label: "本地接口",
name: "nuxt",
order: 0,
show: true,
disabled: false,
},
{
label: "WHO.CX",
name: "whocx",
order: 1,
show: true,
disabled: false,
},
{
label: "TIAN.HU",
name: "tianhu",
order: 2,
show: true,
disabled: false,
},
{
label: "蛙蛙工具",
name: "iamwawa",
order: 3,
show: true,
disabled: false,
},
],
defaultDnsArr: [
{
label: "本地接口",
name: "nuxt",
order: 0,
show: true,
disabled: false,
iName: "本地 DNS",
flag: 'material-symbols:dns-outline'
},
{
label: "Google",
name: "google",
order: 1,
show: true,
disabled: false,
iName: 'Google',
flag: 'flat-color-icons:google'
},
{
label: "AliYun",
name: "aliyun",
order: 2,
show: true,
disabled: false,
iName: 'AliYun',
flag: 'ant-design:aliyun-outlined'
},
{
label: "Tencent",
name: "tencent",
order: 3,
show: true,
disabled: false,
iName: 'Tencent',
flag: 'emojione:cloud'
},
{
label: "Cloudflare",
name: "cloudflare",
order: 4,
show: false,
disabled: true,
iName: 'CloudFlare',
flag: 'skill-icons:cloudflare-light'
}
],
defaultDomainArr: [
{
label: "本地接口",
name: "nuxt",
order: 0,
show: false,
disabled: true,
iName: "本地 DNS",
flag: 'material-symbols:dns-outline'
},
{
label: "WHO.CX",
name: "whocx",
order: 1,
show: true,
disabled: false,
},
],
newsWhoisArr: [] as any,
newsDnsArr: [] as any,
newsDomainArr: [] as any,
}
},
actions: {
newWhoisList() {
this.newsWhoisArr = this.defaultWhoisArr;
},
// 检查更新
checkNewsWhoisUpdate() {
const mainData = this.newsWhoisArr;
let updatedNum = 0;
if (!mainData) return false;
// console.log("列表尝试更新", this.defaultWhoisArr, this.newsWhoisArr);
// 执行比较并迁移
if (this.newsWhoisArr.length > 0) {
for (const newItem of this.defaultWhoisArr) {
const exists = this.newsWhoisArr.some(
(news: any) =>
newItem.label === news.label && newItem.name === news.name
);
if (!exists) {
// console.log("列表有更新:", newItem);
updatedNum++;
this.newsWhoisArr.push(newItem);
}
}
if (updatedNum) useMessage().success(`成功更新 ${updatedNum} 个Whois数据`);
} else {
// console.log("列表无内容,写入默认");
this.newsWhoisArr = this.defaultWhoisArr;
}
},
newDnsList() {
this.newsDnsArr = this.defaultDnsArr;
},
checkNewsDnsUpdate() {
const mainData = this.newsDnsArr;
let updatedNum = 0;
if (!mainData) return false;
// console.log("列表尝试更新", this.defaultWhoisArr, this.newsWhoisArr);
// 执行比较并迁移
if (this.newsDnsArr.length > 0) {
for (const newItem of this.defaultDnsArr) {
const exists = this.newsDnsArr.some(
(news: any) =>
newItem.label === news.label && newItem.name === news.name
);
if (!exists) {
// console.log("列表有更新:", newItem);
updatedNum++;
this.newsDnsArr.push(newItem);
}
}
if (updatedNum) useMessage().success(`成功更新 ${updatedNum} 个Dns数据`);
} else {
// console.log("列表无内容,写入默认");
this.newsDnsArr = this.defaultDnsArr;
}
},
newListAdd() {
this.newsDomainArr = this.defaultDomainArr;
},
checkNewsDomainUpdate() {
// this.newsDomainArr = this.defaultDomainArr;
const mainData = this.newsDomainArr;
let updatedNum = 0;
if (!mainData) return false;
// console.log("列表尝试更新", this.defaultWhoisArr, this.newsWhoisArr);
// 执行比较并迁移
if (this.newsDomainArr.length > 0) {
for (const newItem of this.defaultDomainArr) {
const exists = this.newsDomainArr.some(
(news: any) =>
newItem.label === news.label && newItem.name === news.name
);
if (!exists) {
// console.log("列表有更新:", newItem);
updatedNum++;
this.newsDomainArr.push(newItem);
}
}
if (updatedNum) useMessage().success(`成功更新 ${updatedNum} 个Domain数据`);
} else {
// console.log("列表无内容,写入默认");
this.newsDomainArr = this.defaultDomainArr;
}
},
moveToTop(name: string) {
// 找到对应元素的索引
const index = this.newsDnsArr.findIndex((item: any) => item.name === name);
if (index === -1) return; // 如果没找到,直接返回
// 获取该元素
const itemToMove = this.newsDnsArr.splice(index, 1)[0];
// 将该元素移动到数组的开头
this.newsDnsArr.unshift(itemToMove);
// 可选:如果您想同时更新所有元素的order属性以反映新的顺序
this.newsDnsArr.forEach((item: any, idx: any) => {
item.order = idx;
});
},
moveDomainToTop(name: string) {
// 找到对应元素的索引
const index = this.newsDomainArr.findIndex((item: any) => item.name === name);
if (index === -1) return; // 如果没找到,直接返回
// 获取该元素
const itemToMove = this.newsDomainArr.splice(index, 1)[0];
// 将该元素移动到数组的开头
this.newsDomainArr.unshift(itemToMove);
// 可选:如果您想同时更新所有元素的order属性以反映新的顺序
this.newsDomainArr.forEach((item: any, idx: any) => {
item.order = idx;
});
},
},
getters: {
// 获取所有的 Whois 服务器
getNewDnsArr: (state: any) => state.newsDnsArr,
// 获取第一个展示的 Dns 服务器
getFirstNewDnsShown: (state: any) => state.newsDnsArr.find((item: any) => item.show),
//判断是否有开启的 Dns 服务器
getHasShownItems(state: any) {
return state.newsDnsArr.some((item: any) => item.show);
},
// 获取第一个展示的 Domain 服务器
getFirstNewDomainShown: (state: any) => state.newsDomainArr.find((item: any) => item.show),
// 判断是否有开启的 Domain 服务器
getHasDomainShown(state: any) {
return state.newsDomainArr.some((item: any) => item.show);
},
},
persist: {
storage: persistedState.cookiesWithOptions({
sameSite: 'strict',
}),
},
})
+116
View File
@@ -0,0 +1,116 @@
import {defineStore} from 'pinia'
export const useDnsStore = defineStore('useDnsStore', {
state: () => {
const {t} = useI18n()
return {
defaultDnsArr: [
{
label: "本地接口",
name: "nuxt",
order: 0,
show: true,
disabled: false,
iName: "本地 DNS",
flag: 'material-symbols:dns-outline'
},
{
label: "Google",
name: "google",
order: 1,
show: true,
disabled: false,
iName: 'Google',
flag: 'flat-color-icons:google'
},
{
label: "AliYun",
name: "aliyun",
order: 2,
show: true,
disabled: false,
iName: 'AliYun',
flag: 'ant-design:aliyun-outlined'
},
{
label: "Tencent",
name: "tencent",
order: 3,
show: true,
disabled: false,
iName: 'Tencent',
flag: 'emojione:cloud'
},
{
label: "Cloudflare",
name: "cloudflare",
order: 4,
show: false,
disabled: true,
iName: 'CloudFlare',
flag: 'skill-icons:cloudflare-light'
}
],
newsDnsArr: [] as any,
}
},
actions: {
newDnsList() {
this.newsDnsArr = this.defaultDnsArr;
},
checkNewsDnsUpdate() {
const mainData = this.newsDnsArr;
let updatedNum = 0;
if (!mainData) return false;
// console.log("列表尝试更新", this.defaultWhoisArr, this.newsWhoisArr);
// 执行比较并迁移
if (this.newsDnsArr.length > 0) {
for (const newItem of this.defaultDnsArr) {
const exists = this.newsDnsArr.some(
(news: any) =>
newItem.label === news.label && newItem.name === news.name
);
if (!exists) {
// console.log("列表有更新:", newItem);
updatedNum++;
this.newsDnsArr.push(newItem);
}
}
if (updatedNum) useMessage().success(`成功更新 ${updatedNum} 个Dns数据`);
} else {
// console.log("列表无内容,写入默认");
this.newsDnsArr = this.defaultDnsArr;
}
},
moveToTop(name: string) {
// 找到对应元素的索引
const index = this.newsDnsArr.findIndex((item: any) => item.name === name);
if (index === -1) return; // 如果没找到,直接返回
// 获取该元素
const itemToMove = this.newsDnsArr.splice(index, 1)[0];
// 将该元素移动到数组的开头
this.newsDnsArr.unshift(itemToMove);
// 可选:如果您想同时更新所有元素的order属性以反映新的顺序
this.newsDnsArr.forEach((item: any, idx: any) => {
item.order = idx;
});
},
},
getters: {
getNewDnsArr: (state: any) => state.newsDnsArr,
// 获取第一个展示的 Dns 服务器
getFirstNewDnsShown: (state: any) => state.newsDnsArr.find((item: any) => item.show),
//判断是否有开启的 Dns 服务器
getHasShownItems(state: any) {
return state.newsDnsArr.some((item: any) => item.show);
},
},
persist: {
storage: persistedState.cookiesWithOptions({
sameSite: 'strict',
}),
},
})
+73
View File
@@ -0,0 +1,73 @@
import {defineStore} from 'pinia'
export const useDomainStore = defineStore('useDomainStore', {
state: () => {
const {t} = useI18n()
return {
defaultDomainArr: [
{
label: "本地接口",
name: "nuxt",
order: 0,
show: false,
disabled: true,
iName: "本地 DNS",
flag: 'material-symbols:dns-outline'
},
{
label: "WHO.CX",
name: "whocx",
order: 1,
show: true,
disabled: false,
},
],
newsDomainArr: [] as any,
}
},
actions: {
newDomainList() {
this.newsDomainArr = this.defaultDomainArr;
},
checkNewsDomainUpdate() {
// this.newsDomainArr = this.defaultDomainArr;
const mainData = this.newsDomainArr;
let updatedNum = 0;
if (!mainData) return false;
// console.log("列表尝试更新", this.defaultWhoisArr, this.newsWhoisArr);
// 执行比较并迁移
if (this.newsDomainArr.length > 0) {
for (const newItem of this.defaultDomainArr) {
const exists = this.newsDomainArr.some(
(news: any) =>
newItem.label === news.label && newItem.name === news.name
);
if (!exists) {
// console.log("列表有更新:", newItem);
updatedNum++;
this.newsDomainArr.push(newItem);
}
}
if (updatedNum) useMessage().success(`成功更新 ${updatedNum} 个Domain数据`);
} else {
// console.log("列表无内容,写入默认");
this.newsDomainArr = this.defaultDomainArr;
}
},
},
getters: {
// 获取第一个展示的 Domain 服务器
getFirstNewDomainShown: (state: any) => state.newsDomainArr.find((item: any) => item.show),
// 判断是否有开启的 Domain 服务器
getHasDomainShown(state: any) {
return state.newsDomainArr.some((item: any) => item.show);
},
},
persist: {
storage: persistedState.cookiesWithOptions({
sameSite: 'strict',
}),
},
})
+13 -3
View File
@@ -1,4 +1,4 @@
import { defineStore } from 'pinia'
import {defineStore} from 'pinia'
export const useSettingsStore = defineStore('settings', {
@@ -6,19 +6,29 @@ export const useSettingsStore = defineStore('settings', {
const {t} = useI18n()
return {
isHistory: true,
isBulletin: true,
isDomainList: true,
linkOpenType: 'currentWindow',
selectedOption: 'whois',
domainSearch: '',
}
},
actions: {
setHistory(value: boolean) {
this.isHistory = value
},
setLinkOpenType(value: string ) {
setLinkOpenType(value: string) {
this.linkOpenType = value
},
setSelectedOption(name: string) {
this.selectedOption = name;
}
},
getters: {
getHistory: (state) => state.isHistory,
getHistory: (state: any) => state.isHistory,
getDomain(state: any) {
return state.domainSearch;
}
},
persist: {
storage: persistedState.cookiesWithOptions({
+80
View File
@@ -0,0 +1,80 @@
import {defineStore} from 'pinia'
export const useWhoisStore = defineStore('useWhoisStore', {
state: () => {
const {t} = useI18n()
return {
defaultWhoisArr: [
{
label: "本地接口",
name: "nuxt",
order: 0,
show: true,
disabled: false,
},
{
label: "WHO.CX",
name: "whocx",
order: 1,
show: true,
disabled: false,
},
{
label: "TIAN.HU",
name: "tianhu",
order: 2,
show: true,
disabled: false,
},
{
label: "蛙蛙工具",
name: "iamwawa",
order: 3,
show: true,
disabled: false,
},
],
newsWhoisArr: [] as any,
}
},
actions: {
newWhoisList() {
this.newsWhoisArr = this.defaultWhoisArr;
},
// 检查更新
checkNewsWhoisUpdate() {
const mainData = this.newsWhoisArr;
let updatedNum = 0;
if (!mainData) return false;
// console.log("列表尝试更新", this.defaultWhoisArr, this.newsWhoisArr);
// 执行比较并迁移
if (this.newsWhoisArr.length > 0) {
for (const newItem of this.defaultWhoisArr) {
const exists = this.newsWhoisArr.some(
(news: any) =>
newItem.label === news.label && newItem.name === news.name
);
if (!exists) {
// console.log("列表有更新:", newItem);
updatedNum++;
this.newsWhoisArr.push(newItem);
}
}
if (updatedNum) useMessage().success(`成功更新 ${updatedNum} 个Whois数据`);
} else {
// console.log("列表无内容,写入默认");
this.newsWhoisArr = this.defaultWhoisArr;
}
},
},
getters: {
// 获取所有的 Whois 服务器
getNewDnsArr: (state: any) => state.newsDnsArr,
},
persist: {
storage: persistedState.cookiesWithOptions({
sameSite: 'strict',
}),
},
})