Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
feat: switch mode and some commponent
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanyon committed Mar 13, 2023
1 parent eccee97 commit 6b4913b
Show file tree
Hide file tree
Showing 20 changed files with 542 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
.idea
.vscode/
node_modules
node_modules
dist
Binary file removed dist/assets/google-06fd4ba3.ico
Binary file not shown.
1 change: 0 additions & 1 deletion dist/assets/index-60e7dea1.css

This file was deleted.

3 changes: 0 additions & 3 deletions dist/assets/index-b9955069.js

This file was deleted.

4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Vue + TS</title>
<script type="module" crossorigin src="/assets/index-b9955069.js"></script>
<link rel="stylesheet" href="/assets/index-60e7dea1.css">
<script type="module" crossorigin src="/assets/index-564366c9.js"></script>
<link rel="stylesheet" href="/assets/index-468b33f2.css">
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"tauri": "tauri"
},
"dependencies": {
"@tabler/icons-vue": "^2.10.0",
"@tauri-apps/api": "^1.2.0",
"vue": "^3.2.45"
},
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"build": {
"beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "pnpm build",
"devPath": "http://localhost:1420",
"distDir": "../dist",
"withGlobalTauri": false
"devPath": "http://127.0.0.1:1420/",
"distDir": "../dist"
},
"package": {
"productName": "popup-translation",
Expand Down Expand Up @@ -43,7 +42,12 @@
"icons/icon.ico"
],
"identifier": "io.fzdwx.popup-translation",
"targets": "all"
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
Expand Down
53 changes: 49 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import Translation from "./components/Translation.vue";
import { reactive, provide, watchEffect } from 'vue'
import Translation from "./components/translation.vue";
import Nav from "./components/Nav.vue";
import Set from "./components/Set.vue";
import { KeyInfo, Platform } from "./types/type";
const plat = reactive({
current: Platform.YouDao,
});
const takes = reactive({
isTakes: false,
});
const keyList = reactive<KeyInfo>({
google: {
platform: "Google Key",
key: "",
},
youdao: {
platform: "youdao Key",
key: "",
}
})
const model = reactive({
currentModel: 1,
});
const showSetPage = reactive({
show: false,
});
// watchEffect(()=>{
// console.log(takes.isTakes);
// });
provide("plat", plat);
provide("model", model);
</script>

<template>
<div class="header">
<Nav :plat = plat :takes= takes :showSetPage="showSetPage"/>
</div>
<div class="container">
<Translation />
</div>
<div class="setting" v-if="showSetPage.show">
<Set :keyList="keyList" :model="model"/>
</div>
</template>

<style scoped></style>
<style scoped>
.setting {
position: absolute;
right: 0;
top: 50px;
}
</style>
Binary file added src/assets/youdao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/components/Card.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import Loding from "./Loading.vue";
import Loading from "./common/Loading.vue";
const props = defineProps<{
imgSrc: string;
Expand All @@ -18,15 +18,15 @@ const props = defineProps<{
</div>
<!-- content -->
<div class="text-container target-height">
<Loding :load="props.load">
<Loading :load="props.load">
<!--
if load then show loading
else show text
-->
-->
<div class="text">
{{ props.text }}
</div>
</Loding>
</Loading>
</div>
</div>
</template>
Expand Down
106 changes: 106 additions & 0 deletions src/components/Nav.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<script setup lang="ts">
import {IconSettings, IconBrandGoogle, IconBrandBing, IconBrandNeteaseMusic} from "@tabler/icons-vue";
import Button from "./common/Button.vue";
import { Platform } from "../types/type";
import { ref } from "vue";
const props = defineProps<{
plat: {
current: Platform
},
takes: {
isTakes: boolean,
},
showSetPage: {
show: boolean,
},
}>();
const click = (plat: Platform) => {
props.plat.current = plat;
};
const isTakes = () => {
props.takes.isTakes = !props.takes.isTakes;
};
const color = ref("white");
const show = () => {
props.showSetPage.show = !props.showSetPage.show;
if (props.showSetPage.show) {
color.value = "skyblue";
} else {
color.value = "white";
}
}
</script>

<template>
<div class="nav">
<div class="btns">
<Button class="btn" :class="{ active: plat.current === Platform.YouDao }" @click="click(Platform.YouDao)">
<IconBrandNeteaseMusic :size="16" color="red"></IconBrandNeteaseMusic>
有道词典
</Button>
<Button class="btn" :class="{ active: plat.current === Platform.Bing }" @click="click(Platform.Bing)">
<IconBrandBing :size="16" color="skyblue"></IconBrandBing>
bing
</Button>
<Button class="btn" :class="{ active: plat.current === Platform.Google }" @click="click(Platform.Google)">
<IconBrandGoogle :size="16" color="skyblue"></IconBrandGoogle>
google
</Button>
</div>
<div class="setting">
<div class="takes">
<input type="checkbox" name="takes" id="takes" @change="isTakes()">
<label for="takes">划屏取词</label>
</div>
<IconSettings :color="color" @click="show"></IconSettings>
</div>
</div>
</template>

<style scoped>
.nav {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 50px;
/* background-color: #fff; */
border-bottom: 1px solid #ccc;
}
.nav .btns {
display: flex;
}
.active {
background-color: rgb(91, 77, 77);
}
.btns .btn {
margin: 5px;
flex: 1;
}
.nav .setting {
display: flex;
justify-content: center;
align-items: center;
width: 25%;
cursor: pointer;
}
.setting .takes {
display: flex;
justify-content: center;
align-items: center;
padding: 4px;
margin-right: 8px;
font-size: 14px;
}
.takes > input {
width: 15px;
height: 15px;
}
</style>
50 changes: 50 additions & 0 deletions src/components/Set.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script lang="ts" setup>
import { ref } from "vue";
import { KeyInfo } from "../types/type";
import Input from "./common/Input.vue";
const props = defineProps<{
keyList: KeyInfo,
model: {
currentModel: number,
},
}>();
</script>

<template>
<div class="set">
<div class="model">
选择模式:
<select name="" id="" v-model="props.model.currentModel">
<option :value="1">模式一</option>
<option :value="2">模式二</option>
</select>
</div>
<Input v-for="item in props.keyList" :platform="item.platform" v-model="item.key"></Input>
</div>
</template>

<style scoped>
.set {
display: flex;
flex-direction: column;
justify-content: start;
align-items: start;
width: 400px;
height: calc(100% - 50px);
padding: 8px;
background-color: #1d1d1d;
box-shadow: 1px 4px 10px rgba(255, 255, 255, 0.6);
}
.model {
margin: 8px;
}
.model > select {
width: 100px;
height: 30px;
margin: 8px;
font-size: 16px;
background-color: #1d1d1d;
color: #fff;
}
</style>
Loading

0 comments on commit 6b4913b

Please sign in to comment.