Home.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <script setup>
  2. import {
  3. Top,
  4. Paperclip,
  5. CircleCloseFilled,
  6. Plus,
  7. UserFilled
  8. } from '@element-plus/icons-vue'
  9. import {
  10. ElMessage,
  11. ElMessageBox
  12. } from 'element-plus'
  13. import {
  14. ref,
  15. watch,
  16. computed,
  17. onMounted
  18. } from 'vue'
  19. import {
  20. useUserStore
  21. } from '@/store'
  22. import Login from '@/components/Login.vue'
  23. const userStore = useUserStore()
  24. const message = ref('');
  25. const typeList = ref([{
  26. id: 1,
  27. name: '网站'
  28. }, {
  29. id: 2,
  30. name: '移动端'
  31. }]);
  32. const typeValue = ref(1);
  33. const generateTypeList = {
  34. 1: [{
  35. id: 1,
  36. name: '企业官网'
  37. }, {
  38. id: 2,
  39. name: '电商网站'
  40. }, {
  41. id: 3,
  42. name: '服务网站'
  43. }],
  44. 2: [{
  45. id: 1,
  46. name: '企业介绍'
  47. }, {
  48. id: 2,
  49. name: '物业服务'
  50. }]
  51. }
  52. const generateValue = ref(1);
  53. const generateList = computed(() => {
  54. generateValue.value = 1;
  55. return generateTypeList[typeValue.value];
  56. });
  57. const loading = ref(false);
  58. const websiteURL = ref('');
  59. const commandFunction = (command) => {
  60. if (command === 'url') openUrl();
  61. }
  62. const openUrl = () => {
  63. ElMessageBox.prompt('请输入参考网站网址', 'WorkArk.AI提示', {
  64. confirmButtonText: '确认',
  65. cancelButtonText: '取消',
  66. inputPattern: /./,
  67. inputErrorMessage: '请输入网址',
  68. inputValue: websiteURL.value
  69. }).then(({
  70. value
  71. }) => {
  72. websiteURL.value = value;
  73. }).catch(() => {});
  74. }
  75. const imageList = ref([{
  76. id: 1,
  77. url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
  78. }])
  79. const removeImage = (index) => {
  80. ElMessageBox.confirm('是否删除该图片?', 'WorkArk.AI提示', {
  81. confirmButtonText: '确认',
  82. cancelButtonText: '取消',
  83. type: 'warning',
  84. }).then(() => {
  85. imageList.value.splice(index, 1);
  86. }).catch(() => {});
  87. }
  88. const loginVisible = ref(false);
  89. const callback = () => {
  90. loginVisible.value = false;
  91. init();
  92. }
  93. const user = ref({});
  94. const init = () => {
  95. user.value = userStore.userData;
  96. console.log(JSON.stringify(user.value));
  97. }
  98. onMounted(() => {
  99. init();
  100. })
  101. </script>
  102. <template>
  103. <div class="home-container">
  104. <div class="home-nav">
  105. <div class="home-nav-left">
  106. <img class="img"
  107. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/f9617c7f80da485cb3cc72b6accc62ed"
  108. alt="logo.png" />
  109. <span class="title">WorkArk AI</span>
  110. </div>
  111. <div class="home-nav-right">
  112. <div class="item no-token" @click="loginVisible = true" v-if="!user.userId">
  113. <el-avatar :size="36" :icon="UserFilled"></el-avatar>
  114. <span class="name">登录/注册</span>
  115. </div>
  116. <div class="item no-token" v-else>
  117. <el-avatar :size="36" :src="user.portrait"></el-avatar>
  118. <span class="name">{{user.userName}}</span>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="home-form">
  123. <div class="form-title">
  124. <h1 class="big-title"><span>Build By </span><span class="primary">WorkArk.AI</span></h1>
  125. <p class="small-title">通过与AI聊天创建应用程序和网站</p>
  126. </div>
  127. <div class="form-box">
  128. <el-input type="textarea" v-model="message" placeholder="生成一个信息科技企业官网" resize="none" :rows="5"
  129. :autosize="{ minRows: 3, maxRows: 7 }">
  130. </el-input>
  131. <div class="form-submit">
  132. <div class="form-operation">
  133. <el-dropdown @command="commandFunction">
  134. <el-button size="default" :icon="Paperclip" circle></el-button>
  135. <template #dropdown>
  136. <el-dropdown-menu>
  137. <el-dropdown-item command="url">参考网站</el-dropdown-item>
  138. <el-dropdown-item command="image">上传图片</el-dropdown-item>
  139. </el-dropdown-menu>
  140. </template>
  141. </el-dropdown>
  142. <el-button style="margin-left: 10px;" size="default" :icon="Plus" circle></el-button>
  143. </div>
  144. <el-button type="primary" size="large" :icon="Top" circle :loading="loading"></el-button>
  145. </div>
  146. <div class="operation-file" v-if="websiteURL || imageList.length > 0">
  147. <div class="operation-url" v-if="websiteURL">
  148. <el-tag type="info" closable effect="plain" round @close="websiteURL = ''">
  149. {{websiteURL}}
  150. </el-tag>
  151. </div>
  152. <div class="operation-image" v-if="imageList.length > 0">
  153. <div class="image-item" v-for="(image,index) in imageList" :key="image.id">
  154. <el-image style="width: 60px; height: 60px" :src="image.url" fit="cover" />
  155. <el-icon class="image-icon" @click="removeImage(index)">
  156. <CircleCloseFilled />
  157. </el-icon>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. <el-dialog v-model="loginVisible" title="登录" width="440px">
  164. <login v-if="loginVisible" @callback="callback"></login>
  165. </el-dialog>
  166. </div>
  167. </template>
  168. <style lang="scss">
  169. .home-container {
  170. width: 100%;
  171. height: 100%;
  172. background-image: linear-gradient(135deg, #8ab1ff, #8834ef, #ff8a66);
  173. display: flex;
  174. flex-direction: column;
  175. .home-nav {
  176. background: rgba(255, 255, 255, 0.1);
  177. height: 70px;
  178. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  179. display: flex;
  180. align-items: center;
  181. padding: 0 24px;
  182. justify-content: space-between;
  183. .home-nav-left {
  184. display: flex;
  185. align-items: center;
  186. }
  187. .title {
  188. font-weight: 600;
  189. color: #000;
  190. font-size: 20px;
  191. margin-left: 15px;
  192. }
  193. .img {
  194. width: 32px;
  195. height: 32px;
  196. }
  197. .home-nav-right {
  198. .item {
  199. display: flex;
  200. align-items: center;
  201. }
  202. .no-token {
  203. cursor: pointer;
  204. }
  205. .name {
  206. margin-left: 10px;
  207. }
  208. .el-avatar {
  209. background: var(--el-color-primary);
  210. img {
  211. background: #fff;
  212. }
  213. }
  214. }
  215. }
  216. .home-form {
  217. padding: 24px;
  218. display: flex;
  219. flex-direction: column;
  220. align-items: center;
  221. justify-content: center;
  222. flex: 1;
  223. height: 0;
  224. }
  225. .form-title {
  226. .big-title {
  227. text-align: center;
  228. span {
  229. font-size: 72px;
  230. font-weight: bold;
  231. }
  232. .primary {
  233. color: rgba(255, 255, 255, 0.4);
  234. }
  235. }
  236. .img {
  237. width: 44px;
  238. height: 44px;
  239. }
  240. .small-title {
  241. text-align: center;
  242. font-size: 24px;
  243. opacity: 0.8;
  244. margin-top: 20px;
  245. }
  246. }
  247. .form-box {
  248. border: 1px solid #e2e8f0;
  249. background: rgba(255, 255, 255, 0.8);
  250. border-radius: 30px;
  251. width: 100%;
  252. max-width: 800px;
  253. margin-top: 60px;
  254. padding: 16px 16px 6px 16px;
  255. .el-textarea__inner {
  256. border: none;
  257. background: transparent;
  258. box-shadow: none;
  259. &:hover {
  260. box-shadow: none;
  261. }
  262. }
  263. .form-submit {
  264. margin-top: 10px;
  265. display: flex;
  266. align-items: center;
  267. .form-operation {
  268. flex: 1;
  269. width: 0;
  270. overflow: hidden;
  271. display: flex;
  272. }
  273. .iconfont-item {
  274. width: 30px;
  275. height: 30px;
  276. border: 1px solid var(--el-border-color);
  277. background: #fff;
  278. border-radius: 30px;
  279. margin-right: 10px;
  280. display: flex;
  281. align-items: center;
  282. justify-content: center;
  283. cursor: pointer;
  284. font-size: 16px;
  285. color: #606266;
  286. box-sizing: border-box;
  287. }
  288. .el-select__wrapper {
  289. border-radius: 24px;
  290. }
  291. }
  292. .operation-file {
  293. padding: 10px 0;
  294. }
  295. .operation-image {
  296. display: flex;
  297. }
  298. .image-item {
  299. position: relative;
  300. }
  301. .image-icon {
  302. position: absolute;
  303. right: -6px;
  304. top: -6px;
  305. background: #fff;
  306. border-radius: 6px;
  307. cursor: pointer;
  308. color: var(--el-color-error);
  309. }
  310. }
  311. }
  312. </style>