Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
fix: 记忆开关状态使用搜索会还原开关的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
adproqwq committed Apr 7, 2024
1 parent 1ac5175 commit 1dc7145
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gkdtool-vue",
"version": "2.0.2",
"version": "2.0.3",
"private": true,
"type": "module",
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<script lang="ts">
import { type InputHTMLAttributes, defineComponent } from 'vue'
import { search } from './methods/search'
import { getDefaultSub, getThirdPartySub } from './methods/getSub'
import { getDefaultSub, getThirdPartySub, switchStatus } from './methods/sub'
import { output } from './methods/output'
import { changeSwitch } from './methods/changeSwitch'
import { quickStart } from './methods/quickStart'
import { readFile } from './methods/readFile'
import { edit } from './methods/edit'
import { switchStatus } from './methods/switchStatus'
export default defineComponent({
data() {
return {
codeVer: '2.0.2'
codeVer: '2.0.3'
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/changeSwitch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { script } from './getSub';
import { script } from './sub';

export const changeSwitch = (index: string, job: 'on' | 'off') => {
if (index != 'all') {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/edit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json5 from 'json5'
import { script } from './getSub';
import { script } from './sub';

export const edit = (location: string) => {
let i = location.split('.')[0];
Expand Down
2 changes: 1 addition & 1 deletion src/methods/output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fullScript, script } from './getSub'
import { fullScript, script } from './sub'
import json5 from 'json5'

export const output = (type: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { originSub } from './getSub'
import { originSub } from './sub'
import { writeTable } from './table';

export const search = (target: string) => {
Expand Down
22 changes: 22 additions & 0 deletions src/methods/getSub.ts → src/methods/sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ export const getThirdPartySub = () => {
}
}

export const switchStatus = (type: 'memorize' | 'read') => {
if (type == 'memorize') {
localStorage.setItem(String(fullScript.id), json5.stringify(script));
alert('全部都记下来了!');
}
else if (type == 'read') {
try {
let result = localStorage.getItem(String(fullScript.id));
throw result;
} catch (error) {
if (error == null) {
alert('我的脑子里似乎没有这方面的记忆');
return
}
}
originSub = { ...fullScript }
originSub.apps = json5.parse(localStorage.getItem(String(fullScript.id))!)
alert('一字不落地还原了!');
[fullScript, script, categories] = writeTable(originSub)
}
}

export let originSub: RawSubscription

export let fullScript: RawSubscription
Expand Down
25 changes: 0 additions & 25 deletions src/methods/switchStatus.ts

This file was deleted.

0 comments on commit 1dc7145

Please sign in to comment.